package com.oms.controller; import com.oms.dto.SupplierSettlementDTO; import com.oms.entity.SupplierSettlement; import com.oms.service.SupplierSettlementService; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.oms.dto.PageResponse; import java.util.List; @RestController @RequestMapping("/finance/settlements") @RequiredArgsConstructor public class SupplierSettlementController { private final SupplierSettlementService supplierSettlementService; @GetMapping public PageResponse getSettlements( @RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "20") int size) { Page pageResult = supplierSettlementService.getPage(page, size); return PageResponse.of(pageResult.getRecords(), pageResult.getTotal(), (int) pageResult.getCurrent(), (int) pageResult.getSize()); } @GetMapping("/all") public List getAll() { return supplierSettlementService.getAll(); } @GetMapping("/{id}") public SupplierSettlementDTO getById(@PathVariable Long id) { return supplierSettlementService.getDtoById(id); } @GetMapping("/settlement-no/{settlementNo}") public SupplierSettlement getBySettlementNo(@PathVariable String settlementNo) { return supplierSettlementService.getBySettlementNo(settlementNo); } @PostMapping public Long create(@RequestBody SupplierSettlement settlement) { return supplierSettlementService.save(settlement); } @PutMapping("/{id}") public void update(@PathVariable Long id, @RequestBody SupplierSettlement settlement) { settlement.setId(id); supplierSettlementService.update(settlement); } @DeleteMapping("/{id}") public void delete(@PathVariable Long id) { supplierSettlementService.delete(id); } @PostMapping("/{id}/settle") public void settle(@PathVariable Long id) { supplierSettlementService.settle(id, "system"); } @PostMapping("/{id}/partial-settle") public void partialSettle(@PathVariable Long id, @RequestParam java.math.BigDecimal amount) { supplierSettlementService.partialSettle(id, amount, "system"); } @PostMapping("/generate") public Long generateSettlement(@RequestParam Long supplierId, @RequestParam String period) { return supplierSettlementService.generateSettlement(supplierId, period, null, null); } }