Commit 550e6062 by Jaxon

feat(api/request): 添加对 dj.api.taskcenter 接口的支持

新增 taskcenter 接口的网关路由映射与签名配置,同时统一对象键名的引号格式并调整代码排版以提升可读性
1 parent b3f34706
......@@ -17,7 +17,7 @@ function request(
params = {},
method = RequestMethods.GET,
noSignAttr = [],
options = {}
options = {},
) {
// 兼容线上dj和scrm appkey和secret不一样的情况
let apiName = "";
......@@ -40,11 +40,9 @@ function request(
apiName = "dj";
} else if (params.method.includes("dj.api.oaapproval")) {
apiName = "oaapproval";
} else if (
params.method.includes(
"merchants.api.open.createMerchantWithPermissions"
)
) {
} else if (params.method.includes("dj.api.taskcenter")) {
apiName = "taskcenter";
} else if (params.method.includes("merchants.api.open.createMerchantWithPermissions")) {
/** 开放平台创建商户 — 与同网关 oaapproval 一致,使用 axios_oaapproval / baseURL */
apiName = "oaapproval";
} else {
......@@ -60,19 +58,20 @@ function request(
}
const mappingName = {
"dj.smartcarlife": "axios",
dj: "axios",
scrm: "axios2",
merchants: "axios3",
reportExport: "axios4",
"dj": "axios",
"scrm": "axios2",
"merchants": "axios3",
"reportExport": "axios4",
"glsx.accounts.biz.common.pictureUpload": "common",
clue: "axios5",
"clue": "axios5",
"dj.businessSchool": "axios6",
script: "axios7",
staff: "axios9",
riskmanage: "axios10",
strategy: "axios_strategy",
supervisor: "axios_supervisor",
oaapproval: "axios_oaapproval",
"script": "axios7",
"staff": "axios9",
"riskmanage": "axios10",
"strategy": "axios_strategy",
"supervisor": "axios_supervisor",
"oaapproval": "axios_oaapproval",
"taskcenter": "axiosTaskCenter",
};
const baseApiName = mappingName[apiName];
// console.log(baseApiName, "baseApiName")
......@@ -101,25 +100,26 @@ function request(
*/
const signWay = {
"dj.smartcarlife": "sha1",
dj: "sha1",
scrm: "sha1",
glsx: "md5",
"dj": "sha1",
"scrm": "sha1",
"glsx": "md5",
"glsx.accounts.biz.common.pictureUpload": "md5",
clue: "sha1",
script: "sha1",
staff: "sha1",
riskmanage: "sha1",
oaapproval: "sha1",
"clue": "sha1",
"script": "sha1",
"staff": "sha1",
"riskmanage": "sha1",
"oaapproval": "sha1",
"taskcenter": "sha1",
};
// console.log(signWay[apiName], "baseApiName")
const secret = baseConfig[baseApiName].secret;
const CancelToken = axiosPackage.CancelToken;
let reqData =
method === RequestMethods.POST
let reqData
= method === RequestMethods.POST
? {
baseURL: "/",
data: sign(params, noSignAttr, secret, signWay[apiName]),
}
}
: { params: sign(params, noSignAttr, secret, signWay[apiName]) };
reqData = Object.assign(reqData, options, {});
......@@ -142,7 +142,8 @@ function request(
method,
...reqData,
};
if (options.returnAll) axiosParams.headers = { "return-all": true };
if (options.returnAll)
axiosParams.headers = { "return-all": true };
return axios(axiosParams);
/**
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!