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.TestAaa;
import com.izouma.awesomeadmin.service.TestAaaService;
import com.izouma.awesomeadmin.dao.TestAaaMapper;

/**
*  service接口实现类
*/
@Service
public class TestAaaServiceImpl implements TestAaaService{

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

    @Autowired
    private TestAaaMapper testAaaMapper;

    @Override
    public List<TestAaa> getTestAaaList(TestAaa record) {

        logger.info("getTestAaaList");
        try {

        return testAaaMapper.queryAllTestAaa(record);
        } catch (Exception e) {
        logger.error("getTestAaaList", e);
        }

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

        logger.info("getTestAaaByPage");
        try {

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

        return testAaaMapper.queryTestAaaByPage(parameter);
        } catch (Exception e) {
        logger.error("getTestAaaByPage", e);
        }

        return null;
    }

    @Override
    public TestAaa getTestAaaById(String id) {

        logger.info("getTestAaayId");
        try {

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

        return null;
    }

    @Override
    public TestAaa getTestAaa(TestAaa record) {

        logger.info("getTestAaa");
        try {

            return testAaaMapper.queryTestAaa(record);
        } catch (Exception e) {
        logger.error("getTestAaa", e);
        }

        return null;
    }

    @Override
    public boolean createTestAaa(TestAaa record) {

        logger.info("createTestAaa");
        try {

            int updates = testAaaMapper.insertSelective(record);

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

        return false;
    }

    @Override
    public boolean deleteTestAaa(TestAaa record) {

        logger.info("deleteTestAaa");
        try {

             int updates = testAaaMapper.delete(record);

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

        return false;
    }

    @Override
    public boolean updateTestAaa(TestAaa record) {

        logger.info("updateTestAaa");
        try {

            int updates = testAaaMapper.updateByPrimaryKeySelective(record);

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

        return false;
    }
}

