|
@@ -88,7 +88,9 @@ public abstract class AbstractTreeSortService<E extends TreeSortSupportEntity<PK
|
|
|
|
|
|
protected void applyPath(E entity) {
|
|
|
if (StringUtils.isEmpty(entity.getParentId())) {
|
|
|
- entity.setSortIndex(0L);
|
|
|
+ if (entity.getSortIndex() == null) {
|
|
|
+ entity.setSortIndex(0L);
|
|
|
+ }
|
|
|
entity.setParentId(createParentIdOnExists());
|
|
|
entity.setLevel(0);
|
|
|
entity.setPath(RandomUtil.randomChar(4));
|
|
@@ -100,14 +102,16 @@ public abstract class AbstractTreeSortService<E extends TreeSortSupportEntity<PK
|
|
|
|
|
|
TreeSortSupportEntity<PK> parent = selectByPk(entity.getParentId());
|
|
|
if (null == parent) {
|
|
|
- if (entity.getSortIndex() == null)
|
|
|
+ if (entity.getSortIndex() == null) {
|
|
|
entity.setSortIndex(0L);
|
|
|
+ }
|
|
|
entity.setParentId(createParentIdOnExists());
|
|
|
entity.setPath(RandomUtil.randomChar(4));
|
|
|
entity.setLevel(0);
|
|
|
} else {
|
|
|
- if (entity.getSortIndex() == null && parent.getSortIndex() != null)
|
|
|
+ if (entity.getSortIndex() == null && parent.getSortIndex() != null) {
|
|
|
entity.setSortIndex(parent.getSortIndex() * 10);
|
|
|
+ }
|
|
|
entity.setPath(parent.getPath() + "-" + RandomUtil.randomChar(4));
|
|
|
entity.setLevel(entity.getPath().split("[-]").length);
|
|
|
}
|