user中增加了getUserIdsByActionAuth方法
This commit is contained in:
parent
379b443942
commit
a3352df67e
|
|
@ -5,3 +5,14 @@ export declare function mergeUser<ED extends EntityDict & BaseEntityDict, Cxt ex
|
|||
from: string;
|
||||
to: string;
|
||||
}, context: Cxt, innerLogic?: boolean): Promise<void>;
|
||||
/**
|
||||
* 获取有对entity进行actions操作权限的用户Id(不包含root)
|
||||
* @param params
|
||||
* @param context
|
||||
*/
|
||||
export declare function getUserIdsByActionAuth<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends BackendRuntimeContext<ED>>(params: {
|
||||
entity: T;
|
||||
entityId: string;
|
||||
actions: ED[T]['Action'][];
|
||||
overlap?: boolean;
|
||||
}, context: Cxt): Promise<string[]>;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.mergeUser = void 0;
|
||||
exports.getUserIdsByActionAuth = exports.mergeUser = void 0;
|
||||
var tslib_1 = require("tslib");
|
||||
var types_1 = require("oak-domain/lib/types");
|
||||
var uuid_1 = require("oak-domain/lib/utils/uuid");
|
||||
var lodash_1 = require("oak-domain/lib/utils/lodash");
|
||||
var assert_1 = tslib_1.__importDefault(require("assert"));
|
||||
function mergeUser(params, context, innerLogic) {
|
||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||
|
|
@ -139,3 +140,61 @@ function mergeUser(params, context, innerLogic) {
|
|||
});
|
||||
}
|
||||
exports.mergeUser = mergeUser;
|
||||
/**
|
||||
* 获取有对entity进行actions操作权限的用户Id(不包含root)
|
||||
* @param params
|
||||
* @param context
|
||||
*/
|
||||
function getUserIdsByActionAuth(params, context) {
|
||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||
var entity, entityId, actions, overlap, filter, actionAuths, userRelations;
|
||||
return tslib_1.__generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
entity = params.entity, entityId = params.entityId, actions = params.actions, overlap = params.overlap;
|
||||
filter = {
|
||||
destEntity: entity,
|
||||
relation: {
|
||||
entity: entity,
|
||||
entityId: entityId,
|
||||
},
|
||||
};
|
||||
if (overlap) {
|
||||
Object.assign(filter, {
|
||||
deActions: {
|
||||
$overlaps: actions,
|
||||
},
|
||||
});
|
||||
}
|
||||
else {
|
||||
Object.assign(filter, {
|
||||
deActions: {
|
||||
$contains: actions,
|
||||
},
|
||||
});
|
||||
}
|
||||
return [4 /*yield*/, context.select('actionAuth', {
|
||||
data: {
|
||||
id: 1,
|
||||
relation: {
|
||||
id: 1,
|
||||
userRelation$relation: {
|
||||
$entity: 'userRelation',
|
||||
data: {
|
||||
id: 1,
|
||||
userId: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
filter: filter,
|
||||
}, { dontCollect: true })];
|
||||
case 1:
|
||||
actionAuths = _a.sent();
|
||||
userRelations = actionAuths.map(function (ele) { return ele.relation.userEntityGrant$relation; });
|
||||
return [2 /*return*/, (0, lodash_1.uniq)(Array.prototype.concat.apply(undefined, userRelations).map(function (ele) { return ele.userId; }))];
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
exports.getUserIdsByActionAuth = getUserIdsByActionAuth;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { Cache } from 'oak-frontend-base/lib/features/cache';
|
|||
import { Feature } from 'oak-frontend-base/lib/types/Feature';
|
||||
import { CommonAspectDict } from 'oak-common-aspect';
|
||||
import { LocalStorage } from 'oak-frontend-base/lib/features/localStorage';
|
||||
import { AspectDict } from '../aspects/AspectDict';
|
||||
import AspectDict from '../aspects/AspectDict';
|
||||
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
|
||||
import { FrontendRuntimeContext } from '../context/FrontendRuntimeContext';
|
||||
import { ETheme, IThemeState } from '../types/themeState';
|
||||
|
|
|
|||
|
|
@ -79,15 +79,9 @@
|
|||
<view class="label">有效期:</view>
|
||||
<view class="value-period">
|
||||
<l-counter
|
||||
<<<<<<< HEAD
|
||||
count="{{userEntityGrant.period}}"
|
||||
max="120"
|
||||
min="5"
|
||||
=======
|
||||
count="{{period}}"
|
||||
max="{{ maxes[unit] }}"
|
||||
min="1"
|
||||
>>>>>>> dev
|
||||
round-float="{{true}}"
|
||||
bind:linchange="setPeriodMp"
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@
|
|||
"isomorphic-fetch": "^3.0.0",
|
||||
"miniprogram-api-typings": "^3.4.6",
|
||||
"mocha": "^8.2.1",
|
||||
"react-router-dom": "^6.4.2",
|
||||
"react-router-dom": "^6.13.0",
|
||||
"rimraf": "^3.0.2",
|
||||
"ts-node": "~10.9.1",
|
||||
"typescript": "~4.7.4"
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { generateNewIdAsync } from "oak-domain/lib/utils/uuid";
|
|||
import { BackendRuntimeContext } from "../context/BackendRuntimeContext";
|
||||
import { EntityDict } from "../general-app-domain";
|
||||
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity';
|
||||
import { uniq } from 'oak-domain/lib/utils/lodash';
|
||||
import assert from 'assert';
|
||||
|
||||
export async function mergeUser<ED extends EntityDict & BaseEntityDict, Cxt extends BackendRuntimeContext<ED>>(params: { from: string, to: string }, context: Cxt, innerLogic?: boolean) {
|
||||
|
|
@ -81,4 +82,58 @@ export async function mergeUser<ED extends EntityDict & BaseEntityDict, Cxt exte
|
|||
],
|
||||
},
|
||||
}, {});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取有对entity进行actions操作权限的用户Id(不包含root)
|
||||
* @param params
|
||||
* @param context
|
||||
*/
|
||||
export async function getUserIdsByActionAuth<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends BackendRuntimeContext<ED>>(params: {
|
||||
entity: T;
|
||||
entityId: string;
|
||||
actions: ED[T]['Action'][];
|
||||
overlap?: boolean;
|
||||
}, context: Cxt) {
|
||||
const { entity, entityId, actions, overlap } = params;
|
||||
const filter = {
|
||||
destEntity: entity as string,
|
||||
relation: {
|
||||
entity: entity as string,
|
||||
entityId,
|
||||
},
|
||||
};
|
||||
if (overlap) {
|
||||
Object.assign(filter, {
|
||||
deActions: {
|
||||
$overlaps: actions,
|
||||
},
|
||||
});
|
||||
}
|
||||
else {
|
||||
Object.assign(filter, {
|
||||
deActions: {
|
||||
$contains: actions,
|
||||
},
|
||||
});
|
||||
}
|
||||
const actionAuths = await context.select('actionAuth', {
|
||||
data: {
|
||||
id: 1,
|
||||
relation: {
|
||||
id: 1,
|
||||
userRelation$relation: {
|
||||
$entity: 'userRelation',
|
||||
data: {
|
||||
id: 1,
|
||||
userId: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
filter,
|
||||
}, { dontCollect: true });
|
||||
|
||||
const userRelations = actionAuths.map(ele => ele.relation!.userEntityGrant$relation!);
|
||||
return uniq(Array.prototype.concat.apply(undefined, userRelations).map(ele => ele.userId)) as string[];
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@ import { Cache } from 'oak-frontend-base/lib/features/cache';
|
|||
import { Feature } from 'oak-frontend-base/lib/types/Feature';
|
||||
import { CommonAspectDict } from 'oak-common-aspect';
|
||||
import { LocalStorage } from 'oak-frontend-base/lib/features/localStorage';
|
||||
import { AspectDict } from '../aspects/AspectDict';
|
||||
import AspectDict from '../aspects/AspectDict';
|
||||
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
|
||||
import { FrontendRuntimeContext } from '../context/FrontendRuntimeContext';
|
||||
import { ETheme, IThemeState } from '../types/themeState';
|
||||
|
|
|
|||
Loading…
Reference in New Issue