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.AimPlacePositionLevel;
import com.izouma.awesomeadmin.service.AimPlacePositionLevelService;
import com.izouma.awesomeadmin.dao.AimPlacePositionLevelMapper;

/**
*  service接口实现类
*/
@Service
public class AimPlacePositionLevelServiceImpl implements AimPlacePositionLevelService{

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

    @Autowired
    private AimPlacePositionLevelMapper aimPlacePositionLevelMapper;

    @Override
    public List<AimPlacePositionLevel> getAimPlacePositionLevelList(AimPlacePositionLevel record) {

        logger.info("getAimPlacePositionLevelList");
        try {

        return aimPlacePositionLevelMapper.queryAllAimPlacePositionLevel(record);
        } catch (Exception e) {
        logger.error("getAimPlacePositionLevelList", e);
        }

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

        logger.info("getAimPlacePositionLevelByPage");
        try {

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

        return aimPlacePositionLevelMapper.queryAimPlacePositionLevelByPage(parameter);
        } catch (Exception e) {
        logger.error("getAimPlacePositionLevelByPage", e);
        }

        return null;
    }

    @Override
    public AimPlacePositionLevel getAimPlacePositionLevelById(String id) {

        logger.info("getAimPlacePositionLevelyId");
        try {

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

        return null;
    }

    @Override
    public AimPlacePositionLevel getAimPlacePositionLevel(AimPlacePositionLevel record) {

        logger.info("getAimPlacePositionLevel");
        try {

            return aimPlacePositionLevelMapper.queryAimPlacePositionLevel(record);
        } catch (Exception e) {
        logger.error("getAimPlacePositionLevel", e);
        }

        return null;
    }

    @Override
    public boolean createAimPlacePositionLevel(AimPlacePositionLevel record) {

        logger.info("createAimPlacePositionLevel");
        try {

            int updates = aimPlacePositionLevelMapper.insertSelective(record);

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

        return false;
    }

    @Override
    public boolean deleteAimPlacePositionLevel(AimPlacePositionLevel record) {

        logger.info("deleteAimPlacePositionLevel");
        try {

             int updates = aimPlacePositionLevelMapper.delete(record);

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

        return false;
    }

    @Override
    public boolean updateAimPlacePositionLevel(AimPlacePositionLevel record) {

        logger.info("updateAimPlacePositionLevel");
        try {

            int updates = aimPlacePositionLevelMapper.updateByPrimaryKeySelective(record);

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

        return false;
    }
}

