89 lines
2.0 KiB
TypeScript
89 lines
2.0 KiB
TypeScript
import { request } from "@/api/request";
|
|
|
|
/** API响应包装类型 */
|
|
export interface ApiResponse<T = any> {
|
|
code: number;
|
|
message: string;
|
|
data: T;
|
|
}
|
|
|
|
/** 分页响应类型 */
|
|
export interface PaginatedResponse<T> {
|
|
total: number;
|
|
page: number;
|
|
page_size: number;
|
|
data: T[];
|
|
}
|
|
|
|
/** 回收站记录 */
|
|
export interface TrashRecord {
|
|
id: number;
|
|
created_at: string;
|
|
updated_at: string;
|
|
resource_type: 'document' | 'faq';
|
|
resource_id: number;
|
|
resource_name: string;
|
|
deleted_by: number;
|
|
deleted_name: string;
|
|
deleted_time: string;
|
|
delete_reason: string;
|
|
original_data: string;
|
|
remarks: string;
|
|
}
|
|
|
|
/** 获取回收站列表参数 */
|
|
export interface FetchTrashListParams {
|
|
page?: number;
|
|
page_size?: number;
|
|
resource_type?: 'document' | 'faq';
|
|
}
|
|
|
|
/** 恢复资源请求参数 */
|
|
export interface RestoreTrashParams {
|
|
id: number;
|
|
}
|
|
|
|
/** 彻底删除请求参数 */
|
|
export interface DeleteTrashParams {
|
|
id: number;
|
|
}
|
|
|
|
/** 资源类型选项 */
|
|
export const resourceTypeOptions = [
|
|
{ label: '文档', value: 'document' },
|
|
{ label: '常见问题', value: 'faq' },
|
|
];
|
|
|
|
/** 获取资源类型文本 */
|
|
export const getResourceTypeText = (type: string): string => {
|
|
const typeMap: Record<string, string> = {
|
|
document: '文档',
|
|
faq: '常见问题',
|
|
};
|
|
return typeMap[type] || type;
|
|
};
|
|
|
|
/** 获取资源类型颜色 */
|
|
export const getResourceTypeColor = (type: string): string => {
|
|
const colorMap: Record<string, string> = {
|
|
document: 'blue',
|
|
faq: 'green',
|
|
};
|
|
return colorMap[type] || 'gray';
|
|
};
|
|
|
|
/** 获取回收站列表 */
|
|
export const fetchTrashList = (params?: FetchTrashListParams) => {
|
|
return request.get<ApiResponse<PaginatedResponse<TrashRecord>>>("/Kb/v1/trash/list", { params });
|
|
};
|
|
|
|
/** 恢复资源 */
|
|
export const restoreTrash = (data: RestoreTrashParams) => {
|
|
return request.post<ApiResponse<string>>("/Kb/v1/trash/restore", data);
|
|
};
|
|
|
|
/** 彻底删除 */
|
|
export const deleteTrash = (data: DeleteTrashParams) => {
|
|
return request.post<ApiResponse<string>>("/Kb/v1/trash/delete", data);
|
|
};
|