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.AdminPayOfflineTransferRecordPageReq;
import com.seer.teach.pay.admin.financial.controller.request.AdminPayOfflineTransferRecordQueryReq;
import com.seer.teach.pay.admin.financial.controller.request.AdminPayOfflineTransferRecordReq;
import com.seer.teach.pay.admin.financial.controller.response.AdminPayOfflineTransferRecordResp;
import com.seer.teach.pay.admin.financial.service.AdminPayOfflineTransferRecordService;
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/offline-transfer-record")
@Tag(name = "管理端 - 线下转账记录管理")
public class AdminPayOfflineTransferRecordController {

    private final AdminPayOfflineTransferRecordService adminPayOfflineTransferRecordService;

    @PostMapping("/paged")
    @Operation(summary = "分页查询线下转账记录")
    @SaCheckPermission("admin:pay:financial:offline-transfer-record:page")
    public ResultBean<PageListBean<AdminPayOfflineTransferRecordResp>> pageList(@Parameter(description = "分页查询参数") @Valid @RequestBody AdminPayOfflineTransferRecordPageReq pageRequest) {
        return ResultBean.success(adminPayOfflineTransferRecordService.pageList(pageRequest));
    }

    @PostMapping("/list")
    @Operation(summary = "获取线下转账记录列表")
    @SaCheckPermission("admin:pay:financial:offline-transfer-record:list")
    public ResultBean<List<AdminPayOfflineTransferRecordResp>> list(@Parameter(description = "查询参数") @Valid AdminPayOfflineTransferRecordQueryReq queryRequest) {
        return ResultBean.success(adminPayOfflineTransferRecordService.list(queryRequest));
    }

    @GetMapping("/{id}")
    @Operation(summary = "根据ID获取线下转账记录")
    @SaCheckPermission("admin:pay:financial:offline-transfer-record:detail")
    public ResultBean<AdminPayOfflineTransferRecordResp> getById(@Parameter(description = "ID") @PathVariable Long id) {
        return ResultBean.success(adminPayOfflineTransferRecordService.getDetail(id));
    }

    @PutMapping
    @Operation(summary = "更新线下转账记录")
    @SaCheckPermission("admin:pay:financial:offline-transfer-record:update")
    public ResultBean<Boolean> update(@Parameter(description = "更新参数") @Valid @RequestBody AdminPayOfflineTransferRecordReq requestParam) {
        return ResultBean.success(adminPayOfflineTransferRecordService.updateById(requestParam));
    }

    @DeleteMapping("/{id}")
    @Operation(summary = "删除线下转账记录")
    @SaCheckPermission("admin:pay:financial:offline-transfer-record:delete")
    public ResultBean<Boolean> delete(@Parameter(description = "ID") @PathVariable Long id) {
        return ResultBean.success(adminPayOfflineTransferRecordService.deleteById(id));
    }
}