Files
OCS_service/app/services/settings_service.ts
T
2026-05-23 22:23:29 +08:00

44 lines
1.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// app/services/settings_service.ts - 用户设置和系统配置 API 封装
import type {
IApiResponse,
ISystemConfigResponse,
ISystemConfigUpdateRequest,
IUserSettingsResponse,
IUserSettingsUpdateRequest
} from "@/interfaces";
import BaseClientService from "@/services/base_service";
export class SettingsService {
private static readonly basePath = "/api";
/** 读取当前用户的自定义 API 配置 */
public static getUserSettings() {
return BaseClientService.get<IUserSettingsResponse>(
`${SettingsService.basePath}/user/settings`
);
}
/** 更新当前用户的自定义 API 配置 */
public static updateUserSettings(req: IUserSettingsUpdateRequest) {
return BaseClientService.post<IApiResponse<null>, IUserSettingsUpdateRequest>(
`${SettingsService.basePath}/user/settings`,
req
);
}
/** 读取系统配置(仅 superadmin */
public static getSystemConfig() {
return BaseClientService.get<ISystemConfigResponse>(
`${SettingsService.basePath}/admin/system-config`
);
}
/** 更新系统配置(仅 superadmin */
public static updateSystemConfig(req: ISystemConfigUpdateRequest) {
return BaseClientService.put<IApiResponse<null>, ISystemConfigUpdateRequest>(
`${SettingsService.basePath}/admin/system-config`,
req
);
}
}