package com.izouma.awesomeadmin.service.impl;

import java.util.*;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.izouma.awesomeadmin.constant.AppConstant;
import com.izouma.awesomeadmin.dto.Page;
import com.izouma.awesomeadmin.model.TestBbb;
import com.izouma.awesomeadmin.service.TestBbbService;
import com.izouma.awesomeadmin.dao.TestBbbMapper;

/**
*  service接口实现类
*/
@Service
public class TestBbbServiceImpl implements TestBbbService{

    private static Logger logger = Logger.getLogger(TestBbbServiceImpl.class);

    @Autowired
    private TestBbbMapper testBbbMapper;

    @Override
    public List<TestBbb> getTestBbbList(TestBbb record) {

        logger.info("getTestBbbList");
        try {

        return testBbbMapper.queryAllTestBbb(record);
        } catch (Exception e) {
        logger.error("getTestBbbList", e);
        }

        return null;
    }
    @Override
    public List<TestBbb> getTestBbbByPage(Page page, TestBbb record) {

        logger.info("getTestBbbByPage");
        try {

        Map<String, Object> parameter = new HashMap<String, Object>();
        parameter.put("record", record);
        parameter.put(AppConstant.PAGE, page);

        return testBbbMapper.queryTestBbbByPage(parameter);
        } catch (Exception e) {
        logger.error("getTestBbbByPage", e);
        }

        return null;
    }

    @Override
    public TestBbb getTestBbbById(String id) {

        logger.info("getTestBbbyId");
        try {

            return testBbbMapper.selectByPrimaryKey(Integer.valueOf(id));
        } catch (Exception e) {
        logger.error("getTestBbbById", e);
        }

        return null;
    }

    @Override
    public TestBbb getTestBbb(TestBbb record) {

        logger.info("getTestBbb");
        try {

            return testBbbMapper.queryTestBbb(record);
        } catch (Exception e) {
        logger.error("getTestBbb", e);
        }

        return null;
    }

    @Override
    public boolean createTestBbb(TestBbb record) {

        logger.info("createTestBbb");
        try {

            int updates = testBbbMapper.insertSelective(record);

            if (updates > 0) {
                 return true;
            }
        } catch (Exception e) {
            logger.error("createTestBbb", e);
        }

        return false;
    }

    @Override
    public boolean deleteTestBbb(TestBbb record) {

        logger.info("deleteTestBbb");
        try {

             int updates = testBbbMapper.delete(record);

            if (updates > 0) {
                 return true;
            }
        } catch (Exception e) {
             logger.error("deleteTestBbb", e);
        }

        return false;
    }

    @Override
    public boolean updateTestBbb(TestBbb record) {

        logger.info("updateTestBbb");
        try {

            int updates = testBbbMapper.updateByPrimaryKeySelective(record);

            if (updates > 0) {
                 return true;
            }
        } catch (Exception e) {
             logger.error("updateTestBbb", e);
        }

        return false;
    }
}

