import { TemplateBizType } from "../types"; import Toolkit from "../utils/Toolkit"; import { axios } from "./BaseAPI"; import TextFormat from "../utils/TextFormat"; const getCaptchaAPI = () => axios.defaults.baseURL + "/captcha"; const getAttachmentReadAPI = (mongoId: string) => `${axios.defaults.baseURL}/attachment/read/${mongoId}`; async function getTemplate(bizType: TemplateBizType, code: string): Promise { return axios.get(`/template?bizType=${bizType}&bizCode=${code}`); } async function getSetting(key: string, args?: { [key: string]: any }): Promise { return axios.get(`/setting/${key}?${TextFormat.urlArgs(args)}`); } async function listSetting(keyMap: Map): Promise> { const result = await axios.post("/setting/map", Toolkit.toObject(keyMap)); const map = new Map(); Object.entries(result).forEach(([key, value]) => map.set(key, value as string)); return map; } export default { getCaptchaAPI, getAttachmentReadAPI, getTemplate, getSetting, listSetting };