package com.fjhx.sale.controller.purchase;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.purchase.entity.pay.vo.PayVo;
import com.fjhx.sale.entity.purchase.dto.EhsdPurchaseDto;
import com.fjhx.sale.entity.purchase.dto.EhsdPurchaseSelectDto;
import com.fjhx.sale.entity.purchase.po.EhsdPurchase;
import com.fjhx.sale.entity.purchase.vo.EhsdPurchaseVo;
import com.fjhx.sale.service.purchase.EhsdPurchaseService;
import com.ruoyi.common.core.domain.BaseSelectDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


/**
 * <p>
 * ehsd采购表 前端控制器
 * </p>
 *
 * @author 
 * @since 2023-05-17
 */
@RestController
@RequestMapping("/ehsdPurchase")
public class EhsdPurchaseController {

    @Autowired
    private EhsdPurchaseService ehsdPurchaseService;

    /**
     * ehsd采购表分页
     */
    @PostMapping("/page")
    public Page<EhsdPurchaseVo> page(@RequestBody EhsdPurchaseSelectDto dto) {
        return ehsdPurchaseService.getPage(dto);
    }

    /**
     * ehsd采购表明细
     */
    @PostMapping("/detail")
    public EhsdPurchaseVo detail(@RequestBody BaseSelectDto dto) {
        return ehsdPurchaseService.detail(dto.getId());
    }

    /**
     * ehsd采购表明细
     */
    @PostMapping("/payDetail")
    public PayVo payDetail(@RequestBody BaseSelectDto dto) {
        return ehsdPurchaseService.payDetail(dto.getId());
    }

    /**
     * ehsd采购表新增
     */
    @PostMapping("/add")
    public void add(@RequestBody EhsdPurchaseDto ehsdPurchaseDto) {
        ehsdPurchaseService.add(ehsdPurchaseDto);
    }


    /**
     * ehsd采购表删除
     */
    @PostMapping("/delete")
    public void delete(@RequestBody BaseSelectDto dto) {
        ehsdPurchaseService.delete(dto.getId());
    }

    /**
     * 根据供应商查询采购合同
     */
    @GetMapping("/getListBySupplyId")
    public List<EhsdPurchaseVo> getListBySupplyId(@RequestParam("supplyId") String supplyId) {
        return ehsdPurchaseService.getListBySupplyId(supplyId);
    }

    /**
     * 采购合同作废
     */
    @PostMapping("/cancellation")
    public void cancellation(@RequestBody BaseSelectDto dto) {
        ehsdPurchaseService.cancellation(dto.getId());
    }

    /**
     * 获取产品采购指导价
     *
     * @return
     */
    @PostMapping("/getProductPriceInfo")
    public Map<Long, Map<String, Object>> edit(@RequestBody EhsdPurchaseDto dto) {
        return ehsdPurchaseService.getProductPriceInfo(dto);
    }

    /**
     * 根据供应商查询无发票的采购合同
     */
    @GetMapping("/getNoInvoiceListBySupplyId")
    public List<EhsdPurchase> getNoInvoiceListBySupplyId(@RequestParam("supplyId") String supplyId) {
        return ehsdPurchaseService.getNoInvoiceListBySupplyId(supplyId);
    }

}
