Commit eb24f1f5 by 宋毅

tj

parent 4980f09c
......@@ -43,7 +43,7 @@ class APIBase {
if (!result) {
result = system.getResult(null, "请求的方法返回值为空");
}
var tmpResult = 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.execClient.execLogs("reqPath:" + req.path + "执行结果", param, "brg-user-center-apibase", tmpResult, null);
result.requestId = result.requestId || uuid.v1();
if (req.body.Action && this.userCenterAction[req.body.Action]) {
......@@ -57,7 +57,7 @@ class APIBase {
console.log(stackStr, "api调用出现异常,请联系管理员..........")
var rtnerror = system.getResultFail(-200, "出现异常,error:" + stackStr);
rtnerror.requestId = uuid.v1();
this.execClient.execLogs("reqPath:" + req.path + "执行异常", param, "brg-user-center-apibase", null,stackStr);
this.execClient.execLogs("reqPath:" + req.path + "执行异常", param, "brg-user-center-apibase", null, stackStr);
if (req.body.Action && this.userCenterAction[req.body.Action]) {
return {
"Response": {
......@@ -178,6 +178,29 @@ class APIBase {
//-----------------------新的模式------------------结束
async brgDoexecMethod(gname, methodname, pobj, query, req) {
var param = {
pobj: pobj,
query: query
}
try {
var result = await this[methodname](pobj, query, req);
if (!result) {
result = system.getResult(null, "请求的方法返回值为空");
}
result.requestId = result.requestId || uuid.v1();
this.execClient.execLogs("reqPath:" + req.path + "brg请求结果", param, "brg-user-center-brg-apibase", result, null);
return result;
} catch (error) {
var stackStr = error.stack ? error.stack : JSON.stringify(error);
console.log(stackStr, "api-brg请求调用出现异常,请联系管理员..........")
var rtnerror = system.getResultTX(-1, "", "brg请求出现异常,error:" + stackStr, null);
rtnerror.requestId = uuid.v1();
this.execClient.execLogs("reqPath:" + req.path + "brg请求出现异常", param, "brg-user-center-brg-apibase", null, stackStr);
return rtnerror;
}
}
/**
* 带超时时间的post请求
* @param {*} params 请求数据-json格式
......
......@@ -14,7 +14,7 @@ class Need extends APIBase {
*/
async springBoard(pobj, qobj, req) {
if (!pobj.interface || !pobj.interface.interfaceName) {
return system.getResult(null, "interfaceName参数不能为空");
return system.getResultTX(-1,"","interfaceName参数不能为空",null);
}
var result = await this.opActionProcess(pobj, pobj.interface.interfaceName, req);
return result;
......@@ -41,7 +41,7 @@ class Need extends APIBase {
opResult = await this.txPushLogSve.destroyResource(pobj);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
opResult = system.getResultTX(-1,"","未知方法名",null);
break;
}
return opResult;
......
......@@ -4,6 +4,9 @@ var settings = require("../../../../config/settings");
class TxPushLogService extends ServiceBase {
constructor() {
super("common", ServiceBase.getDaoName(TxPushLogService));
this.orderProductDao = system.getObject("db.order.orderProductDao");
this.orderInfoDao = system.getObject("db.order.orderInfoDao");
}
returnTX(status, componentName, message, data) {
......@@ -66,6 +69,7 @@ class TxPushLogService extends ServiceBase {
//发货检查
async queryFlow(pobj) {
var self=this;
if (!pobj.interface.para.flowId) {
return self.returnTX(-1, "cgateway", "参数错误", null)
}
......@@ -87,6 +91,7 @@ class TxPushLogService extends ServiceBase {
//资源拉取
async queryResources(pobj) {
var self=this;
if (!pobj.interface.para.resourceIds[0]) {
return self.returnTX(-1, "cgateway", "参数错误", null)
}
......@@ -156,6 +161,7 @@ class TxPushLogService extends ServiceBase {
// }
//隔离资源
async isolateResource(pobj) {
var self=this;
if (!pobj.interface.para.resourceId) {
return self.returnTX(-1, "mall_logic", "参数错误", null)
}
......@@ -176,6 +182,7 @@ class TxPushLogService extends ServiceBase {
//销毁资源
async destroyResource(pobj) {
var self=this;
if (!pobj.interface.para.resourceId) {
return self.returnTX(-1, "mall_logic", "参数错误", null)
}
......@@ -210,6 +217,7 @@ class TxPushLogService extends ServiceBase {
//新购参数检查
async checkCreate(pobj) {
var self=this;
if (!pobj.interface || !pobj.interface.para || !pobj.interface.para.goodsDetail) {
return self.returnTX(-1, "qcloud_domain_register", "参数错误", null)
}
......
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
......@@ -138,6 +138,23 @@ class System {
data: data
};
}
/**
* tx请求返回成功
*/
static getResultTX(status, componentName, message, data) {
return {
"version": 1,
"componentName": componentName,
"returnValue": status,
"returnCode": status,
"returnMessage": message,
"timestamp": Date.now(),
"data": data
}
}
/**
* 请求返回成功
* @param {*} data 操作成功返回的数据
......
......@@ -75,5 +75,32 @@ module.exports = function (app) {
});
});
app.post('/brg/:gname/:qname/:method', function (req, res) {
var classPath = req.params["qname"];
var methodName = req.params["method"];
var gname = req.params["gname"];
var params = [];
classPath = gname + "." + classPath;
var tClientIp = system.get_client_ip(req);
req.clientIp = tClientIp;
req.uagent = req.headers["user-agent"];
req.classname = classPath;
params.push(gname);
params.push(methodName);
params.push(req.body);
params.push(req.query);
params.push(req);
var p = null;
var invokeObj = system.getObject("api." + classPath);
if (invokeObj["brgDoexecMethod"]) {
p = invokeObj["brgDoexecMethod"].apply(invokeObj, params);
}
p.then(r => {
res.end(JSON.stringify(r));
});
});
//-----------------------新的模式---------api---------结束
};
......@@ -34,14 +34,7 @@ var settings = {
if (this.env == "dev" || this.env == "test") {
return "http://tx.g.com:8000";
} else {
return "http://paas-service";
}
},
hemingUrl: function () {
if (this.env == "dev" || this.env == "test") {
return "http://192.168.1.131:15502/gsb/heming";
} else {
return "http://ic-name-service/gsb/heming";
return "http://tx.brg.tencentyun.com";
}
},
hemingUrl: function () {
......@@ -75,7 +68,6 @@ var settings = {
password: ENVINPUT.DB_PWD,
config: {
host: ENVINPUT.DB_HOST,
port: ENVINPUT.DB_PORT,
dialect: 'mysql',
operatorsAliases: false,
pool: {
......
{
"name": "bigdata",
"version": "1.0.0",
"description": "h5framework",
"main": "main.js",
"scripts": {
"dev": "nodemon main.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"license": "ISC",
"dependencies": {
"@alicloud/pop-core": "^1.7.7",
"MD5": "^1.3.0",
"after": "^0.8.2",
"ali-oss": "^4.12.2",
"aliyun-api-gateway": "^1.1.6",
"axios": "^0.19.2",
"babel-polyfill": "^6.26.0",
"base64id": "^1.0.0",
"bluebird": "^3.5.1",
"body-parser": "^1.18.2",
"co": "^4.6.0",
"connect-redis": "^3.3.3",
"continuation-local-storage": "^3.2.1",
"cookie-parser": "^1.4.3",
"crypto": "^1.0.1",
"crypto-js": "^3.1.9-1",
"ejs": "^2.5.8",
"element-ui": "^2.4.0",
"engine.io-parser": "^2.1.2",
"errorhandler": "^1.5.0",
"exif-js": "^2.3.0",
"express": "^4.16.2",
"express-session": "^1.15.6",
"gm": "^1.23.1",
"marked": "^0.7.0",
"method-override": "^2.3.10",
"morgan": "^1.9.0",
"multer": "^1.3.0",
"mysql2": "^1.5.3",
"node-cron": "^2.0.1",
"node-uuid": "^1.4.8",
"node-xlsx": "^0.15.0",
"nodemailer": "^6.3.0",
"pinyin": "^2.9.0",
"puppeteer": "^1.20.0",
"qr-image": "^3.2.0",
"sequelize": "^4.37.8",
"sequelize-cli": "^4.1.1",
"serve-favicon": "^2.4.5",
"sha1": "^1.1.1",
"sha256": "^0.2.0",
"socket.io": "^2.1.1",
"uuid": "^3.4.0"
},
"devDependencies": {
"element-theme": "^2.0.1",
"element-theme-chalk": "^2.4.0"
}
}
{
"name": "bigdata",
"version": "1.0.0",
"description": "h5framework",
"main": "main.js",
"scripts": {
"dev": "nodemon main.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"license": "ISC",
"dependencies": {
"@alicloud/pop-core": "^1.7.7",
"MD5": "^1.3.0",
"after": "^0.8.2",
"ali-oss": "^4.12.2",
"aliyun-api-gateway": "^1.1.6",
"axios": "^0.19.2",
"babel-polyfill": "^6.26.0",
"base64id": "^1.0.0",
"bluebird": "^3.5.1",
"body-parser": "^1.18.2",
"co": "^4.6.0",
"connect-redis": "^3.3.3",
"continuation-local-storage": "^3.2.1",
"cookie-parser": "^1.4.3",
"crypto": "^1.0.1",
"crypto-js": "^3.1.9-1",
"ejs": "^2.5.8",
"element-ui": "^2.4.0",
"engine.io-parser": "^2.1.2",
"errorhandler": "^1.5.0",
"exif-js": "^2.3.0",
"express": "^4.16.2",
"express-session": "^1.15.6",
"gm": "^1.23.1",
"marked": "^0.7.0",
"method-override": "^2.3.10",
"morgan": "^1.9.0",
"multer": "^1.3.0",
"mysql2": "^1.5.3",
"node-cron": "^2.0.1",
"node-uuid": "^1.4.8",
"node-xlsx": "^0.15.0",
"nodemailer": "^6.3.0",
"pinyin": "^2.9.0",
"puppeteer": "^1.20.0",
"qr-image": "^3.2.0",
"sequelize": "^4.37.8",
"sequelize-cli": "^4.1.1",
"serve-favicon": "^2.4.5",
"sha1": "^1.1.1",
"sha256": "^0.2.0",
"socket.io": "^2.1.1",
"uuid": "^3.4.0"
},
"devDependencies": {
"element-theme": "^2.0.1",
"element-theme-chalk": "^2.4.0"
}
}
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