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.TestCaidan;
import com.izouma.awesomeadmin.service.TestCaidanService;
import com.izouma.awesomeadmin.dao.TestCaidanMapper;

/**
*  service接口实现类
*/
@Service
public class TestCaidanServiceImpl implements TestCaidanService{

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

    @Autowired
    private TestCaidanMapper testCaidanMapper;

    @Override
    public List<TestCaidan> getTestCaidanList(TestCaidan record) {

        logger.info("getTestCaidanList");
        try {

        return testCaidanMapper.queryAllTestCaidan(record);
        } catch (Exception e) {
        logger.error("getTestCaidanList", e);
        }

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

        logger.info("getTestCaidanByPage");
        try {

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

        return testCaidanMapper.queryTestCaidanByPage(parameter);
        } catch (Exception e) {
        logger.error("getTestCaidanByPage", e);
        }

        return null;
    }

    @Override
    public TestCaidan getTestCaidanById(String id) {

        logger.info("getTestCaidanyId");
        try {

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

        return null;
    }

    @Override
    public TestCaidan getTestCaidan(TestCaidan record) {

        logger.info("getTestCaidan");
        try {

            return testCaidanMapper.queryTestCaidan(record);
        } catch (Exception e) {
        logger.error("getTestCaidan", e);
        }

        return null;
    }

    @Override
    public boolean createTestCaidan(TestCaidan record) {

        logger.info("createTestCaidan");
        try {

            int updates = testCaidanMapper.insertSelective(record);

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

        return false;
    }

    @Override
    public boolean deleteTestCaidan(String id) {

        logger.info("deleteTestCaidan");
        try {

             int updates = testCaidanMapper.delete(id);

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

        return false;
    }

    @Override
    public boolean updateTestCaidan(TestCaidan record) {

        logger.info("updateTestCaidan");
        try {

            int updates = testCaidanMapper.updateByPrimaryKeySelective(record);

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

        return false;
    }
}

