package com.ycwl.basic.service.pc.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ycwl.basic.mapper.CouponRecordMapper;
import com.ycwl.basic.model.pc.couponRecord.entity.CouponRecordEntity;
import com.ycwl.basic.model.pc.couponRecord.req.CouponRecordPageQueryReq;
import com.ycwl.basic.model.pc.couponRecord.resp.CouponRecordPageResp;
import com.ycwl.basic.service.pc.CouponRecordService;
import com.ycwl.basic.utils.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CouponRecordServiceImpl extends ServiceImpl<CouponRecordMapper, CouponRecordEntity> implements CouponRecordService {

    @Autowired
    private CouponRecordMapper couponRecordMapper;

    @Override
    public ApiResponse<PageInfo<CouponRecordPageResp>> pageQuery(CouponRecordPageQueryReq query) {
        PageHelper.startPage(query.getPageNum(), query.getPageSize());
        List<CouponRecordPageResp> list = couponRecordMapper.selectByPageQuery(query);
        PageInfo<CouponRecordPageResp> pageInfo = new PageInfo<>(list);
        return ApiResponse.success(pageInfo);
    }
}