This commit is contained in:
Timi
2026-07-30 18:28:25 +08:00
parent 8b24804b22
commit f0d1090932
21 changed files with 915 additions and 268 deletions
+58
View File
@@ -0,0 +1,58 @@
import {Attachment, BizUpdateReq, TempFileResp} from "../types";
import {axios} from "./BaseAPI";
import CommonAPI from "./CommonAPI";
const BASE_URI = "/attach";
/**
* 上传临时附件
*
* @param file 文件或文件列表
* @param ttl 有效期
* @returns 临时附件列表
*/
async function uploadTemp(file: File | File[], ttl?: string): Promise<TempFileResp[]> {
const formData = new FormData();
const fileList = Array.isArray(file) ? file : [file];
for (const item of fileList) {
formData.append("file", item);
}
if (ttl) {
formData.append("ttl", ttl);
}
return await axios.post(`${BASE_URI}/temp/upload`, formData);
}
/**
* 按业务差分更新附件
*
* @param req 更新请求
*/
async function updateByBiz(req: BizUpdateReq): Promise<void> {
return await axios.post(`${BASE_URI}/update/biz`, req);
}
/**
* 按业务查询附件列表
*
* @param bizType 业务类型
* @param bizId 业务 ID
* @param attachTypeList 附件类型列表
*/
async function listByBiz(bizType: string, bizId: string, attachTypeList?: string[]): Promise<Attachment[]> {
return await axios.get(`${BASE_URI}/list/biz`, {
params: {
bizType,
bizId,
attachTypeList
}
});
}
export default {
uploadTemp,
updateByBiz,
listByBiz,
getReadURL: CommonAPI.getAttachmentReadAPI,
getTempReadURL: CommonAPI.getAttachmentTempReadAPI
};