package com.seer.teach.pay.admin.withdrawal.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.withdrawal.controller.request.AdminPayMerchantRevenueUsagePageReq;
import com.seer.teach.pay.admin.withdrawal.controller.request.AdminPayMerchantRevenueUsageQueryReq;
import com.seer.teach.pay.admin.withdrawal.controller.response.AdminPayMerchantRevenueUsageResp;
import com.seer.teach.pay.admin.withdrawal.service.AdminPayMerchantRevenueUsageService;
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.*;

import jakarta.validation.Valid;
import java.util.List;

/**
 * 收益使用记录控制器
 *
 * @author ZS
 * @since 2025-10-16
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/pay/revenue/usage")
@Tag(name = "管理端 - 收益使用记录管理")
public class AdminPayMerchantRevenueUsageController {

    private final AdminPayMerchantRevenueUsageService adminPayMerchantRevenueUsageService;

    @PostMapping("/paged")
    @Operation(summary = "分页查询收益使用记录")
    @SaCheckPermission("admin:pay:merchant:revenue:usage:page")
    public ResultBean<PageListBean<AdminPayMerchantRevenueUsageResp>> pageList(@Parameter(description = "分页查询参数") @Valid @RequestBody AdminPayMerchantRevenueUsagePageReq pageRequest) {
        return ResultBean.success(adminPayMerchantRevenueUsageService.pageList(pageRequest));
    }

    @PostMapping("/list")
    @Operation(summary = "获取收益使用记录列表")
    @SaCheckPermission("admin:pay:merchant:revenue:usage:list")
    public ResultBean<List<AdminPayMerchantRevenueUsageResp>> list(@Parameter(description = "查询参数") @Valid @RequestBody AdminPayMerchantRevenueUsageQueryReq queryRequest) {
        return ResultBean.success(adminPayMerchantRevenueUsageService.list(queryRequest));
    }

    @GetMapping("/{id}")
    @Operation(summary = "根据ID获取收益使用记录")
    @SaCheckPermission("admin:pay:merchant:revenue:usage:detail")
    public ResultBean<AdminPayMerchantRevenueUsageResp> getById(@Parameter(description = "ID") @PathVariable Long id) {
        return ResultBean.success(adminPayMerchantRevenueUsageService.getDetail(id));
    }

}