deduce时的一些逻辑调整
This commit is contained in:
parent
56fcf88ba1
commit
f4f3c7011e
|
|
@ -1376,10 +1376,10 @@ var RelationAuth = /** @class */ (function () {
|
|||
];
|
||||
if (this.authDeduceRelationMap[entity]) {
|
||||
(0, assert_1.default)(this.authDeduceRelationMap[entity] === 'entity');
|
||||
var _b = filter, deduceEntity = _b.entity, deduceEntityId = _b.entityId;
|
||||
var _b = filter, deduceEntity = _b.entity, deduceEntityId_1 = _b.entityId;
|
||||
var deduceFilter = {};
|
||||
if (deduceEntity && deduceEntityId) {
|
||||
deduceFilter = { id: deduceEntityId };
|
||||
if (deduceEntity && deduceEntityId_1) {
|
||||
deduceFilter = { id: deduceEntityId_1 };
|
||||
}
|
||||
else {
|
||||
// 也可能是用cascade方式进行查找,这里有时候filter上会带有两个不同的entity目标,尚未处理(todo!)
|
||||
|
|
@ -1436,18 +1436,21 @@ var RelationAuth = /** @class */ (function () {
|
|||
count: 10,
|
||||
}, { dontCollect: true });
|
||||
var dealWithData_1 = function (rows) {
|
||||
(0, assert_1.default)(rows.length > 0, "\u67E5\u8BE2\u65E0\u6CD5\u754C\u5B9A\u51FA\u76F8\u5E94\u7684deduce\u5BF9\u8C61".concat(entity, "\uFF0C\u67E5\u8BE2\u6761\u4EF6\u4E3A").concat(JSON.stringify(filter)));
|
||||
var eGroup = (0, lodash_1.groupBy)(rows, 'entity');
|
||||
// 这里如果entity指向不同的实体,一般出现这样的查询,则其权限应当不由这条deduce路径处理
|
||||
// 同上,如果找到的行数大于1行,说明deduce路径上的对象不确定,也暂不处理,等遇到了再说 by Xc 20230725
|
||||
if (Object.keys(eGroup).length > 1 || rows.length > 1) {
|
||||
if (rows.length > 1 || rows.length === 0) {
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
console.warn("\u8FDB\u884Cdeduce\u63A8\u5BFC\u65F6\u627E\u5230\u4E86".concat(rows.length, "\u884C").concat(entity, "\u6570\u636E"));
|
||||
}
|
||||
return entityFilters;
|
||||
}
|
||||
var entityIds = rows.map(function (ele) { return ele.entityId; });
|
||||
var result = getRecursiveDeducedFilters_1(entity, {
|
||||
id: entityIds.length === 1 ? entityIds[0] : {
|
||||
$in: entityIds,
|
||||
},
|
||||
var _a = rows[0], deducedEntity = _a.entity, deducedEntityId = _a.entityId;
|
||||
if (!deducedEntity || !deducedEntityId) {
|
||||
// 这种情况会出现在前台缓存里
|
||||
return entityFilters;
|
||||
}
|
||||
var result = getRecursiveDeducedFilters_1(deducedEntity, {
|
||||
id: deduceEntityId_1,
|
||||
});
|
||||
if (result instanceof Promise) {
|
||||
return result.then(function (r2) {
|
||||
|
|
|
|||
|
|
@ -1686,18 +1686,21 @@ export class RelationAuth<ED extends EntityDict & BaseEntityDict>{
|
|||
}, { dontCollect: true });
|
||||
|
||||
const dealWithData = (rows: Partial<ED[keyof ED]['OpSchema']>[]) => {
|
||||
assert(rows.length > 0, `查询无法界定出相应的deduce对象${entity as string},查询条件为${JSON.stringify(filter)}`);
|
||||
const eGroup = groupBy(rows, 'entity');
|
||||
// 这里如果entity指向不同的实体,一般出现这样的查询,则其权限应当不由这条deduce路径处理
|
||||
// 同上,如果找到的行数大于1行,说明deduce路径上的对象不确定,也暂不处理,等遇到了再说 by Xc 20230725
|
||||
if (Object.keys(eGroup).length > 1 || rows.length > 1) {
|
||||
if (rows.length > 1 || rows.length === 0) {
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
console.warn(`进行deduce推导时找到了${rows.length}行${entity as string}数据`);
|
||||
}
|
||||
return entityFilters;
|
||||
}
|
||||
const entityIds = rows.map(ele => ele.entityId);
|
||||
const result = getRecursiveDeducedFilters(entity, {
|
||||
id: entityIds.length === 1 ? entityIds[0] : {
|
||||
$in: entityIds,
|
||||
},
|
||||
const { entity: deducedEntity, entityId: deducedEntityId } = rows[0];
|
||||
if (!deducedEntity || !deducedEntityId) {
|
||||
// 这种情况会出现在前台缓存里
|
||||
return entityFilters;
|
||||
}
|
||||
const result = getRecursiveDeducedFilters(deducedEntity, {
|
||||
id: deduceEntityId,
|
||||
});
|
||||
|
||||
if (result instanceof Promise) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue