package com.fjhx.sale.controller.contract;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.sale.entity.contract.dto.ContractProductDto;
import com.fjhx.sale.entity.contract.dto.ContractProductSelectDto;
import com.fjhx.sale.entity.contract.vo.ContractProductVo;
import com.fjhx.sale.service.contract.ContractProductService;
import com.ruoyi.common.core.domain.BaseSelectDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * <p>
 * 外销合同-产品 前端控制器
 * </p>
 *
 * @author
 * @since 2023-04-17
 */
@RestController
@RequestMapping("/contractProduct")
public class ContractProductController {

    @Autowired
    private ContractProductService contractProductService;

    /**
     * 外销合同-产品分页
     */
    @PostMapping("/page")
    public Page<ContractProductVo> page(@RequestBody ContractProductSelectDto dto) {
        return contractProductService.getPage(dto);
    }

    /**
     * 采购交接单-产品分页
     */
    @PostMapping("/page1")
    public Page<ContractProductVo> page1(@RequestBody ContractProductSelectDto dto) {
        return contractProductService.getPage1(dto);
    }

    /**
     * 根据合同ID和客户ID查询未包装的产品
     */
    @GetMapping("/getNoPackContractProductById")
    public List<ContractProductVo> getNoPackContractProductById(@RequestParam("customerId") String customerId, @RequestParam("contractIds") String contractIds) {
        return contractProductService.getNoPackContractProductById(customerId, contractIds);
    }

    /**
     * 外销合同-产品ID集合查询产品
     */
    @PostMapping("/getListDetail")
    public List<ContractProductVo> getListDetail(@RequestBody List<Long> ids) {
        return contractProductService.getListDetail(ids);
    }

    /**
     * 外销合同-合同id集合查询产品
     */
    @PostMapping("/getListDetailByContractId")
    public List<ContractProductVo> getListDetailByContractId(@RequestBody List<Long> contractIds) {
        return contractProductService.getListDetailByContractId(contractIds);
    }

    /**
     * 外销合同-产品明细
     */
    @PostMapping("/detail")
    public ContractProductVo detail(@RequestBody BaseSelectDto dto) {
        return contractProductService.detail(dto.getId());
    }

    /**
     * 外销合同-产品新增
     */
    @PostMapping("/add")
    public void add(@RequestBody ContractProductDto contractProductDto) {
        contractProductService.add(contractProductDto);
    }

    /**
     * 外销合同-产品编辑
     */
    @PostMapping("/edit")
    public void edit(@RequestBody ContractProductDto contractProductDto) {
        contractProductService.edit(contractProductDto);
    }

    /**
     * 外销合同-产品删除
     */
    @PostMapping("/delete")
    public void delete(@RequestBody BaseSelectDto dto) {
        contractProductService.delete(dto.getId());
    }

}
