Initial project
This commit is contained in:
28
src/api/CommonAPI.ts
Normal file
28
src/api/CommonAPI.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { axios, SettingKey, TemplateBizType, Toolkit } from "~/index";
|
||||
|
||||
const getCaptchaAPI = () => axios.defaults.baseURL + "/captcha";
|
||||
|
||||
const getAttachmentReadAPI = (mongoId: string) => `${axios.defaults.baseURL}/attachment/read/${mongoId}`;
|
||||
|
||||
async function getTemplate(bizType: TemplateBizType, code: string): Promise<string> {
|
||||
return axios.get(`/template?bizType=${bizType}&bizCode=${code}`);
|
||||
}
|
||||
|
||||
async function getSetting(key: string, args?: { [key: string]: any }): Promise<string> {
|
||||
return axios.get(`/setting/${key}?${Toolkit.toURLArgs(args)}`);
|
||||
}
|
||||
|
||||
async function listSetting(keyMap: Map<string, object | undefined>): Promise<Map<string, string>> {
|
||||
const result = await axios.post("/setting/map", Toolkit.toObject(keyMap));
|
||||
const map = new Map<string, string>();
|
||||
Object.entries(result).forEach(([key, value]) => map.set(key, value as string));
|
||||
return map;
|
||||
}
|
||||
|
||||
export default {
|
||||
getCaptchaAPI,
|
||||
getAttachmentReadAPI,
|
||||
getTemplate,
|
||||
getSetting,
|
||||
listSetting
|
||||
};
|
||||
Reference in New Issue
Block a user