getUserIdsByActions的逻辑修正
This commit is contained in:
parent
9765b2e67e
commit
a6e7b4d082
|
|
@ -103,13 +103,13 @@ export declare class RelationAuth<ED extends EntityDict & BaseEntityDict> {
|
||||||
private checkActions2;
|
private checkActions2;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 获取有对entity进行actions操作权限的用户Id(不包含root)
|
* 获取有对entity进行actions操作权限的userRelation关系
|
||||||
* @param params
|
* @param params
|
||||||
* @param context
|
* @param context
|
||||||
*/
|
*/
|
||||||
export declare function getUserIdsByActions<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED>>(params: {
|
export declare function getUserRelationsByActions<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED>>(params: {
|
||||||
entity: T;
|
entity: T;
|
||||||
entityId: string;
|
entityId: string;
|
||||||
actions: ED[T]['Action'][];
|
actions: ED[T]['Action'][];
|
||||||
overlap?: boolean;
|
overlap?: boolean;
|
||||||
}, context: Cxt): Promise<string[]>;
|
}, context: Cxt): Promise<import("../base-app-domain/UserRelation/Schema").Schema[][]>;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.getUserIdsByActions = exports.RelationAuth = void 0;
|
exports.getUserRelationsByActions = exports.RelationAuth = void 0;
|
||||||
var tslib_1 = require("tslib");
|
var tslib_1 = require("tslib");
|
||||||
var assert_1 = tslib_1.__importDefault(require("assert"));
|
var assert_1 = tslib_1.__importDefault(require("assert"));
|
||||||
var types_1 = require("../types");
|
var types_1 = require("../types");
|
||||||
|
|
@ -2061,11 +2061,11 @@ var RelationAuth = /** @class */ (function () {
|
||||||
exports.RelationAuth = RelationAuth;
|
exports.RelationAuth = RelationAuth;
|
||||||
;
|
;
|
||||||
/**
|
/**
|
||||||
* 获取有对entity进行actions操作权限的用户Id(不包含root)
|
* 获取有对entity进行actions操作权限的userRelation关系
|
||||||
* @param params
|
* @param params
|
||||||
* @param context
|
* @param context
|
||||||
*/
|
*/
|
||||||
function getUserIdsByActions(params, context) {
|
function getUserRelationsByActions(params, context) {
|
||||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||||
var entity, entityId, actions, overlap, filter, actionAuths, userRelations;
|
var entity, entityId, actions, overlap, filter, actionAuths, userRelations;
|
||||||
return tslib_1.__generator(this, function (_a) {
|
return tslib_1.__generator(this, function (_a) {
|
||||||
|
|
@ -2099,6 +2099,14 @@ function getUserIdsByActions(params, context) {
|
||||||
data: {
|
data: {
|
||||||
id: 1,
|
id: 1,
|
||||||
userId: 1,
|
userId: 1,
|
||||||
|
relationId: 1,
|
||||||
|
relation: {
|
||||||
|
id: 1,
|
||||||
|
name: 1,
|
||||||
|
display: 1,
|
||||||
|
},
|
||||||
|
entity: 1,
|
||||||
|
entityId: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -2108,9 +2116,9 @@ function getUserIdsByActions(params, context) {
|
||||||
case 1:
|
case 1:
|
||||||
actionAuths = _a.sent();
|
actionAuths = _a.sent();
|
||||||
userRelations = actionAuths.map(function (ele) { return ele.relation.userRelation$relation; });
|
userRelations = actionAuths.map(function (ele) { return ele.relation.userRelation$relation; });
|
||||||
return [2 /*return*/, (0, lodash_1.uniq)(Array.prototype.concat.apply([], userRelations).map(function (ele) { return ele.userId; }))];
|
return [2 /*return*/, userRelations];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.getUserIdsByActions = getUserIdsByActions;
|
exports.getUserRelationsByActions = getUserRelationsByActions;
|
||||||
|
|
|
||||||
|
|
@ -2496,11 +2496,11 @@ export class RelationAuth<ED extends EntityDict & BaseEntityDict>{
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取有对entity进行actions操作权限的用户Id(不包含root)
|
* 获取有对entity进行actions操作权限的userRelation关系
|
||||||
* @param params
|
* @param params
|
||||||
* @param context
|
* @param context
|
||||||
*/
|
*/
|
||||||
export async function getUserIdsByActions<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED>>(params: {
|
export async function getUserRelationsByActions<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED>>(params: {
|
||||||
entity: T;
|
entity: T;
|
||||||
entityId: string;
|
entityId: string;
|
||||||
actions: ED[T]['Action'][];
|
actions: ED[T]['Action'][];
|
||||||
|
|
@ -2534,6 +2534,14 @@ export class RelationAuth<ED extends EntityDict & BaseEntityDict>{
|
||||||
data: {
|
data: {
|
||||||
id: 1,
|
id: 1,
|
||||||
userId: 1,
|
userId: 1,
|
||||||
|
relationId: 1,
|
||||||
|
relation: {
|
||||||
|
id: 1,
|
||||||
|
name: 1,
|
||||||
|
display: 1,
|
||||||
|
},
|
||||||
|
entity: 1,
|
||||||
|
entityId: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -2542,5 +2550,5 @@ export class RelationAuth<ED extends EntityDict & BaseEntityDict>{
|
||||||
}, { dontCollect: true });
|
}, { dontCollect: true });
|
||||||
|
|
||||||
const userRelations = actionAuths.map(ele => ele.relation!.userRelation$relation!);
|
const userRelations = actionAuths.map(ele => ele.relation!.userRelation$relation!);
|
||||||
return uniq(Array.prototype.concat.apply([], userRelations).map(ele => ele.userId)) as string[];
|
return userRelations;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue