package com.fjhx.purchase.controller.invoice;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.fjhx.common.constant.SourceConstant;
import com.fjhx.purchase.entity.invoice.po.Invoice;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.purchase.entity.invoice.vo.InvoiceVo;
import com.fjhx.purchase.entity.invoice.dto.InvoiceSelectDto;
import com.fjhx.purchase.entity.invoice.dto.InvoiceDto;
import com.ruoyi.common.core.domain.BaseSelectDto;
import com.fjhx.purchase.service.invoice.InvoiceService;
import org.springframework.beans.factory.annotation.Autowired;


/**
 * <p>
 * 发票管理 前端控制器
 * </p>
 *
 * @author 
 * @since 2023-04-12
 */
@DS(SourceConstant.PURCHASE)
@RestController
@RequestMapping("/invoice")
public class InvoiceController {

    @Autowired
    private InvoiceService invoiceService;

    /**
     * 发票管理分页
     */
    @PostMapping("/page")
    public Page<InvoiceVo> page(@RequestBody InvoiceSelectDto dto) {
        return invoiceService.getPage(dto);
    }

    /**
     * 发票管理明细
     */
    @PostMapping("/detail")
    public InvoiceVo detail(@RequestBody BaseSelectDto dto) {
        return invoiceService.detail(dto.getId());
    }

    /**
     * 发票管理新增
     */
    @PostMapping("/add")
    public void add(@RequestBody Invoice invoice) {
        invoiceService.add(invoice);
    }

    /**
     * 发票管理编辑
     */
    @PostMapping("/edit")
    public void edit(@RequestBody Invoice invoice) {
        invoiceService.edit(invoice);
    }

    /**
     * 发票管理删除
     */
    @PostMapping("/delete")
    public void delete(@RequestBody BaseSelectDto dto) {
        invoiceService.delete(dto.getId());
    }

}
