系统配置
This commit is contained in:
62
schoolNewsWeb/src/apis/system/config.ts
Normal file
62
schoolNewsWeb/src/apis/system/config.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* @description 系统配置相关API
|
||||
* @author yslg
|
||||
* @since 2025-11-18
|
||||
*/
|
||||
|
||||
import { api } from '@/apis/index';
|
||||
import type { ResultDomain } from '@/types';
|
||||
import type { ConfigItem, SaveConfigParam } from '@/types/system/config';
|
||||
/**
|
||||
* 系统配置API服务
|
||||
*/
|
||||
export const configApi = {
|
||||
/**
|
||||
* 获取所有配置项
|
||||
* @returns Promise<ResultDomain<ConfigItem[]>>
|
||||
*/
|
||||
async getConfigs(): Promise<ResultDomain<ConfigItem[]>> {
|
||||
const response = await api.get<ConfigItem[]>('/system/config/list');
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 根据分组获取配置项
|
||||
* @param groupKey 配置分组key
|
||||
* @returns Promise<ResultDomain<ConfigItem[]>>
|
||||
*/
|
||||
async getConfigsByGroup(groupKey: string): Promise<ResultDomain<ConfigItem[]>> {
|
||||
const response = await api.get<ConfigItem[]>(`/system/config/group/${groupKey}`);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 保存配置项
|
||||
* @param configs 配置项列表
|
||||
* @returns Promise<ResultDomain<boolean>>
|
||||
*/
|
||||
async saveConfigs(configs: SaveConfigParam[]): Promise<ResultDomain<boolean>> {
|
||||
const response = await api.post<boolean>('/system/config/save', configs);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 根据配置键获取配置值
|
||||
* @param configKey 配置键
|
||||
* @returns Promise<ResultDomain<string>>
|
||||
*/
|
||||
async getConfigValue(configKey: string): Promise<ResultDomain<string>> {
|
||||
const response = await api.get<string>(`/system/config/value/${configKey}`);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* 删除配置项
|
||||
* @param configKey 配置键
|
||||
* @returns Promise<ResultDomain<boolean>>
|
||||
*/
|
||||
async deleteConfig(configKey: string): Promise<ResultDomain<boolean>> {
|
||||
const response = await api.delete<boolean>(`/system/config/${configKey}`);
|
||||
return response.data;
|
||||
}
|
||||
};
|
||||
@@ -14,4 +14,5 @@ export { authApi } from './auth';
|
||||
export { fileApi } from './file';
|
||||
export { moduleApi } from './module';
|
||||
export { logApi } from './log';
|
||||
export { configApi} from './config';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user