feat:增加 fileConfig 文件配置(全部)、file 文件(部分)

This commit is contained in:
YunaiV
2025-04-07 10:22:27 +08:00
parent 1a3657b2bf
commit b4d1c678fd
19 changed files with 1044 additions and 13 deletions

View File

@@ -0,0 +1,68 @@
import { requestClient } from '#/api/request';
import type { PageParam, PageResult } from '@vben/request';
export namespace InfraFileConfigApi {
/** 文件客户端配置 */
export interface FileClientConfig {
basePath: string;
host?: string;
port?: number;
username?: string;
password?: string;
mode?: string;
endpoint?: string;
bucket?: string;
accessKey?: string;
accessSecret?: string;
domain: string;
}
/** 文件配置信息 */
export interface InfraFileConfig {
id?: number;
name: string;
storage?: number;
master: boolean;
visible: boolean;
config: FileClientConfig;
remark: string;
createTime?: Date;
}
}
/** 查询文件配置列表 */
export function getFileConfigPage(params: PageParam) {
return requestClient.get<PageResult<InfraFileConfigApi.InfraFileConfig>>('/infra/file-config/page', {
params
});
}
/** 查询文件配置详情 */
export function getFileConfig(id: number) {
return requestClient.get<InfraFileConfigApi.InfraFileConfig>(`/infra/file-config/get?id=${id}`);
}
/** 更新文件配置为主配置 */
export function updateFileConfigMaster(id: number) {
return requestClient.put(`/infra/file-config/update-master?id=${id}`);
}
/** 新增文件配置 */
export function createFileConfig(data: InfraFileConfigApi.InfraFileConfig) {
return requestClient.post('/infra/file-config/create', data);
}
/** 修改文件配置 */
export function updateFileConfig(data: InfraFileConfigApi.InfraFileConfig) {
return requestClient.put('/infra/file-config/update', data);
}
/** 删除文件配置 */
export function deleteFileConfig(id: number) {
return requestClient.delete(`/infra/file-config/delete?id=${id}`);
}
/** 测试文件配置 */
export function testFileConfig(id: number) {
return requestClient.get(`/infra/file-config/test?id=${id}`);
}

View File

@@ -0,0 +1,52 @@
import { requestClient } from '#/api/request';
import type { PageParam, PageResult } from '@vben/request';
export namespace InfraFileApi {
/** 文件信息 */
export interface InfraFile {
id?: number;
configId?: number;
path: string;
name?: string;
url?: string;
size?: number;
type?: string;
createTime?: Date;
}
/** 文件预签名地址 */
export interface FilePresignedUrlRespVO {
configId: number; // 文件配置编号
uploadUrl: string; // 文件上传 URL
url: string; // 文件 URL
}
}
/** 查询文件列表 */
export function getFilePage(params: PageParam) {
return requestClient.get<PageResult<InfraFileApi.InfraFile>>('/infra/file/page', {
params
});
}
/** 删除文件 */
export function deleteFile(id: number) {
return requestClient.delete(`/infra/file/delete?id=${id}`);
}
/** 获取文件预签名地址 */
export function getFilePresignedUrl(path: string) {
return requestClient.get<InfraFileApi.FilePresignedUrlRespVO>('/infra/file/presigned-url', {
params: { path }
});
}
/** 创建文件 */
export function createFile(data: InfraFileApi.InfraFile) {
return requestClient.post('/infra/file/create', data);
}
/** 上传文件 */
export function uploadFile(data: any) {
return requestClient.upload('/infra/file/upload', data);
}