Commit cf71f2c1 by 宋毅

tj

parent 326e9929
......@@ -10,29 +10,17 @@ class TmQueryAPI extends APIBase {
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionProcess) {
return system.getResult(null, "actionProcess参数不能为空");
}
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = null;
switch (pobj.actionProcess) {
case "jd"://京东
result = await this.jdOpActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody);
break;
default:
result = system.getResult(null, "actionProcess参数错误");
break;
}
var result = await this.opActionProcess(pobj.actionType, pobj.actionBody);
return result;
}
async jdOpActionProcess(action_process, action_type, action_body) {
async opActionProcess(action_type, action_body) {
var opResult = null;
switch (action_type) {
case "test"://测试
......
......@@ -8,29 +8,17 @@ class TmToolsAPI extends APIBase {
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionProcess) {
return system.getResult(null, "actionProcess参数不能为空");
}
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = null;
switch (pobj.actionProcess) {
case "jd"://京东
result = await this.jdOpActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody);
break;
default:
result = system.getResult(null, "actionProcess参数错误");
break;
}
var result = await this.opActionProcess(pobj.actionType, pobj.actionBody);
return result;
}
async jdOpActionProcess(action_process, action_type, action_body) {
async opActionProcess(action_type, action_body) {
var opResult = null;
switch (action_type) {
// sy
......
const system = require("../system");
const moment = require('moment')
const settings = require("../../config/settings");
const md5 = require("MD5");
class AppServiceBase {
constructor() {
this.execClient = system.getObject("util.execClient");
this.restClient = system.getObject("util.restClient");
this.cacheManager = system.getObject("db.common.cacheManager");
}
/**
* 验证签名
* @param {*} params 要验证的参数
* @param {*} app_key 应用的校验key
*/
async verifySign(params, app_key) {
if (!params) {
return system.getResult(null, "请求参数为空");
}
if (!params.sign) {
return system.getResult(null, "请求参数sign为空");
}
var signArr = [];
var keys = Object.keys(params).sort();
if (keys.length == 0) {
return system.getResult(null, "请求参数信息为空");
}
for (let k = 0; k < keys.length; k++) {
const tKey = keys[k];
if (tKey != "sign" && params[tKey] && !(params[tKey] instanceof Array)) {
signArr.push(tKey + "=" + params[tKey]);
}
}
if (signArr.length == 0) {
return system.getResult(null, "请求参数组装签名参数信息为空");
}
var resultSignStr = signArr.join("&") + "&key=" + app_key;
var resultTmpSign = md5(resultSignStr).toUpperCase();
if (params.sign != resultTmpSign) {
return system.getResult(null, "返回值签名验证失败");
}
return system.getResultSuccess();
}
async restPostUrl(pobj, url) {
var rtn = await this.restClient.execPost(pobj, url);
if (!rtn || !rtn.stdout) {
return system.getResult(null, "restPost is empty");
}
var result = JSON.parse(rtn.stdout);
return result;
}
async execPostUrl(pobj, url) {
var rtn = await this.execClient.execPost(pobj, url);
if (!rtn || !rtn.stdout) {
return system.getResult(null, "execPost is empty");
}
var result = JSON.parse(rtn.stdout);
return result;
}
}
module.exports = AppServiceBase;
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