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.AimPlaceContent;
import com.izouma.awesomeadmin.service.AimPlaceContentService;
import com.izouma.awesomeadmin.dao.AimPlaceContentMapper;

/**
*  service接口实现类
*/
@Service
public class AimPlaceContentServiceImpl implements AimPlaceContentService{

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

    @Autowired
    private AimPlaceContentMapper aimPlaceContentMapper;

    @Override
    public List<AimPlaceContent> getAimPlaceContentList(AimPlaceContent record) {

        logger.info("getAimPlaceContentList");
        try {

        return aimPlaceContentMapper.queryAllAimPlaceContent(record);
        } catch (Exception e) {
        logger.error("getAimPlaceContentList", e);
        }

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

        logger.info("getAimPlaceContentByPage");
        try {

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

        return aimPlaceContentMapper.queryAimPlaceContentByPage(parameter);
        } catch (Exception e) {
        logger.error("getAimPlaceContentByPage", e);
        }

        return null;
    }

    @Override
    public AimPlaceContent getAimPlaceContentById(String id) {

        logger.info("getAimPlaceContentyId");
        try {

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

        return null;
    }

    @Override
    public AimPlaceContent getAimPlaceContent(AimPlaceContent record) {

        logger.info("getAimPlaceContent");
        try {

            return aimPlaceContentMapper.queryAimPlaceContent(record);
        } catch (Exception e) {
        logger.error("getAimPlaceContent", e);
        }

        return null;
    }

    @Override
    public boolean createAimPlaceContent(AimPlaceContent record) {

        logger.info("createAimPlaceContent");
        try {

            int updates = aimPlaceContentMapper.insertSelective(record);

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

        return false;
    }

    @Override
    public boolean deleteAimPlaceContent(AimPlaceContent record) {

        logger.info("deleteAimPlaceContent");
        try {

             int updates = aimPlaceContentMapper.delete(record);

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

        return false;
    }

    @Override
    public boolean updateAimPlaceContent(AimPlaceContent record) {

        logger.info("updateAimPlaceContent");
        try {

            int updates = aimPlaceContentMapper.updateByPrimaryKeySelective(record);

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

        return false;
    }
}

