浏览代码

后端调整

lipenghui 4 月之前
父节点
当前提交
8265c90d12

+ 15 - 4
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/IotInfoClassifyController.java

@@ -3,15 +3,13 @@ package cn.iocoder.yudao.module.pms.controller.admin;
 import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
-import cn.iocoder.yudao.module.pms.controller.admin.vo.IotInfoClassifyListReqVO;
-import cn.iocoder.yudao.module.pms.controller.admin.vo.IotInfoClassifyRespVO;
-import cn.iocoder.yudao.module.pms.controller.admin.vo.IotInfoClassifySaveReqVO;
-import cn.iocoder.yudao.module.pms.controller.admin.vo.IotInfoClassifySimpleRespVO;
+import cn.iocoder.yudao.module.pms.controller.admin.vo.*;
 import cn.iocoder.yudao.module.pms.dal.dataobject.IotInfoClassifyDO;
 import cn.iocoder.yudao.module.pms.service.IotInfoClassifyService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
 import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
@@ -30,6 +28,8 @@ public class IotInfoClassifyController {
 
     @Resource
     private IotInfoClassifyService IotInfoClassifyService;
+    @Autowired
+    private IotInfoClassifyService iotInfoClassifyService;
 
     @PostMapping("create")
     @Operation(summary = "创建资料分类")
@@ -47,6 +47,17 @@ public class IotInfoClassifyController {
         return success(true);
     }
 
+    @PutMapping("/update/remove")
+    @Operation(summary = "更新资料分类")
+    @PreAuthorize("@ss.hasPermission('rq:iot-classify:update')")
+    public CommonResult<Boolean> removeIotInfo(@Valid @RequestBody IotInfoClassifySaveReqVO updateReqVO) {
+        IotInfoClassifyDO classify = iotInfoClassifyService.getIotInfoClassify(updateReqVO.getId());
+        classify.setParentId(updateReqVO.getParentId());
+        BeanUtils.copyProperties(classify, updateReqVO);
+        iotInfoClassifyService.updateIotInfoClassify(updateReqVO);
+        return success(true);
+    }
+
     @DeleteMapping("delete")
     @Operation(summary = "删除资料分类")
     @Parameter(name = "id", description = "编号", required = true, example = "1024")

+ 0 - 8
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/IotInfoController.java

@@ -53,14 +53,6 @@ public class IotInfoController {
         return success(true);
     }
 
-    @PutMapping("/update/remove")
-    @Operation(summary = "更新资料")
-    @PreAuthorize("@ss.hasPermission('rq:iot-info:remove')")
-    public CommonResult<Boolean> removeIotInfo(@Valid @RequestBody IotInfoSaveReqVO updateReqVO) {
-        iotInfoService.updateIotInfo(updateReqVO);
-        return success(true);
-    }
-
     @DeleteMapping("/delete")
     @Operation(summary = "删除资料")
     @Parameter(name = "id", description = "编号", required = true)

+ 1 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/vo/IotInfoSaveReqVO.java

@@ -34,7 +34,7 @@ public class IotInfoSaveReqVO {
 
     @Schema(description = "文件路径", requiredMode = Schema.RequiredMode.REQUIRED)
     @NotEmpty(message = "文件路径不能为空")
-    private String[] filePath;
+    private String filePath;
 
     @Schema(description = "备注", example = "随便")
     private String remark;

+ 5 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/IotInfoClassifyServiceImpl.java

@@ -98,11 +98,16 @@ public class IotInfoClassifyServiceImpl implements IotInfoClassifyService {
         iotInfoClassifyMapper.updateById(updateObj);
         //更新pms树
         List<IotTreeDO> iotTreeDOS = iotTreeMapper.selectListByOriginId(updateObj.getId(), "file");
+        List<IotTreeDO> parentIotTreeDOS = iotTreeMapper.selectListByOriginId(updateObj.getParentId(), "file");
         if (org.apache.commons.collections4.CollectionUtils.isEmpty(iotTreeDOS)) {
             throw new ServiceException(ErrorCodeConstants.DEPT_NOT_FOUND.getCode(),"无该部门");
         }
+        if (org.apache.commons.collections4.CollectionUtils.isEmpty(parentIotTreeDOS)) {
+            throw new ServiceException(ErrorCodeConstants.DEPT_NOT_FOUND.getCode(),"无该节点");
+        }
         IotTreeDO iotTreeDO = iotTreeDOS.get(0);
         iotTreeDO.setName(updateObj.getName());
+        iotTreeDO.setParentId(parentIotTreeDOS.get(0).getId());
         iotTreeMapper.updateById(iotTreeDO);
     }
 

+ 3 - 2
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/IotInfoServiceImpl.java

@@ -47,10 +47,10 @@ public class IotInfoServiceImpl implements IotInfoService {
     @Override
     public void createIotInfo(IotInfoSaveReqVO createReqVO) {
         // 插入
-        if (CollUtil.isEmpty(Arrays.asList(createReqVO.getFilePath()))) {
+        if (StringUtils.isBlank(createReqVO.getFilePath())) {
             throw exception(IOT_INFO_NOT_EXISTS);
         }
-        List<IotInfoDO> collect = Arrays.stream(createReqVO.getFilePath()).map(path -> {
+        List<IotInfoDO> collect = Arrays.stream(createReqVO.getFilePath().split(",")).map(path -> {
             IotInfoDO iotInfo = BeanUtils.toBean(createReqVO, IotInfoDO.class);
             // todo iotInfo.setFilename(StringUtils.substringAfterLast(path, File.separator));
             iotInfo.setFilename(StringUtils.substringAfterLast(path, "/"));
@@ -68,6 +68,7 @@ public class IotInfoServiceImpl implements IotInfoService {
         validateIotInfoExists(updateReqVO.getId());
         // 更新
         IotInfoDO updateObj = BeanUtils.toBean(updateReqVO, IotInfoDO.class);
+        updateObj.setFilename(StringUtils.substringAfterLast(updateObj.getFilePath(), "/"));
         iotInfoMapper.updateById(updateObj);
     }