package com.fjhx.sale.controller.documents;

import com.fjhx.sale.entity.documents.po.DocumentsPdf;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.sale.entity.documents.vo.DocumentsVo;
import com.fjhx.sale.entity.documents.dto.DocumentsSelectDto;
import com.fjhx.sale.entity.documents.dto.DocumentsDto;
import com.ruoyi.common.core.domain.BaseSelectDto;
import com.fjhx.sale.service.documents.DocumentsService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Map;


/**
 * <p>
 * 单证表 前端控制器
 * </p>
 *
 * @author
 * @since 2023-04-20
 */
@RestController
@RequestMapping("/documents")
public class DocumentsController {

    @Autowired
    private DocumentsService documentsService;

    /**
     * 单证表分页
     */
    @PostMapping("/page")
    public Page<DocumentsVo> page(@RequestBody DocumentsSelectDto dto) {
        return documentsService.getPage(dto);
    }

    /**
     * 单证表明细
     */
    @PostMapping("/detail")
    public DocumentsVo detail(@RequestBody BaseSelectDto dto) {
        return documentsService.detail(dto.getId());
    }

    /**
     * 单证表新增
     */
    @PostMapping("/add")
    public void add(@RequestBody DocumentsDto documentsDto) {
        documentsService.add(documentsDto);
    }

    /**
     * 单证表删除
     */
    @PostMapping("/delete")
    public void delete(@RequestBody BaseSelectDto dto) {
        documentsService.delete(dto.getId());
    }

    /**
     * 生成pdf---商业发票、装箱单、代理委托书
     */
    @GetMapping("/generateInvoiceAPackPdf")
    public Map<String, Object> generateInvoicePdf(@RequestParam("id") Long id) {
        return documentsService.generateInvoiceAPackPdf(id);
    }

    /**
     * 生成pdf---报关单
     */
    @GetMapping("/generateClearanceePdf")
    public DocumentsPdf generateClearanceePdf(@RequestParam("id") Long id) {
        return documentsService.generateClearanceePdf(id);
    }

}
