package com.fs.app.controller.live;

import com.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.core.page.TableDataInfo;
import com.fs.common.enums.BusinessType;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.live.domain.LiveOrderPayment;
import com.fs.live.service.ILiveOrderPaymentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 支付明细Controller
 *
 * @author fs
 * @date 2025-08-07
 */
@RestController
@RequestMapping("/app/payment")
public class LiveOrderPaymentController extends BaseController
{
    @Autowired
    private ILiveOrderPaymentService liveOrderPaymentService;

    /**
     * 查询支付明细列表
     */
    @GetMapping("/list")
    public TableDataInfo list(LiveOrderPayment liveOrderPayment)
    {
        startPage();
        List<LiveOrderPayment> list = liveOrderPaymentService.selectLiveOrderPaymentList(liveOrderPayment);
        return getDataTable(list);
    }

    /**
     * 导出支付明细列表
     */
    @Log(title = "支付明细", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LiveOrderPayment liveOrderPayment)
    {
        List<LiveOrderPayment> list = liveOrderPaymentService.selectLiveOrderPaymentList(liveOrderPayment);
        ExcelUtil<LiveOrderPayment> util = new ExcelUtil<LiveOrderPayment>(LiveOrderPayment.class);
        return util.exportExcel(list, "支付明细数据");
    }

    /**
     * 获取支付明细详细信息
     */
    @GetMapping(value = "/{paymentId}")
    public AjaxResult getInfo(@PathVariable("paymentId") Long paymentId)
    {
        return AjaxResult.success(liveOrderPaymentService.selectLiveOrderPaymentByPaymentId(paymentId));
    }

    /**
     * 新增支付明细
     */
    @Log(title = "支付明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LiveOrderPayment liveOrderPayment)
    {
        return toAjax(liveOrderPaymentService.insertLiveOrderPayment(liveOrderPayment));
    }

    /**
     * 修改支付明细
     */
    @Log(title = "支付明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LiveOrderPayment liveOrderPayment)
    {
        return toAjax(liveOrderPaymentService.updateLiveOrderPayment(liveOrderPayment));
    }

    /**
     * 删除支付明细
     */
    @Log(title = "支付明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{paymentIds}")
    public AjaxResult remove(@PathVariable Long[] paymentIds)
    {
        return toAjax(liveOrderPaymentService.deleteLiveOrderPaymentByPaymentIds(paymentIds));
    }
}
