Commit ebadc580 by 宋毅

接口地址变化

parent da2d0454
...@@ -3,6 +3,7 @@ const settings = require("../../config/settings"); ...@@ -3,6 +3,7 @@ const settings = require("../../config/settings");
const uuidv4 = require('uuid/v4'); const uuidv4 = require('uuid/v4');
const sha256 = require('sha256'); const sha256 = require('sha256');
const md5 = require("MD5"); const md5 = require("MD5");
class APIBase { class APIBase {
constructor() { constructor() {
this.execClientNew = system.getObject("util.execClientNew"); this.execClientNew = system.getObject("util.execClientNew");
...@@ -16,11 +17,13 @@ class APIBase { ...@@ -16,11 +17,13 @@ class APIBase {
"icpNotify" "icpNotify"
]; ];
} }
getUUID() { getUUID() {
var uuid = uuidv4(); var uuid = uuidv4();
var u = uuid.replace(/\-/g, ""); var u = uuid.replace(/\-/g, "");
return u; return u;
} }
//-----------------------新的模式------------------开始 //-----------------------新的模式------------------开始
async doexecMethod(gname, methodname, pobj, query, req) { async doexecMethod(gname, methodname, pobj, query, req) {
...@@ -51,7 +54,11 @@ class APIBase { ...@@ -51,7 +54,11 @@ class APIBase {
//保存缓存 //保存缓存
await this.redisClient.setWithEx(shaStr, JSON.stringify(result), 3600); await this.redisClient.setWithEx(shaStr, JSON.stringify(result), 3600);
} }
var tmpResult = pobj.actionType && pobj.actionType.indexOf("List") < 0 ? result : { status: result.status, message: result.message, requestId: result.requestId }; var tmpResult = pobj.actionType && pobj.actionType.indexOf("List") < 0 ? result : {
status: result.status,
message: result.message,
requestId: result.requestId
};
this.execClientNew.execLogs("api-center-channel-doexecMethod-reqPath:" + req.path, pobj, "center-channel-doexecMethod", tmpResult, null); this.execClientNew.execLogs("api-center-channel-doexecMethod-reqPath:" + req.path, pobj, "center-channel-doexecMethod", tmpResult, null);
return result; return result;
} catch (e) { } catch (e) {
...@@ -95,18 +102,36 @@ class APIBase { ...@@ -95,18 +102,36 @@ class APIBase {
var result = JSON.parse(rtn.stdout); var result = JSON.parse(rtn.stdout);
return result; return result;
} }
/** /**
* 带超时时间的post请求 * 带超时时间的post请求
* @param {*} req 请求信息 * @param {*} req 请求信息
* @param {*} params 请求数据-json格式 * @param {*} params 请求数据-json格式
* @param {*} url 请求地址 * @param {*} url 请求地址
* @param {*} ContentType 请求头类型,默认application/json * @param {*} ContentType 请求头类型,默认application/json
* @param {*} headData 请求头内容-json格式,如:请求头中传递token,格式:{token:"9098902q849q0434q09439"} * @param {*} headData 请求头内容-json格式,如:请求头中传递token,格式:{token:"9098902q849q0434q09439"}
* @param {*} timeOut 超时时间 * @param {*} timeOut 超时时间
*/ */
async execPostByTimeOut(req, params, url, ContentType, headData, timeOut = 60) { async execPostByTimeOut(req, params, url, ContentType, headData, timeOut = 60) {
const result = await this.execClientNew.execPostTimeOutByBusiness('sve.base', params, url, ContentType, headData, timeOut, req); const result = await this.execClientNew.execPostTimeOutByBusiness('sve.base', params, url, ContentType, headData, timeOut, req);
return result; return result;
} }
/**
* 带headData和超时时间的post请求
* @param {*} params 请求数据-json格式
* @param {*} url 请求地址
* @param {*} ContentType 请求头类型,默认application/json
* @param {*} headData 请求头内容-json格式,如:请求头中传递token,格式:{token:"9098902q849q0434q09439"}
* @param {*} timeOut 超时时间
*/
async execPostByHeadDataTimeOut(params, url, ContentType, headData, timeOut = 5000) {
const result = await this.execClientNew.execPost(params, url, ContentType, headData, timeOut);
return result;
}
} }
module.exports = APIBase; module.exports = APIBase;
// var tmpapi=new APIBase();
// tmpapi.execPostByHeadDataTimeOut({"name":"sytest"},"http://qq.com",null,{"ak":"testak"},60)
...@@ -431,6 +431,18 @@ class AppServiceBase { ...@@ -431,6 +431,18 @@ class AppServiceBase {
const result = await this.execClientNew.execPostTimeOutByBusiness('sve.base', params, url, ContentType, headData, timeOut, req); const result = await this.execClientNew.execPostTimeOutByBusiness('sve.base', params, url, ContentType, headData, timeOut, req);
return result; return result;
} }
/**
* 带headData和超时时间的post请求
* @param {*} params 请求数据-json格式
* @param {*} url 请求地址
* @param {*} ContentType 请求头类型,默认application/json
* @param {*} headData 请求头内容-json格式,如:请求头中传递token,格式:{token:"9098902q849q0434q09439"}
* @param {*} timeOut 超时时间
*/
async execPostByHeadDataTimeOut(params, url, ContentType, headData, timeOut = 5000) {
const result = await this.execClientNew.execPost(params, url, ContentType, headData, timeOut);
return result;
}
/** /**
* 验证签名 * 验证签名
......
...@@ -83,7 +83,14 @@ class UtilsFqAliyunService extends AppServiceBase { ...@@ -83,7 +83,14 @@ class UtilsFqAliyunService extends AppServiceBase {
if (interface_params_info.opUrl.indexOf("/cts-open-agency/crm/opportunity/submit") >= 0) { if (interface_params_info.opUrl.indexOf("/cts-open-agency/crm/opportunity/submit") >= 0) {
await this.transformNeedActionBody(pobj); await this.transformNeedActionBody(pobj);
} }
let result = await this.opAliyunClientPost(pobj, interface_params_info.opUrl, interface_params_info.key, interface_params_info.secret, pobj.actionBody); //迁移到天翼云
let result = null;
if (interface_params_info.isNewReq && interface_params_info.isNewReq == 1) {
result = await this.execPostByHeadDataTimeOut(pobj.actionBody, interface_params_info.opUrl, null, {"X-Gsb-Ua-AppKey": settings.fqReqToken()})
} else {
result = await this.opAliyunClientPost(pobj, interface_params_info.opUrl, interface_params_info.key, interface_params_info.secret, pobj.actionBody);
}
// let result = await this.opAliyunClientPost(pobj, interface_params_info.opUrl, interface_params_info.key, interface_params_info.secret, pobj.actionBody);
return await this.disposePushResult(pobj, result, "fq->pushAliBusiness2Fq->result", this.pushlogFailType.FQ); return await this.disposePushResult(pobj, result, "fq->pushAliBusiness2Fq->result", this.pushlogFailType.FQ);
} }
...@@ -216,6 +223,96 @@ class UtilsFqAliyunService extends AppServiceBase { ...@@ -216,6 +223,96 @@ class UtilsFqAliyunService extends AppServiceBase {
module.exports = UtilsFqAliyunService; module.exports = UtilsFqAliyunService;
// //
//
// let tmp=new UtilsFqAliyunService(); // let tmp = new UtilsFqAliyunService();
// tmp.ddd(); // tmp.pushAliBusiness2Fq({
\ No newline at end of file // "actionType": "getAppInterface",
// "actionBody": {
// "area": "全国",
// "consultType": "2",
// "intentionBizId": "I20220720184552000001",
// "phone": "",
// "requestId": "bcd325a8-4f97-4c36-9e1a-9be239d58679",
// "description": "注册英文商标",
// "principalName": "2",
// "userName": "",
// "userId": "1437439160072087",
// "action_type": "submitNeed",
// "type": "ali.tm",
// "mobile": "",
// "service_product_id": "125855507574624256",
// "productId": "125855507574624256",
// "appName": "阿里云商机",
// "type_code": "sbzc",
// "type_name": "辅助注册",
// "channel_type_code": "2",
// "channel_type_name": "商标注册",
// "idempotentId": "I20220720184552000001",
// "idempotentSourceName": "阿里云商机",
// "idempotentSource": "tm_ali",
// "contactsDingtalk": "I20220720184552000001",
// "level": "A"
// },
// "appInfo": {
// "id": 19,
// "app_hosts": "ali.qifu.gongsibao.com",
// "app_code": "ali",
// "app_name": "阿里云商机",
// "uapp_id": "18",
// "uapp_key": "201912031344",
// "uapp_secret": "7cbb846246874167b5c7e01cd0016c88",
// "contact_name": "宋毅",
// "contact_mobile": "15010929366",
// "contact_email": null,
// "desc": null,
// "is_enabled": 1,
// "is_sign": 0,
// "pay_type": "10",
// "delivery_type": "00",
// "created_at": "2020-03-17T22:47:54.000Z",
// "updated_at": "2020-03-17T22:47:56.000Z",
// "version": 0
// },
// "actionProcess": "ali",
// "userInfo": {
// "version": 0,
// "id": 36402,
// "uapp_id": "18",
// "channel_userid": "115839EA37BCEF50F2689FFA2F3985FF",
// "channel_username": "115839EA37BCEF50F2689FFA2F3985FF",
// "channel_nickname": "",
// "mobile": "115839EA37BCEF50F2689FFA2F3985FF",
// "org_name": "",
// "org_path": "",
// "open_id": "",
// "head_url": "",
// "is_enabled": true,
// "email": "",
// "is_admin": false,
// "is_super": false,
// "last_login_time": "2022-07-20T10:50:05.177Z",
// "created_at": "2022-07-20T10:50:05.177Z"
// },
// "requestId": "84b3d286b2f842b6922bf6615aa543ef",
// "interface_info": {
// "uapp_id": 18,
// "is_enabled": 1,
// "product_id": null,
// "id": 50,
// "interface_url": "service.utilsSve.utilsFqAliyunSve",
// "interface_type": "bd",
// "interface_type_name": "本地接口",
// "method_name": "pushAliBusiness2Fq",
// "params": "{\"opUrl\":\"https://yunfuapi.gongsibao.com/cts-open-agency/crm/opportunity/submit\",\"key\":\"203763771\",\"secret\":\"e5e2ytnn6nrkr9qnqk4w5e6z0xlhkznu\"}",
// "desc": "推送阿里商标需求到蜂擎",
// "op_type": "pushNeedTMBusiness",
// "op_type_name": "推送需求商机",
// "created_at": "2020-03-19T16:24:08.000Z",
// "updated_at": null,
// "deleted_at": null,
// "version": null
// },
// "opType": "pushNeedTMBusiness",
// "isDelProductInfo": 1,
// "interface_params": "{\"opUrl\":\"https://yf.gongsibao.com/api/openapi/open/crm/opportunity/submit\",\"isNewReq\":1,\"key\":\"203763771\",\"secret\":\"e5e2ytnn6nrkr9qnqk4w5e6z0xlhkznu\"}"
// });
\ No newline at end of file
...@@ -164,12 +164,13 @@ class ExecClientNew { ...@@ -164,12 +164,13 @@ class ExecClientNew {
* @param {*} ContentType 请求头类型,默认application/json * @param {*} ContentType 请求头类型,默认application/json
* @param {*} headData 请求头内容-json格式,如:请求头中传递token,格式:{token:"9098902q849q0434q09439"} * @param {*} headData 请求头内容-json格式,如:请求头中传递token,格式:{token:"9098902q849q0434q09439"}
*/ */
async execPost(params, url, ContentType, headData) { async execPost(params, url, ContentType, headData, timeOut = 5000) {
if (!ContentType) { if (!ContentType) {
ContentType = "application/json"; ContentType = "application/json";
} }
let cmd = this.FetchPostCmd(params, url, ContentType, headData); let cmd = this.FetchPostCmd(params, url, ContentType, headData);
var options = { var options = {
timeout: timeOut,
maxBuffer: 1024 * 1024 * 15 maxBuffer: 1024 * 1024 * 15
}; };
var result = await this.exec(cmd, options, headData); var result = await this.exec(cmd, options, headData);
......
...@@ -23,6 +23,10 @@ let settings = { ...@@ -23,6 +23,10 @@ let settings = {
usertimeout: 3600,//单位秒 usertimeout: 3600,//单位秒
basepath: path.normalize(path.join(__dirname, '../..')), basepath: path.normalize(path.join(__dirname, '../..')),
port: process.env.NODE_PORT || 4012, port: process.env.NODE_PORT || 4012,
//云服token
fqReqToken() {
return "P0aox35UisxuIu910ufXvuw89a0zi7vM";
},
//记录日志地址 //记录日志地址
opNewLogUrl() { opNewLogUrl() {
if (this.env == 'dev') { if (this.env == 'dev') {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment