package cn.iocoder.yudao.module.mes.controller.admin.pro.emergencyplan;
|
|
import cn.hutool.core.collection.CollUtil;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
import cn.iocoder.yudao.module.mes.controller.admin.pro.emergencyplan.vo.MesProEmergencyPlanPageReqVO;
|
import cn.iocoder.yudao.module.mes.controller.admin.pro.emergencyplan.vo.MesProEmergencyPlanRespVO;
|
import cn.iocoder.yudao.module.mes.controller.admin.pro.emergencyplan.vo.MesProEmergencyPlanSaveReqVO;
|
import cn.iocoder.yudao.module.mes.dal.dataobject.pro.emergencyplan.MesProEmergencyPlanDO;
|
import cn.iocoder.yudao.module.mes.service.pro.emergencyplan.MesProEmergencyPlanService;
|
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
import jakarta.annotation.Resource;
|
import jakarta.validation.Valid;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.validation.annotation.Validated;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.List;
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
@Tag(name = "管理后台 - MES 应急处置预案")
|
@RestController
|
@RequestMapping("/mes/pro/emergency-plan")
|
@Validated
|
public class MesProEmergencyPlanController {
|
|
@Resource
|
private MesProEmergencyPlanService planService;
|
|
@PostMapping("/create")
|
@Operation(summary = "创建应急处置预案")
|
@PreAuthorize("@ss.hasPermission('mes:pro-emergency-plan:create')")
|
public CommonResult<Long> createPlan(@Valid @RequestBody MesProEmergencyPlanSaveReqVO createReqVO) {
|
return success(planService.createPlan(createReqVO));
|
}
|
|
@PutMapping("/update")
|
@Operation(summary = "更新应急处置预案")
|
@PreAuthorize("@ss.hasPermission('mes:pro-emergency-plan:update')")
|
public CommonResult<Boolean> updatePlan(@Valid @RequestBody MesProEmergencyPlanSaveReqVO updateReqVO) {
|
planService.updatePlan(updateReqVO);
|
return success(true);
|
}
|
|
@DeleteMapping("/delete")
|
@Operation(summary = "删除应急处置预案")
|
@Parameter(name = "ids", description = "编号数组", required = true)
|
@PreAuthorize("@ss.hasPermission('mes:pro-emergency-plan:delete')")
|
public CommonResult<Boolean> deletePlan(@RequestParam("ids") List<Long> ids) {
|
planService.deletePlan(ids);
|
return success(true);
|
}
|
|
@GetMapping("/get")
|
@Operation(summary = "获得应急处置预案")
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
@PreAuthorize("@ss.hasPermission('mes:pro-emergency-plan:query')")
|
public CommonResult<MesProEmergencyPlanRespVO> getPlan(@RequestParam("id") Long id) {
|
MesProEmergencyPlanDO plan = planService.getPlan(id);
|
return success(plan != null ? BeanUtils.toBean(plan, MesProEmergencyPlanRespVO.class) : null);
|
}
|
|
@GetMapping("/page")
|
@Operation(summary = "获得应急处置预案分页")
|
@PreAuthorize("@ss.hasPermission('mes:pro-emergency-plan:query')")
|
public CommonResult<PageResult<MesProEmergencyPlanRespVO>> getPlanPage(@Valid MesProEmergencyPlanPageReqVO pageReqVO) {
|
PageResult<MesProEmergencyPlanDO> pageResult = planService.getPlanPage(pageReqVO);
|
if (CollUtil.isEmpty(pageResult.getList())) {
|
return success(PageResult.empty(pageResult.getTotal()));
|
}
|
return success(BeanUtils.toBean(pageResult, MesProEmergencyPlanRespVO.class));
|
}
|
|
@PutMapping("/publish")
|
@Operation(summary = "发布应急处置预案")
|
@Parameter(name = "id", description = "编号", required = true)
|
@PreAuthorize("@ss.hasPermission('mes:pro-emergency-plan:update')")
|
public CommonResult<Boolean> publishPlan(@RequestParam("id") Long id) {
|
planService.publishPlan(id);
|
return success(true);
|
}
|
|
}
|