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.LandmarkType;
import com.izouma.awesomeadmin.service.LandmarkTypeService;
import com.izouma.awesomeadmin.dao.LandmarkTypeMapper;

/**
*  service接口实现类
*/
@Service
public class LandmarkTypeServiceImpl implements LandmarkTypeService{

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

    @Autowired
    private LandmarkTypeMapper landmarkTypeMapper;

    @Override
    public List<LandmarkType> getLandmarkTypeList(LandmarkType record) {

        logger.info("getLandmarkTypeList");
        try {

        return landmarkTypeMapper.queryAllLandmarkType(record);
        } catch (Exception e) {
        logger.error("getLandmarkTypeList", e);
        }

        return null;
    }
    @Override
    public List<LandmarkType> getLandmarkTypeAllAreaList(LandmarkType record) {

        logger.info("getLandmarkTypeAllAreaList");
        try {

        return landmarkTypeMapper.queryAllLandmarkTypeAllArea(record);
        } catch (Exception e) {
        logger.error("getLandmarkTypeAllAreaList", e);
        }

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

        logger.info("getLandmarkTypeByPage");
        try {

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

        return landmarkTypeMapper.queryLandmarkTypeByPage(parameter);
        } catch (Exception e) {
        logger.error("getLandmarkTypeByPage", e);
        }

        return null;
    }

    @Override
    public LandmarkType getLandmarkTypeById(String id) {

        logger.info("getLandmarkTypeyId");
        try {

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

        return null;
    }

    @Override
    public LandmarkType getLandmarkType(LandmarkType record) {

        logger.info("getLandmarkType");
        try {

            return landmarkTypeMapper.queryLandmarkType(record);
        } catch (Exception e) {
        logger.error("getLandmarkType", e);
        }

        return null;
    }

    @Override
    public boolean createLandmarkType(LandmarkType record) {

        logger.info("createLandmarkType");
        try {

            int updates = landmarkTypeMapper.insertSelective(record);

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

        return false;
    }

    @Override
    public boolean deleteLandmarkType(LandmarkType record) {

        logger.info("deleteLandmarkType");
        try {

             int updates = landmarkTypeMapper.delete(record);

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

        return false;
    }

    @Override
    public boolean updateLandmarkType(LandmarkType record) {

        logger.info("updateLandmarkType");
        try {

            int updates = landmarkTypeMapper.updateByPrimaryKeySelective(record);

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

        return false;
    }
}

