74 lines
1.7 KiB
TypeScript
74 lines
1.7 KiB
TypeScript
/**
|
||
* API 应用管理接口
|
||
* doc.json: /AA/getApiAppList、/AA/createApiApp 等
|
||
*/
|
||
|
||
import { get, post } from './request'
|
||
import { buildQuery } from './request'
|
||
import type { PageResult } from './types'
|
||
|
||
/** model.ApiApp:API 应用项 */
|
||
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)
|
||
}
|