|
|
@@ -70,6 +70,9 @@ public class DefaultSaveHandler<T extends DefaultEntity> extends AbstractSaveHan |
|
|
|
if (field.isNotNull() && StringUtils.isEmpty(bean.getStr(field.getName()))) { |
|
|
|
throw new SwException(field.getTitle() + "不能为空!"); |
|
|
|
} |
|
|
|
if (field.getFieldType() == SwEnum.FieldType.PARENT_ID.value) { |
|
|
|
TreeHelper.getTreeHelper(tableName).checkParent(bean); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
EntityDao dao = DbEngine.getInstance().findDao(tableName); |
|
|
@@ -144,16 +147,17 @@ public class DefaultSaveHandler<T extends DefaultEntity> extends AbstractSaveHan |
|
|
|
} else { |
|
|
|
bean = loadComp(id); |
|
|
|
} |
|
|
|
TreeHelper.getTreeHelper(tableName).checkParent(bean); |
|
|
|
//不考虑没有级次码等情况,这个在表设计时校验 |
|
|
|
ModelField fieldParentCode = table.findFieldByType(SwEnum.FieldType.PARENT_ID.value); |
|
|
|
ModelField fieldParentId = table.findFieldByType(SwEnum.FieldType.PARENT_ID.value); |
|
|
|
|
|
|
|
bean.put(fieldParentCode.getName(), parentId); |
|
|
|
bean.put(fieldParentId.getName(), parentId); |
|
|
|
DbEngine.getInstance().doTrans(new AbsDbWorker() { |
|
|
|
@Override |
|
|
|
public void work() { |
|
|
|
EntityDao dao = DbEngine.getInstance().findDao(tableName); |
|
|
|
listTreeBean = TreeHelper.getTreeHelper(tableName).resetTreeLevel(bean); |
|
|
|
dao.updateEntity(bean, fieldParentCode.getName()); |
|
|
|
dao.updateEntity(bean, fieldParentId.getName()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|