diff --git a/lib/store/RelationAuth.js b/lib/store/RelationAuth.js index a0606b2..b953e8a 100644 --- a/lib/store/RelationAuth.js +++ b/lib/store/RelationAuth.js @@ -136,8 +136,8 @@ var RelationAuth = /** @class */ (function () { || !anchor.relativePath; } // relativePath如果是'', 所有的路径都成立 ); if (relatedAnchor) { - var entity_1 = relatedAnchor.entity, relativePath_1 = relatedAnchor.relativePath, filter_2 = relatedAnchor.filter; - var restPath = relativePath_1 === path[1] ? '' : relativePath_1 === '' ? path[1] : path[1].slice(relativePath_1.length + 1); + var entity_1 = relatedAnchor.entity, relativePath = relatedAnchor.relativePath, filter_2 = relatedAnchor.filter; + var restPath = relativePath === path[1] ? '' : relativePath === '' ? path[1] : path[1].slice(relativePath.length + 1); if (restPath === '') { // 处理一种特殊情况,如果根结点是create,则userRelation或者userId应该附着在创建的信息上 if (actions[0] === 'create' && actions.length === 1) { @@ -149,7 +149,7 @@ var RelationAuth = /** @class */ (function () { return relationId; }); return { - relativePath: '', + relativePath: path[1], relationIds: relationIds, path: path, }; @@ -158,7 +158,7 @@ var RelationAuth = /** @class */ (function () { else { if (filter_2.id === userId) { return { - relativePath: '', + relativePath: path[1], path: path, }; } @@ -166,7 +166,7 @@ var RelationAuth = /** @class */ (function () { } if (path[3]) { return { - relativePath: relativePath_1, + relativePath: path[1], path: path, filter: { entity: entity_1, @@ -177,7 +177,7 @@ var RelationAuth = /** @class */ (function () { if (userId === filter_2.id) { // 说明userId满足条件,直接返回relativePath return { - relativePath: '', + relativePath: path[1], path: path, }; } @@ -189,14 +189,14 @@ var RelationAuth = /** @class */ (function () { // 这里如果不是relation关系,则最后一项是指向user的外键名,否则最后一项就是最后一层的对象,有区别 if (idx === restPaths_1.length - 1 && !path[3]) { return { - relativePath: relativePath_1, + relativePath: path[1], path: path, filter: tslib_1.__assign((_a = {}, _a["".concat(restPaths_1[idx], "Id")] = userId, _a), filter2), }; } else if (idx === restPaths_1.length && path[3]) { return { - relativePath: relativePath_1, + relativePath: path[1], path: path, filter: { entity: entity2, diff --git a/src/store/RelationAuth.ts b/src/store/RelationAuth.ts index fe53eff..f61fedb 100644 --- a/src/store/RelationAuth.ts +++ b/src/store/RelationAuth.ts @@ -206,7 +206,7 @@ export class RelationAuth{ } ); return { - relativePath: '', + relativePath: path[1], relationIds, path, }; @@ -215,7 +215,7 @@ export class RelationAuth{ else { if (filter!.id === userId) { return { - relativePath: '', + relativePath: path[1], path, }; } @@ -223,7 +223,7 @@ export class RelationAuth{ } if (path[3]) { return { - relativePath, + relativePath: path[1], path, filter: { entity, @@ -234,7 +234,7 @@ export class RelationAuth{ if (userId === filter!.id) { // 说明userId满足条件,直接返回relativePath return { - relativePath: '', + relativePath: path[1], path, }; } @@ -250,7 +250,7 @@ export class RelationAuth{ // 这里如果不是relation关系,则最后一项是指向user的外键名,否则最后一项就是最后一层的对象,有区别 if (idx === restPaths.length - 1 && !path[3]) { return { - relativePath, + relativePath: path[1], path, filter: { [`${restPaths[idx]}Id`]: userId, @@ -260,7 +260,7 @@ export class RelationAuth{ } else if (idx === restPaths.length && path[3]) { return { - relativePath, + relativePath: path[1], path, filter: { entity: entity2, @@ -306,7 +306,7 @@ export class RelationAuth{ ).filter( ele => !!ele ) as { - relativePath: string; // (当前目标对象)与在anchor定位出来的对象的相对路径 + relativePath: string; // (当前目标对象)与将用于测试的cascadePath的destEntity的相对路径 path: AuthCascadePath; // 对象的AuthCascadePath filter?: ED[keyof ED]['Selection']['filter']; // 如果有relation,是对userRelation的查询条件,没有relation则是对path所标定的源对象的查询条件,两者都没有则说明查询条件上已经标定了源对象的userId了 relationIds?: string[]; // 如果有值表示userRelation是本动作所创建出来的,relationIds是相对应的relationIds