package cn.iocoder.yudao.module.custom.controller.admin;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.custom.service.CustomerBalanceChangeService;
import cn.iocoder.yudao.module.custom.vo.CustomerBalanceChangePageReqVO;
import cn.iocoder.yudao.module.custom.vo.CustomerBalanceChangeRespVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 用户积分（余额）、卡券变动记录")
@RestController
@RequestMapping("/base/customer-balance-change")
@Validated
public class CustomerBalanceChangeController {

    @Resource
    private CustomerBalanceChangeService customerBalanceChangeService;

    /**
     * 分页查询变更记录
     *
     * @param pageReqVO CustomerBalanceChangePageReqVO实体
     * @param pageNo    分页参数
     * @param pageSize  分页参数
     * @return cn.iocoder.yudao.framework.common.pojo.CommonResult<com.baomidou.mybatisplus.core.metadata.IPage < ?>>
     * @author PQZ
     * @date 22:37 2024/9/20
     **/
    @GetMapping("/page")
    @Operation(summary = "获得用户积分（余额）、卡券变动记录分页")
    @PreAuthorize("@ss.hasPermission('base:customer-balance-change:query')")
    public CommonResult<IPage<?>> getCustomerBalanceChangePage(CustomerBalanceChangePageReqVO pageReqVO,
                                                               @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                               @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
        Page<CustomerBalanceChangeRespVO> page = new Page<>(pageNo, pageSize);
        return success(customerBalanceChangeService.queryListPage(pageReqVO,page));
    }


}