xtraderClient/src/api/apiApp.ts
2026-03-22 11:23:48 +08:00

74 lines
1.7 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.

/**
* API 应用管理接口
* doc.json: /AA/getApiAppList、/AA/createApiApp 等
*/
import { get, post } from './request'
import { buildQuery } from './request'
import type { PageResult } from './types'
/** model.ApiAppAPI 应用项 */
export interface ApiApp {
ID?: number
appKey: string
appSecret: string
desc?: string
status: boolean
userId: number
createdAt?: string
updatedAt?: string
[key: string]: unknown
}
export interface GetApiAppListParams {
page?: number
pageSize?: number
keyword?: string
createdAtRange?: string[]
}
export interface ApiAppListResponse {
code: number
data?: PageResult<ApiApp>
msg: string
}
/**
* GET /AA/getApiAppList
* 分页获取 API 应用列表需鉴权x-token、x-user-id
*/
export async function getApiAppList(
params: GetApiAppListParams = {},
config?: { headers?: Record<string, string> },
): Promise<ApiAppListResponse> {
const { page = 1, pageSize = 10, keyword, createdAtRange } = params
const query = buildQuery({ page, pageSize, keyword, createdAtRange })
return get<ApiAppListResponse>('/AA/getApiAppList', query, config)
}
/** 创建 API 应用请求体appKey/appSecret 由后端生成时可传空) */
export interface CreateApiAppBody {
desc?: string
status: boolean
userId: number
appKey?: string
appSecret?: string
}
export interface CreateApiAppResponse {
code: number
data?: ApiApp
msg: string
}
/**
* POST /AA/createApiApp
* 创建 API 应用,需鉴权。成功后返回新创建的 ApiApp含 appKey、appSecret
*/
export async function createApiApp(
body: CreateApiAppBody,
config?: { headers?: Record<string, string> },
): Promise<CreateApiAppResponse> {
return post<CreateApiAppResponse>('/AA/createApiApp', body, config)
}