2026-05-24 05:42:51 +08:00
|
|
|
import { IAccessService } from "@certd/pipeline";
|
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-03-25 12:48:47 +08:00
|
|
|
getter: <T>(id: any, userId?: number, projectId?: number, ignorePermission?: boolean) => Promise<T>;
|
|
|
|
|
constructor(userId: number, projectId: number, getter: (id: any, userId: number, projectId?: number, ignorePermission?: boolean) => Promise<any>) {
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async getById<T = any>(id: any) {
|
2026-02-13 21:28:17 +08:00
|
|
|
return await this.getter<T>(id, this.userId, this.projectId);
|
2024-10-07 03:21:16 +08:00
|
|
|
}
|
2024-10-20 11:47:35 +08:00
|
|
|
|
|
|
|
|
async getCommonById<T = any>(id: any) {
|
2026-05-24 05:42:51 +08:00
|
|
|
return await this.getter<T>(id, 0, null);
|
2024-10-20 11:47:35 +08:00
|
|
|
}
|
2024-10-07 03:21:16 +08:00
|
|
|
}
|