72 lines
1.8 KiB
TypeScript
72 lines
1.8 KiB
TypeScript
/**
|
|
* 系统配置服务
|
|
* 负责系统配置的API调用
|
|
*/
|
|
|
|
import apiClient from '@/infrastructure/api/client';
|
|
import { API_ENDPOINTS } from '@/infrastructure/api/endpoints';
|
|
|
|
/** 前端展示设置 */
|
|
export interface DisplaySettings {
|
|
/** 是否允许未认种用户查看各省认种热度 */
|
|
allowNonAdopterViewHeat: boolean;
|
|
/** 热度展示方式: 'count' 显示具体数量, 'level' 仅显示热度等级 */
|
|
heatDisplayMode: 'count' | 'level';
|
|
}
|
|
|
|
/** 更新前端展示设置请求 */
|
|
export interface UpdateDisplaySettingsRequest {
|
|
allowNonAdopterViewHeat?: boolean;
|
|
heatDisplayMode?: 'count' | 'level';
|
|
}
|
|
|
|
/** 系统配置项 */
|
|
export interface SystemConfigItem {
|
|
key: string;
|
|
value: string;
|
|
description?: string;
|
|
updatedAt: string;
|
|
}
|
|
|
|
/**
|
|
* 系统配置服务
|
|
*/
|
|
export const systemConfigService = {
|
|
/**
|
|
* 获取所有系统配置
|
|
*/
|
|
async getAllConfigs(): Promise<SystemConfigItem[]> {
|
|
return apiClient.get(API_ENDPOINTS.SYSTEM_CONFIG.ALL);
|
|
},
|
|
|
|
/**
|
|
* 获取前端展示设置
|
|
*/
|
|
async getDisplaySettings(): Promise<DisplaySettings> {
|
|
return apiClient.get(API_ENDPOINTS.SYSTEM_CONFIG.DISPLAY_SETTINGS);
|
|
},
|
|
|
|
/**
|
|
* 更新前端展示设置
|
|
*/
|
|
async updateDisplaySettings(settings: UpdateDisplaySettingsRequest): Promise<DisplaySettings> {
|
|
return apiClient.put(API_ENDPOINTS.SYSTEM_CONFIG.DISPLAY_SETTINGS, settings);
|
|
},
|
|
|
|
/**
|
|
* 获取单个配置
|
|
*/
|
|
async getConfigByKey(key: string): Promise<SystemConfigItem | null> {
|
|
return apiClient.get(API_ENDPOINTS.SYSTEM_CONFIG.BY_KEY(key));
|
|
},
|
|
|
|
/**
|
|
* 更新单个配置
|
|
*/
|
|
async updateConfigByKey(key: string, value: string, description?: string): Promise<SystemConfigItem> {
|
|
return apiClient.put(API_ENDPOINTS.SYSTEM_CONFIG.BY_KEY(key), { value, description });
|
|
},
|
|
};
|
|
|
|
export default systemConfigService;
|