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.AimPlacePosition;
import com.izouma.awesomeadmin.service.AimPlacePositionService;
import com.izouma.awesomeadmin.dao.AimPlacePositionMapper;

/**
 * service接口实现类
 */
@Service
public class AimPlacePositionServiceImpl implements AimPlacePositionService {

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

    @Autowired
    private AimPlacePositionMapper aimPlacePositionMapper;

    @Override
    public List<AimPlacePosition> getAimPlacePositionList(AimPlacePosition record) {

        logger.info("getAimPlacePositionList");
        try {

            return aimPlacePositionMapper.queryAllAimPlacePosition(record);
        } catch (Exception e) {
            logger.error("getAimPlacePositionList", e);
        }

        return null;
    }

    @Override
    public List<AimPlacePosition> getAimPlacePositionChildList(AimPlacePosition record) {

        logger.info("getAimPlacePositionChildList");
        try {

            return aimPlacePositionMapper.queryAllAimPlacePositionChild(record);
        } catch (Exception e) {
            logger.error("getAimPlacePositionChildList", e);
        }

        return null;
    }

    @Override
    public List<AimPlacePosition> getAimPlacePositionByPage(Page page, AimPlacePosition record) {

        logger.info("getAimPlacePositionByPage");
        try {

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

            return aimPlacePositionMapper.queryAimPlacePositionByPage(parameter);
        } catch (Exception e) {
            logger.error("getAimPlacePositionByPage", e);
        }

        return null;
    }

    @Override
    public AimPlacePosition getAimPlacePositionById(String id) {

        logger.info("getAimPlacePositionyId");
        try {

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

        return null;
    }

    @Override
    public AimPlacePosition getAimPlacePosition(AimPlacePosition record) {

        logger.info("getAimPlacePosition");
        try {

            return aimPlacePositionMapper.queryAimPlacePosition(record);
        } catch (Exception e) {
            logger.error("getAimPlacePosition", e);
        }

        return null;
    }

    @Override
    public boolean createAimPlacePosition(AimPlacePosition record) {

        logger.info("createAimPlacePosition");
        try {

            int updates = aimPlacePositionMapper.insertSelective(record);

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

        return false;
    }

    @Override
    public boolean deleteAimPlacePosition(AimPlacePosition record) {

        logger.info("deleteAimPlacePosition");
        try {

            int updates = aimPlacePositionMapper.delete(record);

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

        return false;
    }

    @Override
    public boolean updateAimPlacePosition(AimPlacePosition record) {

        logger.info("updateAimPlacePosition");
        try {

            int updates = aimPlacePositionMapper.updateByPrimaryKeySelective(record);

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

        return false;
    }
}

