remove deprecated api

This commit is contained in:
Timi
2026-08-07 10:46:14 +08:00
parent efea624376
commit f0ba55fe25
18 changed files with 194 additions and 306 deletions
+10 -10
View File
@@ -1,5 +1,5 @@
import {Attachment, BizUpdateReq, TempFileResp} from "../types";
import {axios} from "./BaseAPI";
import { Attachment, BizIdUpdate, TempFile } from "../types";
import { axios } from "./BaseAPI";
import CommonAPI from "./CommonAPI";
const BASE_URI = "/attach";
@@ -11,7 +11,7 @@ const BASE_URI = "/attach";
* @param ttl 有效期
* @returns 临时附件列表
*/
async function uploadTemp(file: File | File[], ttl?: string): Promise<TempFileResp[]> {
async function upload(file: File | File[], ttl?: string): Promise<TempFile[]> {
const formData = new FormData();
const fileList = Array.isArray(file) ? file : [file];
for (const item of fileList) {
@@ -28,8 +28,8 @@ async function uploadTemp(file: File | File[], ttl?: string): Promise<TempFileRe
*
* @param req 更新请求
*/
async function updateByBiz(req: BizUpdateReq): Promise<void> {
return await axios.post(`${BASE_URI}/update/biz`, req);
async function updateByBizId(req: BizIdUpdate): Promise<void> {
return await axios.post(`${BASE_URI}/update/biz/id`, req);
}
/**
@@ -39,8 +39,8 @@ async function updateByBiz(req: BizUpdateReq): Promise<void> {
* @param bizId 业务 ID
* @param attachTypeList 附件类型列表
*/
async function listByBiz(bizType: string, bizId: string, attachTypeList?: string[]): Promise<Attachment[]> {
return await axios.get(`${BASE_URI}/list/biz`, {
async function listByBizId(bizType: string, bizId: string, attachTypeList?: string[]): Promise<Attachment[]> {
return await axios.get(`${BASE_URI}/list/biz/id`, {
params: {
bizType,
bizId,
@@ -50,9 +50,9 @@ async function listByBiz(bizType: string, bizId: string, attachTypeList?: string
}
export default {
uploadTemp,
updateByBiz,
listByBiz,
upload,
updateByBizId,
listByBizId,
getReadURL: CommonAPI.getAttachmentReadAPI,
getTempReadURL: CommonAPI.getAttachmentTempReadAPI
};
+1 -11
View File
@@ -1,4 +1,4 @@
import { CaptchaData, Comment, CommentReply, Page, PageResult } from "../types";
import { CaptchaData, Comment, Page, PageResult } from "../types";
import { axios } from "./BaseAPI";
const BASE_URI = "/comment";
@@ -11,17 +11,7 @@ async function create(captchaData: CaptchaData<Comment>): Promise<void> {
return axios.post(`${BASE_URI}/create`, captchaData);
}
async function pageReply(page: Page<CommentReply>): Promise<PageResult<CommentReply>> {
return axios.post(`${BASE_URI}/reply/list`, page);
}
async function createReply(captchaData: CaptchaData<CommentReply>): Promise<void> {
return axios.post(`${BASE_URI}/reply/create`, captchaData);
}
export default {
page,
create,
createReply,
pageReply
};
+2 -7
View File
@@ -1,5 +1,5 @@
import {CaptchaResult, Setting, TemplateBizType} from "../types";
import {axios} from "./BaseAPI";
import { CaptchaResult, Setting } from "../types";
import { axios } from "./BaseAPI";
function getBaseURI(): string {
const baseURL = axios.defaults.baseURL;
@@ -19,10 +19,6 @@ const getAttachmentReadAPI = (id: string) => `${getBaseURI()}/attach/read/${id}`
const getAttachmentTempReadAPI = (id: string) => `${getBaseURI()}/attach/temp/read?id=${id}`;
async function getTemplate(bizType: TemplateBizType, code: string): Promise<string> {
return axios.get(`/template?bizType=${bizType}&bizCode=${code}`);
}
async function settingMap(map: Record<string, string[]>): Promise<Map<string, Map<string, Setting>>> {
const raw = await axios.post("/setting/map", map);
const moduleMap = new Map<string, Map<string, Setting>>();
@@ -47,6 +43,5 @@ export default {
captcha,
getAttachmentReadAPI,
getAttachmentTempReadAPI,
getTemplate,
settingMap
};
+4 -5
View File
@@ -1,5 +1,4 @@
import type {Attachment, CaptchaData, LoginRequest, LoginResponse, RegisterRequest, UpdatePasswordRequest, User} from "../types";
import {UserAttachType} from "../types";
import type {Attachment, CaptchaData, LoginRequest, LoginResponse, RegisterRequest, UpdatePasswordRequest, User, UserAttachType} from "../types";
import {axios} from "./BaseAPI";
import CommonAPI from "./CommonAPI";
@@ -55,17 +54,17 @@ async function view(id: string): Promise<User> {
function getAvatarURL(user?: UserAttachmentOwner) {
if (user?.attachmentList) {
return findAttachmentByType(user.attachmentList, [UserAttachType.AVATAR, UserAttachType.DEFAULT_AVATAR]);
return findAttachmentByType(user.attachmentList, "AVATAR");
}
}
function getWrapperURL(user?: UserAttachmentOwner) {
if (user?.attachmentList) {
return findAttachmentByType(user.attachmentList, [UserAttachType.WRAPPER, UserAttachType.DEFAULT_WRAPPER]);
return findAttachmentByType(user.attachmentList, "WRAPPER");
}
}
function findAttachmentByType(attachmentList: readonly Attachment[], types: UserAttachType[]) {
function findAttachmentByType(attachmentList: readonly Attachment[], ...types: UserAttachType[]) {
for (let i = 0; i < attachmentList.length; i++) {
const attachType = attachmentList[i].attachType as UserAttachType | undefined;
const id = attachmentList[i].id;