138 lines
2.2 KiB
TypeScript
138 lines
2.2 KiB
TypeScript
import request from '@/utils/request'
|
|
|
|
// API密钥数据类型定义
|
|
export interface ApiKey {
|
|
id?: number
|
|
name: string
|
|
value: string
|
|
remark?: string
|
|
createdBy?: string
|
|
createdTime?: string
|
|
updatedBy?: string
|
|
updatedTime?: string
|
|
}
|
|
|
|
// 分页查询参数
|
|
export interface ApiKeyQuery {
|
|
pageNo?: number
|
|
pageSize?: number
|
|
name?: string
|
|
createdBy?: string
|
|
}
|
|
|
|
/**
|
|
* 分页查询API密钥 (GET)
|
|
*/
|
|
export function getApiKeysPage(params: ApiKeyQuery) {
|
|
return request({
|
|
url: '/brichat-service/apiKeys/page',
|
|
method: 'get',
|
|
params,
|
|
})
|
|
}
|
|
|
|
/**
|
|
* 分页查询API密钥 (POST)
|
|
*/
|
|
export function getApiKeysPagePost(data: ApiKeyQuery) {
|
|
return request({
|
|
url: '/brichat-service/apiKeys/page',
|
|
method: 'post',
|
|
data,
|
|
})
|
|
}
|
|
|
|
/**
|
|
* 查询单个API密钥
|
|
*/
|
|
export function getApiKey(id: number) {
|
|
return request({
|
|
url: `/brichat-service/apiKeys/${id}`,
|
|
method: 'get',
|
|
})
|
|
}
|
|
|
|
/**
|
|
* 新增API密钥
|
|
*/
|
|
export function createApiKey(data: ApiKey) {
|
|
return request({
|
|
url: '/brichat-service/apiKeys',
|
|
method: 'post',
|
|
data,
|
|
})
|
|
}
|
|
|
|
/**
|
|
* 编辑API密钥
|
|
*/
|
|
export function updateApiKey(data: ApiKey) {
|
|
return request({
|
|
url: '/brichat-service/apiKeys',
|
|
method: 'put',
|
|
data,
|
|
})
|
|
}
|
|
|
|
/**
|
|
* 删除API密钥
|
|
*/
|
|
export function deleteApiKey(id: number) {
|
|
return request({
|
|
url: `/brichat-service/apiKeys/${id}`,
|
|
method: 'delete',
|
|
})
|
|
}
|
|
|
|
/**
|
|
* 批量删除API密钥
|
|
*/
|
|
export function batchDeleteApiKeys(ids: number[]) {
|
|
return request({
|
|
url: '/brichat-service/apiKeys/batch',
|
|
method: 'delete',
|
|
data: ids,
|
|
})
|
|
}
|
|
|
|
/**
|
|
* 查询所有API密钥
|
|
*/
|
|
export function getAllApiKeys() {
|
|
return request({
|
|
url: '/brichat-service/apiKeys/all',
|
|
method: 'get',
|
|
})
|
|
}
|
|
|
|
/**
|
|
* 根据名称查询API密钥
|
|
*/
|
|
export function getApiKeyByName(name: string) {
|
|
return request({
|
|
url: `/brichat-service/apiKeys/name/${name}`,
|
|
method: 'get',
|
|
})
|
|
}
|
|
|
|
/**
|
|
* 从缓存获取API密钥值
|
|
*/
|
|
export function getApiKeyFromCache(name: string) {
|
|
return request({
|
|
url: `/brichat-service/apiKeys/cache/${name}`,
|
|
method: 'get',
|
|
})
|
|
}
|
|
|
|
/**
|
|
* 刷新Redis缓存
|
|
*/
|
|
export function refreshCache() {
|
|
return request({
|
|
url: '/brichat-service/apiKeys/refresh-cache',
|
|
method: 'post',
|
|
})
|
|
}
|
|
|