test: web
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
import apiClient from './index';
|
||||
import type { Key } from '../types/models';
|
||||
import apiClient from "./index";
|
||||
import type { Key } from "../types/models";
|
||||
|
||||
/**
|
||||
* 获取指定分组下的所有密钥列表
|
||||
* @param groupId 分组ID
|
||||
*/
|
||||
export const fetchKeysInGroup = (groupId: string): Promise<Key[]> => {
|
||||
return apiClient.get(`/groups/${groupId}/keys`).then(res => res.data.data);
|
||||
return apiClient.get(`/groups/${groupId}/keys`).then((res) => res.data.data);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -14,8 +14,21 @@ export const fetchKeysInGroup = (groupId: string): Promise<Key[]> => {
|
||||
* @param groupId 分组ID
|
||||
* @param keyData 新密钥的数据
|
||||
*/
|
||||
export const createKey = (groupId: string, keyData: Omit<Key, 'id' | 'group_id' | 'usage' | 'created_at' | 'updated_at'>): Promise<Key> => {
|
||||
return apiClient.post(`/groups/${groupId}/keys`, keyData).then(res => res.data.data);
|
||||
export const createKey = (
|
||||
groupId: string,
|
||||
keyData: Omit<
|
||||
Key,
|
||||
| "id"
|
||||
| "group_id"
|
||||
| "created_at"
|
||||
| "updated_at"
|
||||
| "request_count"
|
||||
| "failure_count"
|
||||
>
|
||||
): Promise<Key> => {
|
||||
return apiClient
|
||||
.post(`/groups/${groupId}/keys`, keyData)
|
||||
.then((res) => res.data.data);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -23,8 +36,8 @@ export const createKey = (groupId: string, keyData: Omit<Key, 'id' | 'group_id'
|
||||
* @param id 密钥ID
|
||||
* @param keyData 要更新的数据
|
||||
*/
|
||||
export const updateKey = (id: string, keyData: Partial<Omit<Key, 'id' | 'group_id' | 'usage' | 'created_at' | 'updated_at'>>): Promise<Key> => {
|
||||
return apiClient.put(`/keys/${id}`, keyData).then(res => res.data.data);
|
||||
export const updateKey = (id: string, keyData: Partial<Key>): Promise<Key> => {
|
||||
return apiClient.put(`/keys/${id}`, keyData).then((res) => res.data.data);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -32,5 +45,27 @@ export const updateKey = (id: string, keyData: Partial<Omit<Key, 'id' | 'group_i
|
||||
* @param id 密钥ID
|
||||
*/
|
||||
export const deleteKey = (id: string): Promise<void> => {
|
||||
return apiClient.delete(`/keys/${id}`).then(res => res.data);
|
||||
};
|
||||
return apiClient.delete(`/keys/${id}`).then((res) => res.data);
|
||||
};
|
||||
|
||||
/**
|
||||
* 批量更新密钥
|
||||
* @param ids 密钥ID列表
|
||||
* @param data 要更新的数据
|
||||
*/
|
||||
export const batchUpdateKeys = (
|
||||
ids: string[],
|
||||
data: Partial<Key>
|
||||
): Promise<void> => {
|
||||
return apiClient
|
||||
.post("/keys/batch-update", { ids, data })
|
||||
.then((res) => res.data);
|
||||
};
|
||||
|
||||
/**
|
||||
* 批量删除密钥
|
||||
* @param ids 密钥ID列表
|
||||
*/
|
||||
export const batchDeleteKeys = (ids: string[]): Promise<void> => {
|
||||
return apiClient.post("/keys/batch-delete", { ids }).then((res) => res.data);
|
||||
};
|
||||
|
Reference in New Issue
Block a user