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.ImageDownLog;
import com.izouma.awesomeadmin.service.ImageDownLogService;
import com.izouma.awesomeadmin.dao.ImageDownLogMapper;

/**
*  service接口实现类
*/
@Service
public class ImageDownLogServiceImpl implements ImageDownLogService{

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

    @Autowired
    private ImageDownLogMapper imageDownLogMapper;

    @Override
    public List<ImageDownLog> getImageDownLogList(ImageDownLog record) {

        logger.info("getImageDownLogList");
        try {

        return imageDownLogMapper.queryAllImageDownLog(record);
        } catch (Exception e) {
        logger.error("getImageDownLogList", e);
        }

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

        logger.info("getImageDownLogByPage");
        try {

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

        return imageDownLogMapper.queryImageDownLogByPage(parameter);
        } catch (Exception e) {
        logger.error("getImageDownLogByPage", e);
        }

        return null;
    }

    @Override
    public ImageDownLog getImageDownLogById(String id) {

        logger.info("getImageDownLogyId");
        try {

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

        return null;
    }

    @Override
    public ImageDownLog getImageDownLog(ImageDownLog record) {

        logger.info("getImageDownLog");
        try {

            return imageDownLogMapper.queryImageDownLog(record);
        } catch (Exception e) {
        logger.error("getImageDownLog", e);
        }

        return null;
    }

    @Override
    public boolean createImageDownLog(ImageDownLog record) {

        logger.info("createImageDownLog");
        try {

            int updates = imageDownLogMapper.insertSelective(record);

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

        return false;
    }

    @Override
    public boolean deleteImageDownLog(ImageDownLog record) {

        logger.info("deleteImageDownLog");
        try {

             int updates = imageDownLogMapper.delete(record);

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

        return false;
    }

    @Override
    public boolean updateImageDownLog(ImageDownLog record) {

        logger.info("updateImageDownLog");
        try {

            int updates = imageDownLogMapper.updateByPrimaryKeySelective(record);

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

        return false;
    }
}

