package com.ruoyi.web.modules.trading.controller;

import java.util.List;
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.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
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.web.modules.trading.domain.BizSupplierSettlement;
import com.ruoyi.web.modules.trading.service.IBizSupplierSettlementService;

/**
 * 供应商结算管理。
 */
@RestController
@RequestMapping("/tradeMarket/supplierSettlement")
public class BizSupplierSettlementController extends BaseController
{
    @Autowired
    private IBizSupplierSettlementService bizSupplierSettlementService;

    @PreAuthorize("@ss.hasPermi('tradeMarket:supplierSettlement:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizSupplierSettlement query)
    {
        startPage();
        List<BizSupplierSettlement> list = bizSupplierSettlementService.selectBizSupplierSettlementList(query);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('tradeMarket:supplierSettlement:query')")
    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bizSupplierSettlementService.selectBizSupplierSettlementById(id));
    }

    @PreAuthorize("@ss.hasPermi('tradeMarket:supplierSettlement:settle')")
    @Log(title = "供应商结算管理", businessType = BusinessType.UPDATE)
    @PutMapping("/completeSettle")
    public AjaxResult completeSettle(@RequestBody BizSupplierSettlement request)
    {
        BizSupplierSettlement result = bizSupplierSettlementService.completeSettle(request, getUsername());
        return success(result);
    }
}
