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.AdminPayMerchantRevenueDetailPageReq;
import com.seer.teach.pay.admin.withdrawal.controller.request.AdminPayMerchantRevenueDetailQueryReq;
import com.seer.teach.pay.admin.withdrawal.controller.request.AdminPayMerchantRevenueDetailReq;
import com.seer.teach.pay.admin.withdrawal.controller.response.AdminPayMerchantRevenueDetailResp;
import com.seer.teach.pay.admin.withdrawal.service.AdminPayMerchantRevenueDetailService;
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.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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

/**
 * 商户收益明细控制器
 *
 * @author ZS
 * @since 2025-09-25
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/pay/revenue")
@Tag(name = "商户端 - 商户收益明细管理")
public class AdminPayMerchantRevenueDetailController {

    private final AdminPayMerchantRevenueDetailService adminPayMerchantRevenueDetailService;

    @PostMapping("/paged")
    @Operation(summary = "分页查询商户收益明细")
    @SaCheckPermission("admin:pay:merchant:revenue:page")
    public ResultBean<PageListBean<AdminPayMerchantRevenueDetailResp>> pageList(@Parameter(description = "分页查询参数") @Valid @RequestBody AdminPayMerchantRevenueDetailPageReq pageRequest) {
        return ResultBean.success(adminPayMerchantRevenueDetailService.pageList(pageRequest));
    }

    @PostMapping("/list")
    @Operation(summary = "获取商户收益明细列表")
    @SaCheckPermission("admin:pay:merchant:revenue:list")
    public ResultBean<List<AdminPayMerchantRevenueDetailResp>> list(@Parameter(description = "查询参数") @Valid @RequestBody AdminPayMerchantRevenueDetailQueryReq queryRequest) {
        return ResultBean.success(adminPayMerchantRevenueDetailService.list(queryRequest));
    }

    @GetMapping("/{id}")
    @Operation(summary = "根据ID获取商户收益明细")
    @SaCheckPermission("admin:pay:merchant:revenue:detail")
    public ResultBean<AdminPayMerchantRevenueDetailResp> getById(@Parameter(description = "ID") @PathVariable Long id) {
        return ResultBean.success(adminPayMerchantRevenueDetailService.getDetail(id));
    }

}