package com.yh.saas.plugin.yiliangyiyun.controller;


import com.baomidou.mybatisplus.plugins.Page;
import com.yh.saas.plugin.yiliangyiyun.entity.ProcurementPlanInfo;
import com.yh.saas.plugin.yiliangyiyun.entity.view.ReleaseView;
import com.yh.saas.plugin.yiliangyiyun.service.IProcurementPlanInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 记录采购计划 前端控制器
 * </p>
 *
 * @author Gongdc
 * @since 2021-07-20
 */
@RestController
@RequestMapping("/procurementPlanInfo")
public class ProcurementPlanInfoController {

    @Autowired
    private IProcurementPlanInfoService procurementPlanInfoService;

    /**
     * 查看采购计划
     *
     * @param id
     * @return
     */
    @GetMapping("/getProcurementPlan")
    public ProcurementPlanInfo getProcurementPlan(String id) {
        return procurementPlanInfoService.getProcurementPlan(id);
    }

    /**
     * 编辑采购计划
     *
     * @param procurementPlanInfo
     * @return
     */
    @PostMapping("/api/editProcurementPlan")
    public String editProcurementPlan(@RequestBody ProcurementPlanInfo procurementPlanInfo) {
        return procurementPlanInfoService.editProcurementPlan(procurementPlanInfo);
    }

    /**
     * 删除采购计划
     *
     * @param procurementPlanInfo
     * @return
     */
    @PostMapping("/api/deleteProcurementPlan")
    public void deleteProcurementPlan(@RequestBody ProcurementPlanInfo procurementPlanInfo) {
        procurementPlanInfoService.deleteProcurementPlan(procurementPlanInfo.getId());
    }

    /**
     * 采购计划列表
     *
     * @param procurementPlanInfo
     * @return
     */
    @GetMapping("/selectProcurementPlanInfo")
    public Page<ProcurementPlanInfo> selectProcurementPlanInfo(ProcurementPlanInfo procurementPlanInfo) {
        return procurementPlanInfoService.selectProcurementPlanInfo(procurementPlanInfo);
    }

    /**
     * 添加采购计划
     *
     * @param procurementPlanInfo
     * @return
     */
    @PostMapping("/api/insertProcurementPlanInfo")
    public String insertProcurementPlanInfo(@RequestBody ProcurementPlanInfo procurementPlanInfo) {
        return procurementPlanInfoService.insertProcurementPlanInfo(procurementPlanInfo);
    }

    /**
     * 更改状态/基差/单价
     *
     * @param procurementPlanInfo
     * @return
     */
    @PostMapping("/api/editStatus")
    public String editStatus(@RequestBody ProcurementPlanInfo procurementPlanInfo) {
        return procurementPlanInfoService.editStatus(procurementPlanInfo);

    }

    /**
     * 审核
     *
     * @param procurementPlanInfo
     * @return
     */
    @PostMapping("/api/examine")
    public String examine(@RequestBody ProcurementPlanInfo procurementPlanInfo) {
        return procurementPlanInfoService.examine(procurementPlanInfo);
    }

    /**
     * APP我的发布列表
     *
     * @param procurementPlanInfo
     * @return
     */
    @GetMapping("/selectProcurementPlanInfoAPP")
    public Page<ReleaseView> selectProcurementPlanInfoAPP(ProcurementPlanInfo procurementPlanInfo) {
        return procurementPlanInfoService.selectProcurementPlanInfoAPP(procurementPlanInfo);
    }

}

