72 lines
2.2 KiB
JavaScript
72 lines
2.2 KiB
JavaScript
import { OakUnloggedInException, } from 'oak-domain/lib/types';
|
|
import { omit } from 'oak-domain/lib/utils/lodash';
|
|
export async function loadRelations(params, context) {
|
|
const { entities } = params;
|
|
const userId = context.getCurrentUserId();
|
|
if (!userId) {
|
|
throw new OakUnloggedInException();
|
|
}
|
|
const userRelations = await context.select('userRelation', {
|
|
data: {
|
|
id: 1,
|
|
userId: 1,
|
|
relationId: 1,
|
|
entity: 1,
|
|
entityId: 1,
|
|
relation: {
|
|
id: 1,
|
|
entity: 1,
|
|
entityId: 1,
|
|
name: 1,
|
|
display: 1,
|
|
actionAuth$relation: {
|
|
$entity: 'actionAuth',
|
|
data: {
|
|
id: 1,
|
|
pathId: 1,
|
|
path: {
|
|
id: 1,
|
|
sourceEntity: 1,
|
|
destEntity: 1,
|
|
value: 1,
|
|
recursive: 1,
|
|
},
|
|
deActions: 1,
|
|
},
|
|
},
|
|
relationAuth$sourceRelation: {
|
|
$entity: 'relationAuth',
|
|
data: {
|
|
id: 1,
|
|
sourceRelationId: 1,
|
|
destRelationId: 1,
|
|
destRelation: {
|
|
id: 1,
|
|
entity: 1,
|
|
entityId: 1,
|
|
name: 1,
|
|
display: 1,
|
|
},
|
|
pathId: 1,
|
|
path: {
|
|
id: 1,
|
|
sourceEntity: 1,
|
|
destEntity: 1,
|
|
value: 1,
|
|
recursive: 1,
|
|
},
|
|
},
|
|
}
|
|
},
|
|
},
|
|
filter: {
|
|
userId,
|
|
entity: {
|
|
$in: entities,
|
|
},
|
|
},
|
|
}, {});
|
|
const result = userRelations.map((userRelation) => omit(userRelation, 'relation'));
|
|
return result;
|
|
}
|