package com.fjhx.mes.controller.bom;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.mes.entity.bom.dto.BomInfoDto;
import com.fjhx.mes.entity.bom.dto.BomInfoSelectDto;
import com.fjhx.mes.entity.bom.po.BomInfo;
import com.fjhx.mes.entity.bom.vo.BomInfoVo;
import com.fjhx.mes.service.bom.BomInfoService;
import com.ruoyi.common.core.domain.BaseSelectDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
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>
 * bom 前端控制器
 * </p>
 *
 * @author
 * @since 2023-03-29
 */
@RestController
@RequestMapping("/bomInfo")
public class BomInfoController {

    @Autowired
    private BomInfoService bomInfoService;

    /**
     * bom分页
     */
    @PostMapping("/page")
    public Page<BomInfoVo> page(@RequestBody BomInfoSelectDto dto) {
        return bomInfoService.getPage(dto);
    }

    /**
     * bom明细
     */
    @PostMapping("/detail")
    public BomInfoVo detail(@RequestBody BaseSelectDto dto) {
        return bomInfoService.detail(dto.getId());
    }

    /**
     * bom新增
     */
    @PostMapping("/add")
    public void add(@Validated @RequestBody BomInfoDto bomInfoDto) {
        bomInfoService.add(bomInfoDto);
    }

    /**
     * bom编辑
     */
    @PostMapping("/edit")
    public void edit(@RequestBody BomInfoDto bomInfoDto) {
        bomInfoService.edit(bomInfoDto);
    }

    /**
     * 获取bom版本
     */
    @PostMapping("/getVersion")
    public List<BomInfo> getVersion(@RequestBody BomInfo bomInfo) {
        return bomInfoService.getVersion(bomInfo.getProductId());
    }

    /**
     * 切换版本
     */
    @PostMapping("/editVersion")
    public void editVersion(@RequestBody BomInfo bomInfo) {
        bomInfoService.editVersion(bomInfo);
    }

    /**
     * bom新增 嘉兴双拓
     */
    @PostMapping("/addByJxst")
    public void addByJxst(@Validated @RequestBody BomInfoDto bomInfoDto) {
        bomInfoService.addByJxst(bomInfoDto);
    }

    /**
     * bom编辑 嘉兴双拓
     */
    @PostMapping("/editByJxst")
    public void editByJxst(@RequestBody BomInfoDto bomInfoDto) {
        bomInfoService.editByJxst(bomInfoDto);
    }

}
