mirror of
https://github.com/certd/certd.git
synced 2026-07-11 07:47:32 +08:00
30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
import { IAccessService, IRuntimeDepsService } from "@certd/pipeline";
|
|
|
|
export type AccessRuntimeDepsService = IRuntimeDepsService;
|
|
|
|
export class AccessGetter implements IAccessService {
|
|
userId: number;
|
|
projectId?: number;
|
|
runtimeDepsService?: AccessRuntimeDepsService;
|
|
getter: <T>(id: any, userId?: number, projectId?: number, ignorePermission?: boolean, runtimeDepsService?: AccessRuntimeDepsService) => Promise<T>;
|
|
constructor(
|
|
userId: number,
|
|
projectId: number,
|
|
getter: (id: any, userId: number, projectId?: number, ignorePermission?: boolean, runtimeDepsService?: AccessRuntimeDepsService) => Promise<any>,
|
|
runtimeDepsService?: AccessRuntimeDepsService
|
|
) {
|
|
this.userId = userId;
|
|
this.projectId = projectId;
|
|
this.getter = getter;
|
|
this.runtimeDepsService = runtimeDepsService;
|
|
}
|
|
|
|
async getById<T = any>(id: any) {
|
|
return await this.getter<T>(id, this.userId, this.projectId, false, this.runtimeDepsService);
|
|
}
|
|
|
|
async getCommonById<T = any>(id: any) {
|
|
return await this.getter<T>(id, 0, null, false, this.runtimeDepsService);
|
|
}
|
|
}
|