2026-06-20 00:35:13 +08:00
|
|
|
import { IAccessService, IRuntimeDepsService } from "@certd/pipeline";
|
2024-10-07 03:21:16 +08:00
|
|
|
|
2026-06-20 00:35:13 +08:00
|
|
|
export type AccessRuntimeDepsService = IRuntimeDepsService;
|
2026-06-19 17:44:57 +08:00
|
|
|
|
2024-10-07 03:21:16 +08:00
|
|
|
export class AccessGetter implements IAccessService {
|
|
|
|
|
userId: number;
|
2026-02-13 21:28:17 +08:00
|
|
|
projectId?: number;
|
2026-06-19 17:44:57 +08:00
|
|
|
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
|
|
|
|
|
) {
|
2024-10-07 03:21:16 +08:00
|
|
|
this.userId = userId;
|
2026-02-13 21:28:17 +08:00
|
|
|
this.projectId = projectId;
|
2024-10-07 03:21:16 +08:00
|
|
|
this.getter = getter;
|
2026-06-19 17:44:57 +08:00
|
|
|
this.runtimeDepsService = runtimeDepsService;
|
2024-10-07 03:21:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async getById<T = any>(id: any) {
|
2026-06-19 17:44:57 +08:00
|
|
|
return await this.getter<T>(id, this.userId, this.projectId, false, this.runtimeDepsService);
|
2024-10-07 03:21:16 +08:00
|
|
|
}
|
2024-10-20 11:47:35 +08:00
|
|
|
|
|
|
|
|
async getCommonById<T = any>(id: any) {
|
2026-06-19 17:44:57 +08:00
|
|
|
return await this.getter<T>(id, 0, null, false, this.runtimeDepsService);
|
2024-10-20 11:47:35 +08:00
|
|
|
}
|
2024-10-07 03:21:16 +08:00
|
|
|
}
|