REQ-3540: 添加校验
This commit is contained in:
parent
e1ce9efde6
commit
f67f3e1e2c
@ -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;
|
||||
|
||||
@ -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) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user