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.PayWithdrawalOperationLogPageReq;
import com.seer.teach.pay.admin.withdrawal.controller.request.PayWithdrawalOperationLogReq;
import com.seer.teach.pay.admin.withdrawal.controller.response.PayWithdrawalOperationLogResp;
import com.seer.teach.pay.admin.withdrawal.service.AdminPayWithdrawalOperationLogService;
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-17
 */
@RestController
@RequestMapping("/pay/withdrawal/log")
@Tag(name = "管理端 - 提现操作日志管理")
@RequiredArgsConstructor
public class AdminPayMerchantWithdrawalOperationLogController {

    private final AdminPayWithdrawalOperationLogService payWithdrawalOperationLogService;

    @PostMapping("/paged")
    @Operation(summary = "分页查询提现操作日志")
    @SaCheckPermission("admin:pay:withdrawal:operation-log:page")
    public ResultBean<PageListBean<PayWithdrawalOperationLogResp>> pageList(@Parameter(description = "分页查询参数") @Valid @RequestBody PayWithdrawalOperationLogPageReq queryParam) {
        return ResultBean.success(payWithdrawalOperationLogService.pageList(queryParam));
    }

    @PostMapping("/list")
    @Operation(summary = "获取提现操作日志列表")
    @SaCheckPermission("admin:pay:withdrawal:operation-log:list")
    public ResultBean<List<PayWithdrawalOperationLogResp>> list(@Parameter(description = "查询参数") @Valid PayWithdrawalOperationLogReq req) {
        return ResultBean.success(payWithdrawalOperationLogService.list(req));
    }

    @GetMapping("/{id}")
    @Operation(summary = "根据ID获取提现操作日志详情")
    @SaCheckPermission("admin:pay:withdrawal:operation-log:detail")
    public ResultBean<PayWithdrawalOperationLogResp> getById(@Parameter(description = "ID") @PathVariable Long id) {
        return ResultBean.success(payWithdrawalOperationLogService.getDetail(id));
    }

    @PostMapping
    @Operation(summary = "新增提现操作日志")
    @SaCheckPermission("admin:pay:withdrawal:operation-log:create")
    public ResultBean<Boolean> save(@Parameter(description = "新增参数") @Valid @RequestBody PayWithdrawalOperationLogReq payWithdrawalOperationLog) {
        return ResultBean.success(payWithdrawalOperationLogService.save(payWithdrawalOperationLog));
    }

    @PutMapping
    @Operation(summary = "更新提现操作日志")
    @SaCheckPermission("admin:pay:withdrawal:operation-log:update")
    public ResultBean<Boolean> update(@Parameter(description = "更新参数") @Valid @RequestBody PayWithdrawalOperationLogReq payWithdrawalOperationLog) {
        return ResultBean.success(payWithdrawalOperationLogService.updateById(payWithdrawalOperationLog));
    }

    @DeleteMapping("/{id}")
    @Operation(summary = "删除提现操作日志")
    @SaCheckPermission("admin:pay:withdrawal:operation-log:delete")
    public ResultBean<Boolean> delete(@Parameter(description = "ID") @PathVariable Long id) {
        return ResultBean.success(payWithdrawalOperationLogService.deleteById(id));
    }
}