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.ProductCommentImage;
import com.izouma.awesomeadmin.service.ProductCommentImageService;
import com.izouma.awesomeadmin.dao.ProductCommentImageMapper;

/**
*  service接口实现类
*/
@Service
public class ProductCommentImageServiceImpl implements ProductCommentImageService{

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

    @Autowired
    private ProductCommentImageMapper productCommentImageMapper;

    @Override
    public List<ProductCommentImage> getProductCommentImageList(ProductCommentImage record) {

        logger.info("getProductCommentImageList");
        try {

        return productCommentImageMapper.queryAllProductCommentImage(record);
        } catch (Exception e) {
        logger.error("getProductCommentImageList", e);
        }

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

        logger.info("getProductCommentImageByPage");
        try {

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

        return productCommentImageMapper.queryProductCommentImageByPage(parameter);
        } catch (Exception e) {
        logger.error("getProductCommentImageByPage", e);
        }

        return null;
    }

    @Override
    public ProductCommentImage getProductCommentImageById(String id) {

        logger.info("getProductCommentImageyId");
        try {

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

        return null;
    }

    @Override
    public ProductCommentImage getProductCommentImage(ProductCommentImage record) {

        logger.info("getProductCommentImage");
        try {

            return productCommentImageMapper.queryProductCommentImage(record);
        } catch (Exception e) {
        logger.error("getProductCommentImage", e);
        }

        return null;
    }

    @Override
    public boolean createProductCommentImage(ProductCommentImage record) {

        logger.info("createProductCommentImage");
        try {

            int updates = productCommentImageMapper.insertSelective(record);

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

        return false;
    }

    @Override
    public boolean deleteProductCommentImage(String id) {

        logger.info("deleteProductCommentImage");
        try {

             int updates = productCommentImageMapper.delete(id);

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

        return false;
    }

    @Override
    public boolean updateProductCommentImage(ProductCommentImage record) {

        logger.info("updateProductCommentImage");
        try {

            int updates = productCommentImageMapper.updateByPrimaryKeySelective(record);

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

        return false;
    }
}

