package com.seer.teach.pay.admin.financial.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.financial.controller.request.AdminPayFinancialReconciliationDetailPageReq;
import com.seer.teach.pay.admin.financial.controller.request.AdminPayFinancialReconciliationDetailQueryReq;
import com.seer.teach.pay.admin.financial.controller.request.AdminPayFinancialReconciliationDetailReq;
import com.seer.teach.pay.admin.financial.controller.response.AdminPayFinancialReconciliationDetailResp;
import com.seer.teach.pay.admin.financial.service.AdminPayFinancialReconciliationDetailService;
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-29
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/pay/financial-reconciliation-detail")
@Tag(name = "管理端 - 财务对账明细管理")
public class AdminPayFinancialReconciliationDetailController {

    private final AdminPayFinancialReconciliationDetailService adminPayFinancialReconciliationDetailService;

    @GetMapping("/paged")
    @Operation(summary = "分页查询财务对账明细")
    @SaCheckPermission("admin:pay:financial:reconciliation-detail:page")
    public ResultBean<PageListBean<AdminPayFinancialReconciliationDetailResp>> pageList(@Parameter(description = "分页查询参数") @Valid @RequestBody AdminPayFinancialReconciliationDetailPageReq pageRequest) {
        return ResultBean.success(adminPayFinancialReconciliationDetailService.pageList(pageRequest));
    }

    @GetMapping("/list")
    @Operation(summary = "获取财务对账明细列表")
    @SaCheckPermission("admin:pay:financial:reconciliation-detail:list")
    public ResultBean<List<AdminPayFinancialReconciliationDetailResp>> list(@Parameter(description = "查询参数") @Valid AdminPayFinancialReconciliationDetailQueryReq queryRequest) {
        return ResultBean.success(adminPayFinancialReconciliationDetailService.list(queryRequest));
    }

    @GetMapping("/{id}")
    @Operation(summary = "根据ID获取财务对账明细")
    @SaCheckPermission("admin:pay:financial:reconciliation-detail:detail")
    public ResultBean<AdminPayFinancialReconciliationDetailResp> getById(@Parameter(description = "ID") @PathVariable Long id) {
        return ResultBean.success(adminPayFinancialReconciliationDetailService.getDetail(id));
    }

    @PostMapping
    @Operation(summary = "新增财务对账明细")
    @SaCheckPermission("admin:pay:financial:reconciliation-detail:create")
    public ResultBean<Boolean> save(@Parameter(description = "新增参数") @Valid @RequestBody AdminPayFinancialReconciliationDetailReq requestParam) {
        return ResultBean.success(adminPayFinancialReconciliationDetailService.save(requestParam));
    }

    @PutMapping
    @Operation(summary = "更新财务对账明细")
    @SaCheckPermission("admin:pay:financial:reconciliation-detail:update")
    public ResultBean<Boolean> update(@Parameter(description = "更新参数") @Valid @RequestBody AdminPayFinancialReconciliationDetailReq requestParam) {
        return ResultBean.success(adminPayFinancialReconciliationDetailService.updateById(requestParam));
    }

    @DeleteMapping("/{id}")
    @Operation(summary = "删除财务对账明细")
    @SaCheckPermission("admin:pay:financial:reconciliation-detail:delete")
    public ResultBean<Boolean> delete(@Parameter(description = "ID") @PathVariable Long id) {
        return ResultBean.success(adminPayFinancialReconciliationDetailService.deleteById(id));
    }
}