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.LandMark;
import com.izouma.awesomeadmin.service.LandMarkService;
import com.izouma.awesomeadmin.dao.LandMarkMapper;

/**
 * service接口实现类
 */
@Service
public class LandMarkServiceImpl implements LandMarkService {

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

    @Autowired
    private LandMarkMapper landMarkMapper;

    @Override
    public List<LandMark> getLandMarkList(LandMark record) {

        logger.info("getLandMarkList");
        try {

            return landMarkMapper.queryAllLandMark(record);
        } catch (Exception e) {
            logger.error("getLandMarkList", e);
        }

        return null;
    }

    @Override
    public List<LandMark> getLandMarkChildList(LandMark record) {

        logger.info("getLandMarkChildList");
        try {

            return landMarkMapper.queryAllLandMarkChild(record);
        } catch (Exception e) {
            logger.error("getLandMarkChildList", e);
        }

        return null;
    }

    @Override
    public List<LandMark> getLandMarkByPage(Page page, LandMark record) {

        logger.info("getLandMarkByPage");
        try {

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

            return landMarkMapper.queryLandMarkByPage(parameter);
        } catch (Exception e) {
            logger.error("getLandMarkByPage", e);
        }

        return null;
    }

    @Override
    public List<LandMark> getCityLandMarkByPage(Page page, LandMark record) {

        logger.info("getCityLandMarkByPage");
        try {

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

            return landMarkMapper.queryCityLandMarkByPage(parameter);
        } catch (Exception e) {
            logger.error("getCityLandMarkByPage", e);
        }

        return null;
    }

    @Override
    public LandMark getLandMarkById(String id) {

        logger.info("getLandMarkyId");
        try {

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

        return null;
    }

    @Override
    public LandMark getLandMark(LandMark record) {

        logger.info("getLandMark");
        try {

            return landMarkMapper.queryLandMark(record);
        } catch (Exception e) {
            logger.error("getLandMark", e);
        }

        return null;
    }

    @Override
    public LandMark getLandMarkMapInfo(LandMark record) {

        logger.info("getLandMarkMapInfo");
        try {

            return landMarkMapper.queryLandMarkMapInfo(record);
        } catch (Exception e) {
            logger.error("getLandMarkMapInfo", e);
        }

        return null;
    }

    @Override
    public boolean createLandMark(LandMark record) {

        logger.info("createLandMark");
        try {

            int updates = landMarkMapper.insertSelective(record);

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

        return false;
    }

    @Override
    public boolean deleteLandMark(LandMark record) {

        logger.info("deleteLandMark");
        try {

            int updates = landMarkMapper.delete(record);

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

        return false;
    }

    @Override
    public boolean updateLandMark(LandMark record) {

        logger.info("updateLandMark");
        try {

            int updates = landMarkMapper.updateByPrimaryKeySelective(record);

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

        return false;
    }
}

