package com.ruoyi.web.bst;

import com.ruoyi.bst.pay.domain.PayQuery;
import com.ruoyi.bst.pay.domain.PayVO;
import com.ruoyi.bst.pay.service.PayService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 支付订单Controller
 *
 * @author ruoyi
 * @date 2025-03-26
 */
@RestController
@RequestMapping("/bst/pay")
public class PayController extends BaseController
{
    @Autowired
    private PayService payService;

    /**
     * 查询支付订单列表
     */
    @PreAuthorize("@ss.hasPermi('bst:pay:list')")
    @GetMapping("/list")
    public TableDataInfo list(PayQuery query)
    {
        startPage();
        startOrderBy();
        List<PayVO> list = payService.selectPayList(query);
        return getDataTable(list);
    }

    /**
     * 导出支付订单列表
     */
    @PreAuthorize("@ss.hasPermi('bst:pay:export')")
    @Log(title = "支付订单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PayQuery query)
    {
        List<PayVO> list = payService.selectPayList(query);
        ExcelUtil<PayVO> util = new ExcelUtil<PayVO>(PayVO.class);
        util.exportExcel(response, list, "支付订单数据");
    }

    /**
     * 获取支付订单详细信息
     */
    @PreAuthorize("@ss.hasPermi('bst:pay:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(payService.selectPayById(id));
    }
}
