package com.seer.teach.pay.admin.recharge.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.seer.teach.common.PageListBean;
import com.seer.teach.common.ResultBean;
import com.seer.teach.pay.admin.recharge.controller.resp.CoinRechargeResp;
import com.seer.teach.pay.admin.recharge.service.IAdminCoinRechargeService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import jakarta.annotation.Resource;

@RestController
@Tag(name = "管理端 - 充值记录查询")
@RequestMapping("/pay/recharge")
@RequiredArgsConstructor
public class AdminCoinRechargeController {

    @Resource
    private IAdminCoinRechargeService adminCoinRechargeService;

    /**
     * 查询所有用户的充值记录
     */
    @Operation(summary = "查询所有用户的充值记录")
    @GetMapping("/{size}/{current}")
    @SaCheckPermission("admin:recharge:record:list")
    public ResultBean<PageListBean<CoinRechargeResp>> getAllRechargeRecords(
            @Parameter(description = "每页数量") @PathVariable("size") Integer size,
            @Parameter(description = "当前页") @PathVariable("current") Integer current,
            @Parameter(description = "充值状态，0:待支付, 1: 支付成功") @RequestParam(name = "playStatus", required = false) Integer playStatus,
            @Parameter(description = "充值订单号") @RequestParam(name = "rechargeSn", required = false) String rechargeSn,
            @Parameter(description = "用户Id") @RequestParam(name = "userId", required = false) Integer userId) {
        return ResultBean.success(adminCoinRechargeService.getAllRechargeRecords(size, current, playStatus, rechargeSn,userId));
    }

    /**
     * 查询充值记录详情
     */
    @Operation(summary = "查询充值记录详情")
    @GetMapping("/{id}")
    @SaCheckPermission("admin:recharge:record:detail")
    public ResultBean<CoinRechargeResp> getRechargeRecordDetail(@Parameter(description = "充值记录Id") @PathVariable("id") Integer id) {
        return ResultBean.success(adminCoinRechargeService.getRechargeRecordDetail(id));
    }
}