浏览代码

修复新增树节点无法添加父节点path的问题导致不能级联删除

zhou-hao 7 年之前
父节点
当前提交
b3ec879dd4

+ 2 - 2
hsweb-commons/hsweb-commons-service/hsweb-commons-service-simple/src/main/java/org/hswebframework/web/service/AbstractTreeSortService.java

@@ -64,7 +64,7 @@ public abstract class AbstractTreeSortService<E extends TreeSortSupportEntity<PK
     }
 
     protected void applyPath(E entity) {
-        if (!StringUtils.isEmpty(entity.getParentId())) {
+        if (StringUtils.isEmpty(entity.getParentId())) {
             return;
         }
         if (!StringUtils.isEmpty(entity.getPath())) {
@@ -125,11 +125,11 @@ public abstract class AbstractTreeSortService<E extends TreeSortSupportEntity<PK
     public PK saveOrUpdateForSingle(E entity) {
         assertNotNull(entity);
         PK id = entity.getId();
-        applyPath(entity);
         if (null == id || this.selectByPk(id) == null) {
             if (null == id) {
                 entity.setId(getIDGenerator().generate());
             }
+            applyPath(entity);
             return super.insert(entity);
         }
         super.updateByPk(entity);