/* * @Descripttion: * @version: * @Author: congsir * @Date: 2023-02-17 11:00:25 * @LastEditors: * @LastEditTime: 2023-09-04 14:14:53 */ import { CloudtSessionUser, UserRoles, AuthList, UploadOSSPolicy } from '../model/cloudt/session.user'; import { ApiClientFactory } from '../core/api.client.factory'; export class AuthService { constructor(protected factory: ApiClientFactory) {} // async loadCloudtUser(): Promise { // const user = await this.factory.cloudtRaw.get('/web/session/user'); // return user; // } async loadUserRoles(fullOrgId: string, userId: number, tenantId: string): Promise { const roles = await this.factory.datahub.get('/api/app/auth/roles', { fullOrgId, userId, tenantId, }); return roles; } /** * @function loadProjectAuth 获取项目的权限列表 */ async loadProjectAuth(projectId: string): Promise { const result = await this.factory.entity.get(`/api/module/auth/project/${projectId}`); return result; } /** * @function loadTenantAuth 获取租户的权限列表 */ async loadTenantAuth(tenantId: string): Promise { const result = await this.factory.entity.get(`/api/module/auth/tenant/${tenantId}`); return result; } /** * @function loadTenantInfoByOrgId 获取租户信息 */ loadTenantInfoByOrgId(orgId: string) { const result = this.factory.entity.get(`/api/tenants/org?orgId=${orgId}`); return result; } /** * @function loadClearProjectAuth 刷新项目的权限 */ async loadClearProjectAuth(projectId: string): Promise { const result = await this.factory.entity.get(`/api/module/auth/project/${projectId}/clearCache`); return result; } /** * @function loadClearTenantAuth 刷新租户的权限 */ async loadClearTenantAuth(tenantId: string): Promise { const result = await this.factory.entity.get(`/api/module/auth/tenant/${tenantId}/clearCache`); return result; } /** * 获取分享页面 */ fetchSharePageList(id: string, userId: string, type: 'project' | 'tenant') { const url = `/share/page/${type}/${id}`; return this.factory.surveillance.get(url, { userId }); } /** * 租户下项目授权情况 * @param tenantId */ fetchProjectAuthList(tenantId: string) { const url = `/api/auth/projects`; return this.factory.entity.get(url, { tenantId }); } /** * @function loadSyncAuth 同步授权 * @param tenantId 租户ID */ async loadSyncAuth(tenantId: string) { const response = await this.factory.entity.post(`/api/sync/auth/tenants/${tenantId}`); return response as any; } async syncronizeProjectAuth(projectId: string) { const response = await this.factory.entity.post(`/api/sync/auth/project/${projectId}`); return response as any; } /** * 获取项目状态 * @param tenantId * @returns */ async loadProjectStatus(tenantId: string) { const response = await this.factory.entity.get(`/api/org/projectStatus?tenantId=${tenantId}`); return response as any; } /** * 获取项目状态设置列表 * @param tenantId * @returns */ async loadProjectStatusSet(tenantId: string) { const response = await this.factory.entity.get(`/api/tenant/${tenantId}/projectStatus/list`); return response as any; } /** * 保存项目状态 * @param tenantId * @returns */ async saveProjectStatus(tenantId: string, projectStatus: string[]) { const response = await this.factory.entity.put(`/api/tenant/${tenantId}/projectStatus/save`, { projectStatus, }); return response as any; } // 获取文件上传Policy async loadUPDatePolicyV1() { const url = `/api/system/oss/policyV1`; const response = await this.factory.entity.get(url); return response; } }