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.LandMarkLevel;
import com.izouma.awesomeadmin.service.LandMarkLevelService;
import com.izouma.awesomeadmin.dao.LandMarkLevelMapper;

/**
*  service接口实现类
*/
@Service
public class LandMarkLevelServiceImpl implements LandMarkLevelService{

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

    @Autowired
    private LandMarkLevelMapper landMarkLevelMapper;

    @Override
    public List<LandMarkLevel> getLandMarkLevelList(LandMarkLevel record) {

        logger.info("getLandMarkLevelList");
        try {

        return landMarkLevelMapper.queryAllLandMarkLevel(record);
        } catch (Exception e) {
        logger.error("getLandMarkLevelList", e);
        }

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

        logger.info("getLandMarkLevelByPage");
        try {

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

        return landMarkLevelMapper.queryLandMarkLevelByPage(parameter);
        } catch (Exception e) {
        logger.error("getLandMarkLevelByPage", e);
        }

        return null;
    }

    @Override
    public LandMarkLevel getLandMarkLevelById(String id) {

        logger.info("getLandMarkLevelyId");
        try {

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

        return null;
    }

    @Override
    public LandMarkLevel getLandMarkLevel(LandMarkLevel record) {

        logger.info("getLandMarkLevel");
        try {

            return landMarkLevelMapper.queryLandMarkLevel(record);
        } catch (Exception e) {
        logger.error("getLandMarkLevel", e);
        }

        return null;
    }

    @Override
    public boolean createLandMarkLevel(LandMarkLevel record) {

        logger.info("createLandMarkLevel");
        try {

            int updates = landMarkLevelMapper.insertSelective(record);

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

        return false;
    }

    @Override
    public boolean deleteLandMarkLevel(LandMarkLevel record) {

        logger.info("deleteLandMarkLevel");
        try {

             int updates = landMarkLevelMapper.delete(record);

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

        return false;
    }

    @Override
    public boolean updateLandMarkLevel(LandMarkLevel record) {

        logger.info("updateLandMarkLevel");
        try {

            int updates = landMarkLevelMapper.updateByPrimaryKeySelective(record);

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

        return false;
    }
}

