PaymentController.java 1.45 KB
package vion.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.linpeilie.Converter;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import vion.dto.PaymentDTO;
import vion.service.IPaymentService;
import vion.vo.PaymentVO;

import java.util.List;

/**
* 收款记录管理
*/
@RestController
@RequestMapping("/api")
@RequiredArgsConstructor
public class PaymentController {

    private final IPaymentService paymentService;
    private final Converter converter;

    @GetMapping("/payment")
    @SaCheckPermission(value = "payment:list", orRole = "admin")
    public Page<PaymentVO> list(PaymentDTO dto) {
        return paymentService.list(dto);
    }

    @GetMapping("/payment/{id}")
    @SaCheckPermission(value = "payment:query", orRole = "admin")
    public PaymentVO getById(@PathVariable Long id) {
        return converter.convert(paymentService.getById(id), new PaymentVO());
    }

    @PostMapping("/payment")
    @SaCheckPermission(value = "payment:save", orRole = "admin")
    public String save(@RequestBody List<PaymentDTO> dto) {
        return paymentService.save(dto);
    }

    @DeleteMapping("/payment/{id}")
    @SaCheckPermission(value = "payment:remove", orRole = "admin")
    public String delById(@PathVariable Long id) {
        return paymentService.removeById(id) ? "删除成功" : "删除失败";
    }

}