package com.kexue.skills.controller;

import com.github.pagehelper.PageInfo;
import com.kexue.skills.annotation.RequireAuth;
import com.kexue.skills.common.CommonResult;
import com.kexue.skills.entity.PaymentOrder;
import com.kexue.skills.entity.dto.PaymentOrderDto;
import com.kexue.skills.service.PaymentOrderService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (PaymentOrder)表控制层
 * 支付订单管理控制器
 *
 * @author 王志维
 * @since 2025-02-21 23:01:48
 */
@Tag(name = "支付订单管理 Api")
@RestController
@RequestMapping("/api/paymentOrder")
public class PaymentOrderController {
    /**
     * 服务对象
     */
    @Resource
    private PaymentOrderService paymentOrderService;

    /**
     * 分页查询
     *
     * @param queryDto 查询参数
     * @return 分页结果
     */
    @Operation(summary = "分页查询支付订单", description = "分页查询支付订单")
    @PostMapping("/pageList")
    @RequireAuth
    public CommonResult<PageInfo<PaymentOrder>> getPageList(@RequestBody PaymentOrderDto queryDto) {
        return CommonResult.success(this.paymentOrderService.getPageList(queryDto));
    }

    /**
     * 查询列表
     *
     * @param queryDto 查询参数
     * @return 列表结果
     */
    @Operation(summary = "查询支付订单列表", description = "查询支付订单列表")
    @PostMapping("/list")
    @RequireAuth
    public CommonResult<List<PaymentOrder>> getList(@RequestBody PaymentOrderDto queryDto) {
        return CommonResult.success(this.paymentOrderService.getList(queryDto));
    }

    /**
     * 通过主键查询单条数据
     *
     * @param orderId 主键
     * @return 单条数据
     */
    @Operation(summary = "通过ID查询支付订单", description = "通过ID查询支付订单")
    @PostMapping("/queryById/{orderId}")
    @RequireAuth
    public CommonResult<PaymentOrder> queryById(@Parameter(description = "订单ID") @PathVariable("orderId") Long orderId) {
        return CommonResult.success(this.paymentOrderService.queryById(orderId));
    }

    /**
     * 通过订单号查询单条数据
     *
     * @param orderNo 订单号
     * @return 单条数据
     */
    @Operation(summary = "通过订单号查询支付订单", description = "通过订单号查询支付订单")
    @PostMapping("/queryByOrderNo")
    @RequireAuth
    public CommonResult<PaymentOrder> queryByOrderNo(@Parameter(description = "订单号") @RequestParam("orderNo") String orderNo) {
        return CommonResult.success(this.paymentOrderService.queryByOrderNo(orderNo));
    }
}