refactor(modules): 拆分多模块工程并收口common基础模块
This commit is contained in:
31
frontend/src/api/attachments.ts
Normal file
31
frontend/src/api/attachments.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { post } from './request';
|
||||
|
||||
export interface AttachmentUploadRequest {
|
||||
file: File;
|
||||
sourceType: string;
|
||||
sourceId?: string;
|
||||
}
|
||||
|
||||
export interface AttachmentResponse {
|
||||
id: string;
|
||||
sourceType: string;
|
||||
sourceId?: string | null;
|
||||
originalName: string;
|
||||
fileName: string;
|
||||
fileSuffix?: string | null;
|
||||
contentType?: string | null;
|
||||
fileSize: number;
|
||||
storageType: string;
|
||||
fileUrl?: string | null;
|
||||
remark?: string | null;
|
||||
}
|
||||
|
||||
export function uploadAttachment(data: AttachmentUploadRequest) {
|
||||
const formData = new FormData();
|
||||
formData.append('file', data.file);
|
||||
formData.append('sourceType', data.sourceType);
|
||||
if (data.sourceId) {
|
||||
formData.append('sourceId', data.sourceId);
|
||||
}
|
||||
return post<AttachmentResponse, FormData>('/attachments/upload', formData);
|
||||
}
|
||||
Reference in New Issue
Block a user