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.MarketMapBoxDes;
import com.izouma.awesomeadmin.service.MarketMapBoxDesService;
import com.izouma.awesomeadmin.dao.MarketMapBoxDesMapper;

/**
*  service接口实现类
*/
@Service
public class MarketMapBoxDesServiceImpl implements MarketMapBoxDesService{

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

    @Autowired
    private MarketMapBoxDesMapper marketMapBoxDesMapper;

    @Override
    public List<MarketMapBoxDes> getMarketMapBoxDesList(MarketMapBoxDes record) {

        logger.info("getMarketMapBoxDesList");
        try {

        return marketMapBoxDesMapper.queryAllMarketMapBoxDes(record);
        } catch (Exception e) {
        logger.error("getMarketMapBoxDesList", e);
        }

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

        logger.info("getMarketMapBoxDesByPage");
        try {

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

        return marketMapBoxDesMapper.queryMarketMapBoxDesByPage(parameter);
        } catch (Exception e) {
        logger.error("getMarketMapBoxDesByPage", e);
        }

        return null;
    }

    @Override
    public MarketMapBoxDes getMarketMapBoxDesById(String id) {

        logger.info("getMarketMapBoxDesyId");
        try {

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

        return null;
    }

    @Override
    public MarketMapBoxDes getMarketMapBoxDes(MarketMapBoxDes record) {

        logger.info("getMarketMapBoxDes");
        try {

            return marketMapBoxDesMapper.queryMarketMapBoxDes(record);
        } catch (Exception e) {
        logger.error("getMarketMapBoxDes", e);
        }

        return null;
    }

    @Override
    public boolean createMarketMapBoxDes(MarketMapBoxDes record) {

        logger.info("createMarketMapBoxDes");
        try {

            int updates = marketMapBoxDesMapper.insertSelective(record);

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

        return false;
    }

    @Override
    public boolean deleteMarketMapBoxDes(MarketMapBoxDes record) {

        logger.info("deleteMarketMapBoxDes");
        try {

             int updates = marketMapBoxDesMapper.delete(record);

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

        return false;
    }

    @Override
    public boolean updateMarketMapBoxDes(MarketMapBoxDes record) {

        logger.info("updateMarketMapBoxDes");
        try {

            int updates = marketMapBoxDesMapper.updateByPrimaryKeySelective(record);

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

        return false;
    }
}

