package com.fjhx.sale.controller.purchase;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.purchase.entity.purchase.po.Purchase;
import com.fjhx.sale.entity.purchase.dto.EhsdPurchaseDto;
import com.fjhx.sale.entity.purchase.dto.EhsdPurchaseSelectDto;
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;


/**
 * <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("/add")
    public void add(@RequestBody EhsdPurchaseDto ehsdPurchaseDto) {
        ehsdPurchaseService.add(ehsdPurchaseDto);
    }

    /**
     * ehsd采购表编辑
     */
    @PostMapping("/edit")
    public void edit(@RequestBody EhsdPurchaseDto ehsdPurchaseDto) {
        ehsdPurchaseService.edit(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);
    }

}
