package com.fjhx.mes.controller.work;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.fjhx.common.constant.SourceConstant;
import com.fjhx.mes.entity.work.po.WorkOrder;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.mes.entity.work.vo.WorkOrderVo;
import com.fjhx.mes.entity.work.dto.WorkOrderSelectDto;
import com.fjhx.mes.entity.work.dto.WorkOrderDto;
import com.ruoyi.common.core.domain.BaseSelectDto;
import com.fjhx.mes.service.work.WorkOrderService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;


/**
 * <p>
 * 工单 前端控制器
 * </p>
 *
 * @author
 * @since 2023-03-29
 */
@DS(SourceConstant.MES)
@RestController
@RequestMapping("/workOrder")
public class WorkOrderController {

    @Autowired
    private WorkOrderService workOrderService;

    /**
     * 工单分页
     */
    @PostMapping("/page")
    public Page<WorkOrderVo> page(@RequestBody WorkOrderSelectDto dto) {
        return workOrderService.getPage(dto);
    }

    /**
     * 工单明细
     */
    @PostMapping("/detail")
    public WorkOrderVo detail(@RequestBody BaseSelectDto dto) {
        return workOrderService.detail(dto.getId());
    }

    /**
     * 工单新增
     */
    @PostMapping("/add")
    public void add(@RequestBody WorkOrderDto workOrderDto) {
        workOrderService.add(workOrderDto);
    }

    /**
     * 工单批量新增
     */
    @PostMapping("/addBatch")
    public void addBatch(@RequestBody List<WorkOrder> workOrderDtoList) {
        workOrderService.addBatch(workOrderDtoList);
    }

    /**
     * 工单编辑
     */
    @PostMapping("/edit")
    public void edit(@RequestBody WorkOrderDto workOrderDto) {
        workOrderService.edit(workOrderDto);
    }

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

    /**
     * 工单分页 嘉新双拓
     */
    @PostMapping("/pageByJxst")
    public Page<WorkOrderVo> getPageByJxst(@RequestBody WorkOrderSelectDto dto) {
        return workOrderService.getPageByJxst(dto);
    }

}
