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

This commit is contained in:
zhou-hao
2018-04-26 21:10:06 +08:00
parent 40b96c0e66
commit b3ec879dd4

View File

@@ -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);