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.ArContentChild;
import com.izouma.awesomeadmin.service.ArContentChildService;
import com.izouma.awesomeadmin.dao.ArContentChildMapper;

/**
*  service接口实现类
*/
@Service
public class ArContentChildServiceImpl implements ArContentChildService{

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

    @Autowired
    private ArContentChildMapper arContentChildMapper;

    @Override
    public List<ArContentChild> getArContentChildList(ArContentChild record) {

        logger.info("getArContentChildList");
        try {

        return arContentChildMapper.queryAllArContentChild(record);
        } catch (Exception e) {
        logger.error("getArContentChildList", e);
        }

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

        logger.info("getArContentChildByPage");
        try {

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

        return arContentChildMapper.queryArContentChildByPage(parameter);
        } catch (Exception e) {
        logger.error("getArContentChildByPage", e);
        }

        return null;
    }

    @Override
    public ArContentChild getArContentChildById(String id) {

        logger.info("getArContentChildyId");
        try {

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

        return null;
    }

    @Override
    public ArContentChild getArContentChild(ArContentChild record) {

        logger.info("getArContentChild");
        try {

            return arContentChildMapper.queryArContentChild(record);
        } catch (Exception e) {
        logger.error("getArContentChild", e);
        }

        return null;
    }

    @Override
    public boolean createArContentChild(ArContentChild record) {

        logger.info("createArContentChild");
        try {

            int updates = arContentChildMapper.insertSelective(record);

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

        return false;
    }

    @Override
    public boolean deleteArContentChild(ArContentChild record) {

        logger.info("deleteArContentChild");
        try {

             int updates = arContentChildMapper.delete(record);

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

        return false;
    }

    @Override
    public boolean updateArContentChild(ArContentChild record) {

        logger.info("updateArContentChild");
        try {

            int updates = arContentChildMapper.updateByPrimaryKeySelective(record);

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

        return false;
    }
}

