package com.fjhx.mes.controller.technology;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.mes.entity.technology.dto.TechnologyDto;
import com.fjhx.mes.entity.technology.dto.TechnologySelectDto;
import com.fjhx.mes.entity.technology.vo.TechnologyVo;
import com.fjhx.mes.service.technology.TechnologyService;
import com.ruoyi.common.core.domain.BaseSelectDto;
import org.springframework.beans.factory.annotation.Autowired;
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;


/**
 * <p>
 * 工艺 前端控制器
 * </p>
 *
 * @author
 * @since 2023-03-28
 */
@RestController
@RequestMapping("/technology")
public class TechnologyController {

    @Autowired
    private TechnologyService technologyService;

    /**
     * 工艺分页
     */
    @PostMapping("/page")
    public Page<TechnologyVo> page(@RequestBody TechnologySelectDto dto) {
        return technologyService.getPage(dto);
    }

    /**
     * 工艺明细
     */
    @PostMapping("/detail")
    public TechnologyVo detail(@RequestBody BaseSelectDto dto) {
        return technologyService.detail(dto.getId());
    }

    /**
     * 工艺新增
     */
    @PostMapping("/add")
    public void add(@RequestBody TechnologyDto technologyDto) {
        technologyService.add(technologyDto);
    }

    /**
     * 工艺编辑
     */
    @PostMapping("/edit")
    public void edit(@RequestBody TechnologyDto technologyDto) {
        technologyService.edit(technologyDto);
    }

    /**
     * 工艺适用产品修改
     */
    @PostMapping("/editProduct")
    public void editProduct(@RequestBody TechnologyDto technologyDto) {
        technologyService.editProduct(technologyDto);
    }

    /**
     * 工艺删除
     */
    @PostMapping("/delete")
    public void delete(@RequestBody BaseSelectDto dto) {
        technologyService.delete(dto.getId());
    }

}
