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.AimTemplateAim;
import com.izouma.awesomeadmin.service.AimTemplateAimService;
import com.izouma.awesomeadmin.dao.AimTemplateAimMapper;

/**
*  service接口实现类
*/
@Service
public class AimTemplateAimServiceImpl implements AimTemplateAimService{

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

    @Autowired
    private AimTemplateAimMapper aimTemplateAimMapper;

    @Override
    public List<AimTemplateAim> getAimTemplateAimList(AimTemplateAim record) {

        logger.info("getAimTemplateAimList");
        try {

        return aimTemplateAimMapper.queryAllAimTemplateAim(record);
        } catch (Exception e) {
        logger.error("getAimTemplateAimList", e);
        }

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

        logger.info("getAimTemplateAimByPage");
        try {

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

        return aimTemplateAimMapper.queryAimTemplateAimByPage(parameter);
        } catch (Exception e) {
        logger.error("getAimTemplateAimByPage", e);
        }

        return null;
    }

    @Override
    public AimTemplateAim getAimTemplateAimById(String id) {

        logger.info("getAimTemplateAimyId");
        try {

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

        return null;
    }

    @Override
    public AimTemplateAim getAimTemplateAim(AimTemplateAim record) {

        logger.info("getAimTemplateAim");
        try {

            return aimTemplateAimMapper.queryAimTemplateAim(record);
        } catch (Exception e) {
        logger.error("getAimTemplateAim", e);
        }

        return null;
    }

    @Override
    public boolean createAimTemplateAim(AimTemplateAim record) {

        logger.info("createAimTemplateAim");
        try {

            int updates = aimTemplateAimMapper.insertSelective(record);

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

        return false;
    }

    @Override
    public boolean deleteAimTemplateAim(AimTemplateAim record) {

        logger.info("deleteAimTemplateAim");
        try {

             int updates = aimTemplateAimMapper.delete(record);

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

        return false;
    }

    @Override
    public boolean updateAimTemplateAim(AimTemplateAim record) {

        logger.info("updateAimTemplateAim");
        try {

            int updates = aimTemplateAimMapper.updateByPrimaryKeySelective(record);

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

        return false;
    }
}

