Commit eb24f1f5 by 宋毅

tj

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