InvoiceController.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.InvoiceDTO;
import vion.service.IInvoiceService;
import vion.vo.InvoiceVO;

import java.util.List;

/**
* 发票记录管理
*/
@RestController
@RequestMapping("/api")
@RequiredArgsConstructor
public class InvoiceController {

    private final IInvoiceService invoiceService;
    private final Converter converter;

    @GetMapping("/invoice")
    @SaCheckPermission(value = "invoice:list", orRole = "admin")
    public Page<InvoiceVO> list(InvoiceDTO dto) {
        return invoiceService.list(dto);
    }

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

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

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

}