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.ArContentType;
import com.izouma.awesomeadmin.service.ArContentTypeService;
import com.izouma.awesomeadmin.dao.ArContentTypeMapper;

/**
*  service接口实现类
*/
@Service
public class ArContentTypeServiceImpl implements ArContentTypeService{

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

    @Autowired
    private ArContentTypeMapper arContentTypeMapper;

    @Override
    public List<ArContentType> getArContentTypeList(ArContentType record) {

        logger.info("getArContentTypeList");
        try {

        return arContentTypeMapper.queryAllArContentType(record);
        } catch (Exception e) {
        logger.error("getArContentTypeList", e);
        }

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

        logger.info("getArContentTypeByPage");
        try {

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

        return arContentTypeMapper.queryArContentTypeByPage(parameter);
        } catch (Exception e) {
        logger.error("getArContentTypeByPage", e);
        }

        return null;
    }

    @Override
    public ArContentType getArContentTypeById(String id) {

        logger.info("getArContentTypeyId");
        try {

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

        return null;
    }

    @Override
    public ArContentType getArContentType(ArContentType record) {

        logger.info("getArContentType");
        try {

            return arContentTypeMapper.queryArContentType(record);
        } catch (Exception e) {
        logger.error("getArContentType", e);
        }

        return null;
    }

    @Override
    public boolean createArContentType(ArContentType record) {

        logger.info("createArContentType");
        try {

            int updates = arContentTypeMapper.insertSelective(record);

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

        return false;
    }

    @Override
    public boolean deleteArContentType(ArContentType record) {

        logger.info("deleteArContentType");
        try {

             int updates = arContentTypeMapper.delete(record);

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

        return false;
    }

    @Override
    public boolean updateArContentType(ArContentType record) {

        logger.info("updateArContentType");
        try {

            int updates = arContentTypeMapper.updateByPrimaryKeySelective(record);

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

        return false;
    }
}

