createAttrUpdateCheckers容错

This commit is contained in:
lxy 2024-09-26 09:40:51 +08:00
parent 8afa88af4f
commit dffda4a346
2 changed files with 7 additions and 7 deletions

View File

@ -328,7 +328,7 @@ function createAttrUpdateCheckers(schema, attrUpdateMatrix) {
throw new types_1.OakAttrCantUpdateException(entity, extras, '更新了不允许的属性');
}
const condition = attrs.map(ele => matrix[ele]);
const actions = condition.map(ele => ele.actions).filter(ele => !!ele);
const actions = condition.map(ele => ele?.actions).filter(ele => !!ele);
const a = actions.length > 0 && (0, lodash_1.intersection)(actions.flat());
if (a) {
if (!a.includes(action)) {
@ -338,10 +338,10 @@ function createAttrUpdateCheckers(schema, attrUpdateMatrix) {
}
}
const filters = condition.map(ele => {
if (typeof ele.filter === 'function') {
if (typeof ele?.filter === 'function') {
return ele.filter(action || 'select');
}
return ele.filter;
return ele?.filter;
}).filter(ele => !!ele);
const f = filters.length > 0 && (0, filter_1.combineFilters)(entity, schema, filters);
if (f) {

View File

@ -326,7 +326,7 @@ function cascadelyCheckUpdateFilters<ED extends EntityDict & BaseEntityDict, T e
if (!f) {
return true;
}
// 此时看应用了success的attributes更新后能否消除掉f中的部分条件
const result = analyzeFilterRelation(entity, schema, successAttrFilter, f, true);
if (typeof result === 'boolean') {
@ -400,7 +400,7 @@ function createAttrUpdateCheckers<ED extends EntityDict & BaseEntityDict, Cxt ex
throw new OakAttrCantUpdateException(entity, extras, '更新了不允许的属性');
}
const condition = attrs.map(ele => matrix[ele]!);
const actions = condition.map(ele => ele.actions).filter(ele => !!ele);
const actions = condition.map(ele => ele?.actions).filter(ele => !!ele);
const a = actions.length > 0 && intersection(actions.flat());
if (a) {
if (!a.includes(action)) {
@ -412,10 +412,10 @@ function createAttrUpdateCheckers<ED extends EntityDict & BaseEntityDict, Cxt ex
}
}
const filters = condition.map(ele => {
if (typeof ele.filter === 'function') {
if (typeof ele?.filter === 'function') {
return ele.filter(action || 'select');
}
return ele.filter;
return ele?.filter;
}).filter(ele => !!ele);
const f = filters.length > 0 && combineFilters(entity, schema, filters);
if (f) {