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.AimPlaceContentChild;
import com.izouma.awesomeadmin.service.AimPlaceContentChildService;
import com.izouma.awesomeadmin.dao.AimPlaceContentChildMapper;

/**
*  service接口实现类
*/
@Service
public class AimPlaceContentChildServiceImpl implements AimPlaceContentChildService{

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

    @Autowired
    private AimPlaceContentChildMapper aimPlaceContentChildMapper;

    @Override
    public List<AimPlaceContentChild> getAimPlaceContentChildList(AimPlaceContentChild record) {

        logger.info("getAimPlaceContentChildList");
        try {

        return aimPlaceContentChildMapper.queryAllAimPlaceContentChild(record);
        } catch (Exception e) {
        logger.error("getAimPlaceContentChildList", e);
        }

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

        logger.info("getAimPlaceContentChildByPage");
        try {

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

        return aimPlaceContentChildMapper.queryAimPlaceContentChildByPage(parameter);
        } catch (Exception e) {
        logger.error("getAimPlaceContentChildByPage", e);
        }

        return null;
    }

    @Override
    public AimPlaceContentChild getAimPlaceContentChildById(String id) {

        logger.info("getAimPlaceContentChildyId");
        try {

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

        return null;
    }

    @Override
    public AimPlaceContentChild getAimPlaceContentChild(AimPlaceContentChild record) {

        logger.info("getAimPlaceContentChild");
        try {

            return aimPlaceContentChildMapper.queryAimPlaceContentChild(record);
        } catch (Exception e) {
        logger.error("getAimPlaceContentChild", e);
        }

        return null;
    }

    @Override
    public boolean createAimPlaceContentChild(AimPlaceContentChild record) {

        logger.info("createAimPlaceContentChild");
        try {

            int updates = aimPlaceContentChildMapper.insertSelective(record);

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

        return false;
    }

    @Override
    public boolean deleteAimPlaceContentChild(AimPlaceContentChild record) {

        logger.info("deleteAimPlaceContentChild");
        try {

             int updates = aimPlaceContentChildMapper.delete(record);

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

        return false;
    }

    @Override
    public boolean updateAimPlaceContentChild(AimPlaceContentChild record) {

        logger.info("updateAimPlaceContentChild");
        try {

            int updates = aimPlaceContentChildMapper.updateByPrimaryKeySelective(record);

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

        return false;
    }
}

