ec-admin/src/api/config.ts
liuyun 0a1fbf3df2 refactor: 前端时间类型 string → number(对齐 Unix 毫秒契约)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-11 16:54:19 +08:00

55 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.

import { http } from '@/api/http'
export interface Config {
id: string
tenantCode: string
key: string
value: string | null
remark: string | null
createdAt: number
updatedAt: number
}
export interface ConfigListQuery {
page: number
pageSize: number
key?: string
value?: string
}
export interface ConfigListResult {
list: Config[]
total: number
page: number
pageSize: number
}
export interface ConfigUpsertData {
key?: string
value?: string
remark?: string
}
/** 配置分页列表。 */
export function listConfigs(query: ConfigListQuery, signal?: AbortSignal): Promise<ConfigListResult> {
const params: Record<string, unknown> = { page: query.page, pageSize: query.pageSize }
if (query.key) params.key = query.key
if (query.value) params.value = query.value
return http.get<ConfigListResult>('/configs', { params, signal })
}
/** 新增配置。 */
export function createConfig(data: ConfigUpsertData): Promise<Config> {
return http.post<Config>('/configs', data)
}
/** 更新配置(key 不可改)。 */
export function updateConfig(id: string, data: ConfigUpsertData): Promise<Config> {
return http.patch<Config>(`/configs/${id}`, data)
}
/** 删除配置(软删)。 */
export function deleteConfig(id: string): Promise<unknown> {
return http.delete(`/configs/${id}`)
}