Browse Source

后端调整,添加更新判断

lipenghui 4 months ago
parent
commit
35a6ad0457

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

@@ -43,7 +43,7 @@ public class IotInfoClassifyController {
     @Operation(summary = "更新资料分类")
     @PreAuthorize("@ss.hasPermission('iot:info-classify:update')")
     public CommonResult<Boolean> updateIotInfoClassify(@Valid @RequestBody IotInfoClassifySaveReqVO updateReqVO) {
-        IotInfoClassifyService.updateIotInfoClassify(updateReqVO);
+        IotInfoClassifyService.updateIotInfoClassify(updateReqVO,"update");
         return success(true);
     }
 
@@ -54,7 +54,7 @@ public class IotInfoClassifyController {
         IotInfoClassifyDO classify = iotInfoClassifyService.getIotInfoClassify(updateReqVO.getId());
         classify.setParentId(updateReqVO.getParentId());
         BeanUtils.copyProperties(classify, updateReqVO);
-        iotInfoClassifyService.updateIotInfoClassify(updateReqVO);
+        iotInfoClassifyService.updateIotInfoClassify(updateReqVO, "remove");
         return success(true);
     }
 

+ 1 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/IotInfoClassifyService.java

@@ -28,7 +28,7 @@ public interface IotInfoClassifyService {
      *
      * @param updateReqVO 产品分类信息
      */
-    void updateIotInfoClassify(IotInfoClassifySaveReqVO updateReqVO);
+    void updateIotInfoClassify(IotInfoClassifySaveReqVO updateReqVO, String type);
 
     /**
      * 删除产品分类

+ 10 - 7
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/IotInfoClassifyServiceImpl.java

@@ -83,7 +83,7 @@ public class IotInfoClassifyServiceImpl implements IotInfoClassifyService {
     @CacheEvict(cacheNames = RedisKeyConstants.IOT_INFO_CHILDREN_ID_LIST,
             allEntries = true)
     @Transactional(rollbackFor = Exception.class)
-    public void updateIotInfoClassify(IotInfoClassifySaveReqVO updateReqVO) {
+    public void updateIotInfoClassify(IotInfoClassifySaveReqVO updateReqVO, String type) {
         if (updateReqVO.getParentId() == null) {
             updateReqVO.setParentId(IotInfoClassifyDO.PARENT_ID_ROOT);
         }
@@ -99,16 +99,19 @@ 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)) {
+        if (CollUtil.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());
+        List<IotTreeDO> parentIotTreeDOS = iotTreeMapper.selectListByOriginId(updateObj.getParentId(), "file");
+        if ("remove".equals(type)) {
+            if (CollUtil.isEmpty(parentIotTreeDOS)) {
+                throw new ServiceException(ErrorCodeConstants.DEPT_NOT_FOUND.getCode(),"无该节点");
+            } else {
+                iotTreeDO.setParentId(parentIotTreeDOS.get(0).getId());
+            }
+        }
         iotTreeDO.setDeptId(updateObj.getDeptId());
         iotTreeMapper.updateById(iotTreeDO);
     }

+ 1 - 0
yudao-server/src/main/resources/application-dev.yaml

@@ -73,6 +73,7 @@ spring:
     host: localhost # 地址
     port: 6379 # 端口
     database: 0  # 数据库索引
+    password: 123456
 
 --- #################### 定时任务相关配置 ####################