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.AlipayTemp;
import com.izouma.awesomeadmin.service.AlipayTempService;
import com.izouma.awesomeadmin.dao.AlipayTempMapper;

/**
*  service接口实现类
*/
@Service
public class AlipayTempServiceImpl implements AlipayTempService{

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

    @Autowired
    private AlipayTempMapper alipayTempMapper;

    @Override
    public List<AlipayTemp> getAlipayTempList(AlipayTemp record) {

        logger.info("getAlipayTempList");
        try {

        return alipayTempMapper.queryAllAlipayTemp(record);
        } catch (Exception e) {
        logger.error("getAlipayTempList", e);
        }

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

        logger.info("getAlipayTempByPage");
        try {

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

        return alipayTempMapper.queryAlipayTempByPage(parameter);
        } catch (Exception e) {
        logger.error("getAlipayTempByPage", e);
        }

        return null;
    }

    @Override
    public AlipayTemp getAlipayTempById(String id) {

        logger.info("getAlipayTempyId");
        try {

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

        return null;
    }

    @Override
    public AlipayTemp getAlipayTemp(AlipayTemp record) {

        logger.info("getAlipayTemp");
        try {

            return alipayTempMapper.queryAlipayTemp(record);
        } catch (Exception e) {
        logger.error("getAlipayTemp", e);
        }

        return null;
    }

    @Override
    public boolean createAlipayTemp(AlipayTemp record) {

        logger.info("createAlipayTemp");
        try {

            int updates = alipayTempMapper.insertSelective(record);

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

        return false;
    }

    @Override
    public boolean deleteAlipayTemp(String id) {

        logger.info("deleteAlipayTemp");
        try {

             int updates = alipayTempMapper.delete(id);

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

        return false;
    }

    @Override
    public boolean updateAlipayTemp(AlipayTemp record) {

        logger.info("updateAlipayTemp");
        try {

            int updates = alipayTempMapper.updateByPrimaryKeySelective(record);

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

        return false;
    }
}

