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: {
......
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