|
@@ -0,0 +1,97 @@
|
|
|
+package cn.iocoder.yudao.module.pms.controller.admin.maintain;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.maintain.vo.IotMaintainPageReqVO;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.maintain.vo.IotMaintainRespVO;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.maintain.vo.IotMaintainSaveReqVO;
|
|
|
+import cn.iocoder.yudao.module.pms.service.maintain.IotMaintainService;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import javax.annotation.Resource;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
+import io.swagger.v3.oas.annotations.Parameter;
|
|
|
+import io.swagger.v3.oas.annotations.Operation;
|
|
|
+
|
|
|
+import javax.validation.constraints.*;
|
|
|
+import javax.validation.*;
|
|
|
+import javax.servlet.http.*;
|
|
|
+import java.util.*;
|
|
|
+import java.io.IOException;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
+import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
|
|
+
|
|
|
+import cn.iocoder.yudao.module.rq.dal.dataobject.iotmaintain.IotMaintainDO;
|
|
|
+
|
|
|
+@Tag(name = "管理后台 - 维修工单")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/rq/iot-maintain")
|
|
|
+@Validated
|
|
|
+public class IotMaintainController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IotMaintainService iotMaintainService;
|
|
|
+
|
|
|
+ @PostMapping("/create")
|
|
|
+ @Operation(summary = "创建维修工单")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-maintain:create')")
|
|
|
+ public CommonResult<Long> createIotMaintain(@Valid @RequestBody IotMaintainSaveReqVO createReqVO) {
|
|
|
+ return success(iotMaintainService.createIotMaintain(createReqVO));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/update")
|
|
|
+ @Operation(summary = "更新维修工单")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-maintain:update')")
|
|
|
+ public CommonResult<Boolean> updateIotMaintain(@Valid @RequestBody IotMaintainSaveReqVO updateReqVO) {
|
|
|
+ iotMaintainService.updateIotMaintain(updateReqVO);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping("/delete")
|
|
|
+ @Operation(summary = "删除维修工单")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true)
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-maintain:delete')")
|
|
|
+ public CommonResult<Boolean> deleteIotMaintain(@RequestParam("id") Long id) {
|
|
|
+ iotMaintainService.deleteIotMaintain(id);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/get")
|
|
|
+ @Operation(summary = "获得维修工单")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-maintain:query')")
|
|
|
+ public CommonResult<IotMaintainRespVO> getIotMaintain(@RequestParam("id") Long id) {
|
|
|
+ IotMaintainDO iotMaintain = iotMaintainService.getIotMaintain(id);
|
|
|
+ return success(BeanUtils.toBean(iotMaintain, IotMaintainRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/page")
|
|
|
+ @Operation(summary = "获得维修工单分页")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-maintain:query')")
|
|
|
+ public CommonResult<PageResult<IotMaintainRespVO>> getIotMaintainPage(@Valid IotMaintainPageReqVO pageReqVO) {
|
|
|
+ PageResult<IotMaintainDO> pageResult = iotMaintainService.getIotMaintainPage(pageReqVO);
|
|
|
+ return success(BeanUtils.toBean(pageResult, IotMaintainRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/export-excel")
|
|
|
+ @Operation(summary = "导出维修工单 Excel")
|
|
|
+ @PreAuthorize("@ss.hasPermission('rq:iot-maintain:export')")
|
|
|
+ @ApiAccessLog(operateType = EXPORT)
|
|
|
+ public void exportIotMaintainExcel(@Valid IotMaintainPageReqVO pageReqVO,
|
|
|
+ HttpServletResponse response) throws IOException {
|
|
|
+ pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
+ List<IotMaintainDO> list = iotMaintainService.getIotMaintainPage(pageReqVO).getList();
|
|
|
+ // 导出 Excel
|
|
|
+ ExcelUtils.write(response, "维修工单.xls", "数据", IotMaintainRespVO.class,
|
|
|
+ BeanUtils.toBean(list, IotMaintainRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+}
|