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.MarketAimPlace;
import com.izouma.awesomeadmin.service.MarketAimPlaceService;
import com.izouma.awesomeadmin.dao.MarketAimPlaceMapper;

/**
*  service接口实现类
*/
@Service
public class MarketAimPlaceServiceImpl implements MarketAimPlaceService{

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

    @Autowired
    private MarketAimPlaceMapper marketAimPlaceMapper;

    @Override
    public List<MarketAimPlace> getMarketAimPlaceList(MarketAimPlace record) {

        logger.info("getMarketAimPlaceList");
        try {

        return marketAimPlaceMapper.queryAllMarketAimPlace(record);
        } catch (Exception e) {
        logger.error("getMarketAimPlaceList", e);
        }

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

        logger.info("getMarketAimPlaceByPage");
        try {

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

        return marketAimPlaceMapper.queryMarketAimPlaceByPage(parameter);
        } catch (Exception e) {
        logger.error("getMarketAimPlaceByPage", e);
        }

        return null;
    }

    @Override
    public MarketAimPlace getMarketAimPlaceById(String id) {

        logger.info("getMarketAimPlaceyId");
        try {

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

        return null;
    }

    @Override
    public MarketAimPlace getMarketAimPlace(MarketAimPlace record) {

        logger.info("getMarketAimPlace");
        try {

            return marketAimPlaceMapper.queryMarketAimPlace(record);
        } catch (Exception e) {
        logger.error("getMarketAimPlace", e);
        }

        return null;
    }

    @Override
    public boolean createMarketAimPlace(MarketAimPlace record) {

        logger.info("createMarketAimPlace");
        try {

            int updates = marketAimPlaceMapper.insertSelective(record);

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

        return false;
    }

    @Override
    public boolean deleteMarketAimPlace(MarketAimPlace record) {

        logger.info("deleteMarketAimPlace");
        try {

             int updates = marketAimPlaceMapper.delete(record);

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

        return false;
    }

    @Override
    public boolean updateMarketAimPlace(MarketAimPlace record) {

        logger.info("updateMarketAimPlace");
        try {

            int updates = marketAimPlaceMapper.updateByPrimaryKeySelective(record);

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

        return false;
    }
}

