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.AreaShowPoint;
import com.izouma.awesomeadmin.service.AreaShowPointService;
import com.izouma.awesomeadmin.dao.AreaShowPointMapper;

/**
*  service接口实现类
*/
@Service
public class AreaShowPointServiceImpl implements AreaShowPointService{

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

    @Autowired
    private AreaShowPointMapper areaShowPointMapper;

    @Override
    public List<AreaShowPoint> getAreaShowPointList(AreaShowPoint record) {

        logger.info("getAreaShowPointList");
        try {

        return areaShowPointMapper.queryAllAreaShowPoint(record);
        } catch (Exception e) {
        logger.error("getAreaShowPointList", e);
        }

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

        logger.info("getAreaShowPointByPage");
        try {

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

        return areaShowPointMapper.queryAreaShowPointByPage(parameter);
        } catch (Exception e) {
        logger.error("getAreaShowPointByPage", e);
        }

        return null;
    }

    @Override
    public AreaShowPoint getAreaShowPointById(String id) {

        logger.info("getAreaShowPointyId");
        try {

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

        return null;
    }

    @Override
    public AreaShowPoint getAreaShowPoint(AreaShowPoint record) {

        logger.info("getAreaShowPoint");
        try {

            return areaShowPointMapper.queryAreaShowPoint(record);
        } catch (Exception e) {
        logger.error("getAreaShowPoint", e);
        }

        return null;
    }

    @Override
    public boolean createAreaShowPoint(AreaShowPoint record) {

        logger.info("createAreaShowPoint");
        try {

            int updates = areaShowPointMapper.insertSelective(record);

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

        return false;
    }

    @Override
    public boolean deleteAreaShowPoint(AreaShowPoint record) {

        logger.info("deleteAreaShowPoint");
        try {

             int updates = areaShowPointMapper.delete(record);

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

        return false;
    }

    @Override
    public boolean updateAreaShowPoint(AreaShowPoint record) {

        logger.info("updateAreaShowPoint");
        try {

            int updates = areaShowPointMapper.updateByPrimaryKeySelective(record);

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

        return false;
    }
}

