package com.fjhx.mes.controller.workshop;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.fjhx.common.constant.SourceConstant;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.mes.entity.workshop.vo.WorkshopVo;
import com.fjhx.mes.entity.workshop.dto.WorkshopSelectDto;
import com.fjhx.mes.entity.workshop.dto.WorkshopDto;
import com.ruoyi.common.core.domain.BaseSelectDto;
import com.fjhx.mes.service.workshop.WorkshopService;
import org.springframework.beans.factory.annotation.Autowired;


/**
 * <p>
 * 车间 前端控制器
 * </p>
 *
 * @author 
 * @since 2023-03-23
 */
//@DS(SourceConstant.MES)
@RestController
@RequestMapping("/workshop")
public class WorkshopController {

    @Autowired
    private WorkshopService workshopService;

    /**
     * 车间分页
     */
    @PostMapping("/page")
    public Page<WorkshopVo> page(@RequestBody WorkshopSelectDto dto) {
        return workshopService.getPage(dto);
    }

    /**
     * 车间明细
     */
    @PostMapping("/detail")
    public WorkshopVo detail(@RequestBody BaseSelectDto dto) {
        return workshopService.detail(dto.getId());
    }

    /**
     * 车间新增
     */
    @PostMapping("/add")
    public void add(@RequestBody WorkshopDto workshopDto) {
        workshopService.add(workshopDto);
    }

    /**
     * 车间编辑
     */
    @PostMapping("/edit")
    public void edit(@RequestBody WorkshopDto workshopDto) {
        workshopService.edit(workshopDto);
    }

    /**
     * 车间删除
     */
    @PostMapping("/delete")
    public void delete(@RequestBody BaseSelectDto dto) {
        workshopService.delete(dto.getId());
    }

}
