100 lines
2.0 KiB
TypeScript
100 lines
2.0 KiB
TypeScript
import request from '@/utils/request'
|
|
|
|
export interface SystemConfig {
|
|
id?: number
|
|
configKey: string
|
|
configValue: string
|
|
configGroup?: string
|
|
configName?: string
|
|
description?: string
|
|
valueType?: string
|
|
builtIn?: number
|
|
sortOrder?: number
|
|
}
|
|
|
|
/**
|
|
* 获取系统配置值
|
|
*/
|
|
export const getSystemConfig = (key: string) => {
|
|
return request.get<string>(`/system-config/key/${key}`)
|
|
}
|
|
|
|
/**
|
|
* 获取所有系统配置
|
|
*/
|
|
export const getAllSystemConfigs = () => {
|
|
return request.get<any>('/system-config')
|
|
}
|
|
|
|
/**
|
|
* 根据分组获取系统配置
|
|
*/
|
|
export const getSystemConfigsByGroup = (group: string) => {
|
|
return request.get<any>(`/system-config/group/${group}`)
|
|
}
|
|
|
|
/**
|
|
* 获取所有系统配置的Map
|
|
*/
|
|
export const getAllSystemConfigsMap = () => {
|
|
return request.get<Record<string, string>>('/system-config/map')
|
|
}
|
|
|
|
/**
|
|
* 根据分组获取系统配置Map
|
|
*/
|
|
export const getSystemConfigsMapByGroup = (group: string) => {
|
|
return request.get<Record<string, string>>(`/system-config/map/group/${group}`)
|
|
}
|
|
|
|
/**
|
|
* 创建系统配置
|
|
*/
|
|
export const createSystemConfig = (config: {
|
|
configKey: string
|
|
configValue: string
|
|
configGroup?: string
|
|
configName?: string
|
|
description?: string
|
|
valueType?: string
|
|
builtIn?: number
|
|
sortOrder?: number
|
|
}) => {
|
|
return request.post<any>('/system-config', config)
|
|
}
|
|
|
|
/**
|
|
* 更新系统配置
|
|
*/
|
|
export const updateSystemConfig = (id: number, config: {
|
|
configValue?: string
|
|
configName?: string
|
|
description?: string
|
|
valueType?: string
|
|
sortOrder?: number
|
|
}) => {
|
|
return request.put<any>(`/system-config/${id}`, config)
|
|
}
|
|
|
|
/**
|
|
* 批量更新系统配置值
|
|
*/
|
|
export const batchUpdateSystemConfigs = (configMap: Record<string, string>) => {
|
|
return request.put<any>('/system-config/batch', configMap)
|
|
}
|
|
|
|
/**
|
|
* 删除系统配置
|
|
*/
|
|
export const deleteSystemConfig = (id: number) => {
|
|
return request.delete<any>(`/system-config/${id}`)
|
|
}
|
|
|
|
/**
|
|
* 初始化默认配置
|
|
*/
|
|
export const initDefaultConfigs = () => {
|
|
return request.post<any>('/system-config/init')
|
|
}
|
|
|