REQ-3540: 添加校验

This commit is contained in:
yanglin 2025-03-19 19:33:18 +08:00
parent e1ce9efde6
commit f67f3e1e2c
2 changed files with 14 additions and 2 deletions

View File

@ -2,6 +2,7 @@
package cn.axzo.nanopart.doc.api.domain;
import cn.axzo.nanopart.doc.api.enums.DatabaseScope;
import cn.axzo.nanopart.doc.api.enums.DatabaseType;
import cn.axzo.nanopart.doc.api.enums.IndexNodeContext;
/**
@ -30,6 +31,16 @@ public interface IndexNodeScope {
}
}
default boolean isLimitChildrenCount() {
switch (context()) {
case FILE_TEMPLATE:
case TEMPLATE_DATABASE:
return true;
default:
return scope().getDatabaseType() != DatabaseType.NONE;
}
}
IndexNodeScope FILE_TEMPLATE = () -> IndexNodeContext.FILE_TEMPLATE;
IndexNodeScope TEMPLATE_DATABASE = () -> IndexNodeContext.TEMPLATE_DATABASE;

View File

@ -92,8 +92,9 @@ class IndexSupport {
BizAssertions.assertTrue(
indexNodeDao.validChildrenCount(parent.getCode()) < docProps.getIndexNodeMaxChildrenSize(),
"创建失败, 子节点数量不能超过 {}", docProps.getIndexNodeMaxChildrenSize());
BizAssertions.assertTrue(parent.path().depth() < docProps.getIndexNodeMaxDepth(), //
"节点深度超过限制{}, 无法再创建新节点", docProps.getIndexNodeMaxDepth());
if (parent.isLimitChildrenCount())
BizAssertions.assertTrue(parent.path().depth() < docProps.getIndexNodeMaxDepth(), //
"节点深度超过限制{}, 无法再创建新节点", docProps.getIndexNodeMaxDepth());
}
void incrNameIfDuplicate(IndexNode rename) {