user的查询条件改到checker里
This commit is contained in:
parent
7e8d1b68c7
commit
f61c7769ff
|
|
@ -16,7 +16,7 @@ const checkers: Checker<EntityDict, 'user', RuntimeCxt> [] = [
|
||||||
type: 'relation',
|
type: 'relation',
|
||||||
action: ['play', 'remove', 'disable', 'enable'],
|
action: ['play', 'remove', 'disable', 'enable'],
|
||||||
entity: 'user',
|
entity: 'user',
|
||||||
relationFilter: (userId) => {
|
relationFilter: () => {
|
||||||
// 只有root才能进行操作
|
// 只有root才能进行操作
|
||||||
throw new OakUserUnpermittedException();
|
throw new OakUserUnpermittedException();
|
||||||
},
|
},
|
||||||
|
|
@ -63,6 +63,29 @@ const checkers: Checker<EntityDict, 'user', RuntimeCxt> [] = [
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
errMsg: '不能禁用root用户',
|
errMsg: '不能禁用root用户',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'row',
|
||||||
|
action: 'select',
|
||||||
|
entity: 'user',
|
||||||
|
filter: (operation, context) => {
|
||||||
|
const systemId = context.getSystemId();
|
||||||
|
if (systemId) {
|
||||||
|
return {
|
||||||
|
id: {
|
||||||
|
$in: {
|
||||||
|
entity: 'userSystem',
|
||||||
|
data: {
|
||||||
|
userId: 1,
|
||||||
|
},
|
||||||
|
filter: {
|
||||||
|
systemId,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,3 +16,6 @@ export {
|
||||||
export * from './types/Exception';
|
export * from './types/Exception';
|
||||||
export { composeFileUrl, decomposeFileUrl } from './utils/extraFile';
|
export { composeFileUrl, decomposeFileUrl } from './utils/extraFile';
|
||||||
export * from './data/DEV-CONFIG';
|
export * from './data/DEV-CONFIG';
|
||||||
|
export * from './context/BackendRuntimeContext';
|
||||||
|
export * from './context/FrontendRuntimeContext';
|
||||||
|
export * from './context/RuntimeContext';
|
||||||
|
|
|
||||||
|
|
@ -124,54 +124,6 @@ const triggers: Trigger<EntityDict, 'user', RuntimeCxt>[] = [
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
} as UpdateTrigger<EntityDict, 'user', RuntimeCxt>,
|
} as UpdateTrigger<EntityDict, 'user', RuntimeCxt>,
|
||||||
{
|
|
||||||
name: '查询用户时,默认加上systemId',
|
|
||||||
entity: 'user',
|
|
||||||
action: 'select',
|
|
||||||
when: 'before',
|
|
||||||
fn: async ({ operation }, context) => {
|
|
||||||
const app = await context.getApplication();
|
|
||||||
if (app) {
|
|
||||||
const { filter } = operation;
|
|
||||||
if (!filter) {
|
|
||||||
Object.assign(operation, {
|
|
||||||
filter: {
|
|
||||||
id: {
|
|
||||||
$in: {
|
|
||||||
entity: 'userSystem',
|
|
||||||
data: {
|
|
||||||
userId: 1,
|
|
||||||
},
|
|
||||||
filter: {
|
|
||||||
systemId: app.systemId,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Object.assign(operation, {
|
|
||||||
filter: addFilterSegment({
|
|
||||||
id: {
|
|
||||||
$in: {
|
|
||||||
entity: 'userSystem',
|
|
||||||
data: {
|
|
||||||
userId: 1,
|
|
||||||
},
|
|
||||||
filter: {
|
|
||||||
systemId: app.systemId,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, filter),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
} as SelectTriggerBefore<EntityDict, 'user', RuntimeCxt>
|
|
||||||
];
|
];
|
||||||
|
|
||||||
export default triggers;
|
export default triggers;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue