浏览代码

优化属性设置逻辑

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

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

@@ -65,6 +65,9 @@ public abstract class AbstractTreeSortService<E extends TreeSortSupportEntity<PK
 
 
     protected void applyPath(E entity) {
     protected void applyPath(E entity) {
         if (StringUtils.isEmpty(entity.getParentId())) {
         if (StringUtils.isEmpty(entity.getParentId())) {
+            entity.setSortIndex(0L);
+            entity.setParentId(createParentIdOnExists());
+            entity.setPath(RandomUtil.randomChar(4));
             return;
             return;
         }
         }
         if (!StringUtils.isEmpty(entity.getPath())) {
         if (!StringUtils.isEmpty(entity.getPath())) {