package com.ruoyi.web.bst;

import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.bst.creditPay.domain.CreditPayQuery;
import com.ruoyi.bst.creditPay.domain.CreditPayVO;
import com.ruoyi.bst.creditPay.service.CreditPayService;
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;

/**
 * 挂账支付Controller
 *
 * @author ruoyi
 * @date 2025-05-28
 */
@RestController
@RequestMapping("/bst/creditPay")
public class CreditPayController extends BaseController
{
    @Autowired
    private CreditPayService creditPayService;

    /**
     * 查询挂账支付列表
     */
    @PreAuthorize("@ss.hasPermi('bst:creditPay:list')")
    @GetMapping("/list")
    public TableDataInfo list(CreditPayQuery query)
    {
        startPage();
        startOrderBy();
        List<CreditPayVO> list = creditPayService.selectCreditPayList(query);
        return getDataTable(list);
    }

    /**
     * 导出挂账支付列表
     */
    @PreAuthorize("@ss.hasPermi('bst:creditPay:export')")
    @Log(title = "挂账支付", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CreditPayQuery query)
    {
        List<CreditPayVO> list = creditPayService.selectCreditPayList(query);
        ExcelUtil<CreditPayVO> util = new ExcelUtil<CreditPayVO>(CreditPayVO.class);
        util.exportExcel(response, list, "挂账支付数据");
    }

    /**
     * 获取挂账支付详细信息
     */
    @PreAuthorize("@ss.hasPermi('bst:creditPay:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(creditPayService.selectCreditPayById(id));
    }

}
