package com.iamberry.wechat.service.integral;

import com.github.pagehelper.PageHelper;
import com.iamberry.wechat.core.entity.integral.IntegralProduct;
import com.iamberry.wechat.core.entity.page.PageRequest;
import com.iamberry.wechat.core.entity.page.PagedResult;
import com.iamberry.wechat.core.entity.receive.ChargerReceive;
import com.iamberry.wechat.face.integral.IntegralProductService;
import com.iamberry.wechat.service.mapper.IntegralProductMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import util.PageUtil;

import java.util.List;

/**
 *  积分商品接口
 * @author ys
 * @Date 2018-04-28
 */
@Service
public class IntegralProductServiceImpl  implements IntegralProductService {
    @Autowired
    private IntegralProductMapper integralProductMapper;
    /**
     * 获取集合
     * @param  integralProduct
     * @return List
     */
    @Override
    public List<IntegralProduct> getIntegralProductList(IntegralProduct  integralProduct){
        return  integralProductMapper.getIntegralProductList(integralProduct);
    }

    @Override
    public PagedResult<IntegralProduct> listIntegralProductPage(PageRequest<IntegralProduct> pageRequest) {
        PageHelper.startPage(pageRequest.getPageNO(), pageRequest.getPageSize(), pageRequest.isPageTotal());
        List<IntegralProduct> detedctList = integralProductMapper.getIntegralProductList(pageRequest.getData());
        return PageUtil.getPage(detedctList);
    }

    /**
     * 查询单条数据
     * @param  id
     * @return  integralProduct
     */
    @Override
    public  IntegralProduct  getIntegralProductById(Integer  id){
        return  integralProductMapper.getIntegralProductById(id);
    }
    /**
     * 增加数据
     * @param  integralProduct
     * @return Integer
     */
    @Override
    public  Integer  save(IntegralProduct  integralProduct){
        return  integralProductMapper.save(integralProduct);
    }
    /**
     * 修改数据
     * @param  integralProduct
     * @return Integer
     */
    @Override
    public  Integer  update(IntegralProduct integralProduct){
        return  integralProductMapper.update(integralProduct);
    }
    /**
     * 删除数据
     * @param  id
     * @return Integer
     */
    @Override
    public  Integer  delete(Integer  id){
        return  integralProductMapper.delete(id);
    }
}