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.GuideTipImage;
import com.izouma.awesomeadmin.service.GuideTipImageService;
import com.izouma.awesomeadmin.dao.GuideTipImageMapper;

/**
*  service接口实现类
*/
@Service
public class GuideTipImageServiceImpl implements GuideTipImageService{

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

    @Autowired
    private GuideTipImageMapper guideTipImageMapper;

    @Override
    public List<GuideTipImage> getGuideTipImageList(GuideTipImage record) {

        logger.info("getGuideTipImageList");
        try {

        return guideTipImageMapper.queryAllGuideTipImage(record);
        } catch (Exception e) {
        logger.error("getGuideTipImageList", e);
        }

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

        logger.info("getGuideTipImageByPage");
        try {

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

        return guideTipImageMapper.queryGuideTipImageByPage(parameter);
        } catch (Exception e) {
        logger.error("getGuideTipImageByPage", e);
        }

        return null;
    }

    @Override
    public GuideTipImage getGuideTipImageById(String id) {

        logger.info("getGuideTipImageyId");
        try {

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

        return null;
    }

    @Override
    public GuideTipImage getGuideTipImage(GuideTipImage record) {

        logger.info("getGuideTipImage");
        try {

            return guideTipImageMapper.queryGuideTipImage(record);
        } catch (Exception e) {
        logger.error("getGuideTipImage", e);
        }

        return null;
    }

    @Override
    public boolean createGuideTipImage(GuideTipImage record) {

        logger.info("createGuideTipImage");
        try {

            int updates = guideTipImageMapper.insertSelective(record);

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

        return false;
    }

    @Override
    public boolean deleteGuideTipImage(GuideTipImage record) {

        logger.info("deleteGuideTipImage");
        try {

             int updates = guideTipImageMapper.delete(record);

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

        return false;
    }

    @Override
    public boolean updateGuideTipImage(GuideTipImage record) {

        logger.info("updateGuideTipImage");
        try {

            int updates = guideTipImageMapper.updateByPrimaryKeySelective(record);

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

        return false;
    }
}

