package com.fjhx.sale.controller.ext;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.sale.entity.ext.dto.ExtQuotationDto;
import com.fjhx.sale.entity.ext.dto.ExtQuotationSelectDto;
import com.fjhx.sale.entity.ext.vo.ExtQuotationVo;
import com.fjhx.sale.service.ext.ExtQuotationService;
import com.ruoyi.common.core.domain.BaseSelectDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * <p>
 * 对外报价单 前端控制器
 * </p>
 *
 * @author
 * @since 2024-01-14
 */
@RestController
@RequestMapping("/extQuotation")
public class ExtQuotationController {

    @Autowired
    private ExtQuotationService extQuotationService;

    /**
     * 对外报价单分页
     */
    @PostMapping("/page")
    public Page<ExtQuotationVo> page(@RequestBody ExtQuotationSelectDto dto) {
        return extQuotationService.getPage(dto);
    }

    /**
     * 对外报价单明细
     */
    @PostMapping("/detail")
    public ExtQuotationVo detail(@RequestBody BaseSelectDto dto) {
        return extQuotationService.detail(dto.getId());
    }

    /**
     * 对外报价单新增
     */
    @PostMapping("/add")
    public void add(@RequestBody ExtQuotationDto extQuotationDto) {
        extQuotationService.add(extQuotationDto);
    }

    /**
     * 对外报价单编辑
     */
    @PostMapping("/edit")
    public void edit(@RequestBody ExtQuotationDto extQuotationDto) {
        extQuotationService.edit(extQuotationDto);
    }

    /**
     * 对外报价单删除
     */
    @PostMapping("/delete")
    public void delete(@RequestBody BaseSelectDto dto) {
        extQuotationService.delete(dto.getId());
    }

    /**
     * 对外报价单变更
     */
    @PostMapping("/change")
    public void change(@RequestBody ExtQuotationDto dto) {
        extQuotationService.changeSaleQuotation(dto);
    }

    /**
     * 报价表作废
     */
    @PostMapping("/cancellation")
    public void cancellation(@RequestBody BaseSelectDto dto) {
        extQuotationService.cancellation(dto.getId());
    }

    /**
     * 获取报价单历史版本
     */
    @PostMapping("/getVersionList")
    List<ExtQuotationVo> getVersionList(@RequestBody ExtQuotationSelectDto dto) {
        return extQuotationService.getVersionList(dto.getId());
    }


}
