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.AimTemplateAr;
import com.izouma.awesomeadmin.service.AimTemplateArService;
import com.izouma.awesomeadmin.dao.AimTemplateArMapper;

/**
*  service接口实现类
*/
@Service
public class AimTemplateArServiceImpl implements AimTemplateArService{

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

    @Autowired
    private AimTemplateArMapper aimTemplateArMapper;

    @Override
    public List<AimTemplateAr> getAimTemplateArList(AimTemplateAr record) {

        logger.info("getAimTemplateArList");
        try {

        return aimTemplateArMapper.queryAllAimTemplateAr(record);
        } catch (Exception e) {
        logger.error("getAimTemplateArList", e);
        }

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

        logger.info("getAimTemplateArByPage");
        try {

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

        return aimTemplateArMapper.queryAimTemplateArByPage(parameter);
        } catch (Exception e) {
        logger.error("getAimTemplateArByPage", e);
        }

        return null;
    }

    @Override
    public AimTemplateAr getAimTemplateArById(String id) {

        logger.info("getAimTemplateAryId");
        try {

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

        return null;
    }

    @Override
    public AimTemplateAr getAimTemplateAr(AimTemplateAr record) {

        logger.info("getAimTemplateAr");
        try {

            return aimTemplateArMapper.queryAimTemplateAr(record);
        } catch (Exception e) {
        logger.error("getAimTemplateAr", e);
        }

        return null;
    }

    @Override
    public boolean createAimTemplateAr(AimTemplateAr record) {

        logger.info("createAimTemplateAr");
        try {

            int updates = aimTemplateArMapper.insertSelective(record);

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

        return false;
    }

    @Override
    public boolean deleteAimTemplateAr(AimTemplateAr record) {

        logger.info("deleteAimTemplateAr");
        try {

             int updates = aimTemplateArMapper.delete(record);

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

        return false;
    }

    @Override
    public boolean updateAimTemplateAr(AimTemplateAr record) {

        logger.info("updateAimTemplateAr");
        try {

            int updates = aimTemplateArMapper.updateByPrimaryKeySelective(record);

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

        return false;
    }
}

