ContractPaymentController.java 1.27 KB
package vion.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import vion.dto.ContractPaymentDTO;
import vion.model.ContractPayment;
import vion.service.IContractPaymentService;
import vion.vo.ContractPaymentVO;

import java.util.List;

/**
 * 合同收款方式
 */
@RestController
@RequestMapping("/api")
@RequiredArgsConstructor
public class ContractPaymentController {

    private final IContractPaymentService contractPaymentService;
    private final Converter converter;

    @GetMapping("/contractPayment/{id}")
    @SaCheckPermission(value = "contractPayment:query", orRole = "admin")
    public List<ContractPaymentVO> getPaymentById(@PathVariable Long id) {
        return converter.convert(contractPaymentService.lambdaQuery().eq(ContractPayment::getContractId, id).list(), ContractPaymentVO.class);
    }

    @PostMapping("/contractPayment")
    @SaCheckPermission(value = "contractPayment:edit", orRole = "admin")
    public String updPayment(@RequestBody List<ContractPaymentDTO> dtoList) {
        return contractPaymentService.saveBatch(converter.convert(dtoList, ContractPayment.class)) ? "更新成功" : "更新失败";
    }

}