package com.fjhx.purchase.controller.invoice;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.fjhx.common.constant.SourceConstant;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.purchase.entity.invoice.vo.InvoiceDetailsVo;
import com.fjhx.purchase.entity.invoice.dto.InvoiceDetailsSelectDto;
import com.fjhx.purchase.entity.invoice.dto.InvoiceDetailsDto;
import com.ruoyi.common.core.domain.BaseSelectDto;
import com.fjhx.purchase.service.invoice.InvoiceDetailsService;
import org.springframework.beans.factory.annotation.Autowired;


/**
 * <p>
 * 发票明细 前端控制器
 * </p>
 *
 * @author 
 * @since 2023-04-12
 */
//@DS(SourceConstant.PURCHASE)
@RestController
@RequestMapping("/invoiceDetails")
public class InvoiceDetailsController {

    @Autowired
    private InvoiceDetailsService invoiceDetailsService;

    /**
     * 发票明细分页
     */
    @PostMapping("/page")
    public Page<InvoiceDetailsVo> page(@RequestBody InvoiceDetailsSelectDto dto) {
        return invoiceDetailsService.getPage(dto);
    }

    /**
     * 发票明细明细
     */
    @PostMapping("/detail")
    public InvoiceDetailsVo detail(@RequestBody BaseSelectDto dto) {
        return invoiceDetailsService.detail(dto.getId());
    }

    /**
     * 发票明细新增
     */
    @PostMapping("/add")
    public void add(@RequestBody InvoiceDetailsDto invoiceDetailsDto) {
        invoiceDetailsService.add(invoiceDetailsDto);
    }

    /**
     * 发票明细编辑
     */
    @PostMapping("/edit")
    public void edit(@RequestBody InvoiceDetailsDto invoiceDetailsDto) {
        invoiceDetailsService.edit(invoiceDetailsDto);
    }

    /**
     * 发票明细删除
     */
    @PostMapping("/delete")
    public void delete(@RequestBody BaseSelectDto dto) {
        invoiceDetailsService.delete(dto.getId());
    }

}
