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.MarketMapBox;
import com.izouma.awesomeadmin.service.MarketMapBoxService;
import com.izouma.awesomeadmin.dao.MarketMapBoxMapper;

/**
*  service接口实现类
*/
@Service
public class MarketMapBoxServiceImpl implements MarketMapBoxService{

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

    @Autowired
    private MarketMapBoxMapper marketMapBoxMapper;

    @Override
    public List<MarketMapBox> getMarketMapBoxList(MarketMapBox record) {

        logger.info("getMarketMapBoxList");
        try {

        return marketMapBoxMapper.queryAllMarketMapBox(record);
        } catch (Exception e) {
        logger.error("getMarketMapBoxList", e);
        }

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

        logger.info("getMarketMapBoxByPage");
        try {

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

        return marketMapBoxMapper.queryMarketMapBoxByPage(parameter);
        } catch (Exception e) {
        logger.error("getMarketMapBoxByPage", e);
        }

        return null;
    }

    @Override
    public MarketMapBox getMarketMapBoxById(String id) {

        logger.info("getMarketMapBoxyId");
        try {

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

        return null;
    }

    @Override
    public MarketMapBox getMarketMapBox(MarketMapBox record) {

        logger.info("getMarketMapBox");
        try {

            return marketMapBoxMapper.queryMarketMapBox(record);
        } catch (Exception e) {
        logger.error("getMarketMapBox", e);
        }

        return null;
    }

    @Override
    public boolean createMarketMapBox(MarketMapBox record) {

        logger.info("createMarketMapBox");
        try {

            int updates = marketMapBoxMapper.insertSelective(record);

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

        return false;
    }

    @Override
    public boolean deleteMarketMapBox(MarketMapBox record) {

        logger.info("deleteMarketMapBox");
        try {

             int updates = marketMapBoxMapper.delete(record);

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

        return false;
    }

    @Override
    public boolean updateMarketMapBox(MarketMapBox record) {

        logger.info("updateMarketMapBox");
        try {

            int updates = marketMapBoxMapper.updateByPrimaryKeySelective(record);

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

        return false;
    }
}

