Commit 7d533bab by 蒋勇

d

parent 24e272c4
...@@ -7,6 +7,11 @@ class CtlBase { ...@@ -7,6 +7,11 @@ class CtlBase {
this.service = system.getObject("service." + gname + "." + sname); this.service = system.getObject("service." + gname + "." + sname);
this.cacheManager = system.getObject("db.common.cacheManager"); this.cacheManager = system.getObject("db.common.cacheManager");
} }
getUUID() {
var uuid = uuidv4();
var u = uuid.replace(/\-/g, "");
return u;
}
static getServiceName(ClassObj) { static getServiceName(ClassObj) {
return ClassObj["name"].substring(0, ClassObj["name"].lastIndexOf("Ctl")).toLowerCase() + "Sve"; return ClassObj["name"].substring(0, ClassObj["name"].lastIndexOf("Ctl")).toLowerCase() + "Sve";
...@@ -50,7 +55,8 @@ class CtlBase { ...@@ -50,7 +55,8 @@ class CtlBase {
credid: req.headers["x-credential-identifier"], credid: req.headers["x-credential-identifier"],
regrole:req.headers["xregrole"], regrole:req.headers["xregrole"],
bizpath:req.headers["xbizpath"], bizpath:req.headers["xbizpath"],
codetitle:req.headers["codetitle"], codetitle:req.headers["xcodename"],
codetitle:req.headers["xcodetitle"]?decodeURI(req.headers["xcodetitle"]):'',
} }
if(!req.xctx.appkey){ if(!req.xctx.appkey){
return [-200,"请求头缺少应用x-app-key"] return [-200,"请求头缺少应用x-app-key"]
...@@ -97,8 +103,31 @@ class CtlBase { ...@@ -97,8 +103,31 @@ class CtlBase {
// } // }
//req.session=redis缓存的上下文对象 //req.session=redis缓存的上下文对象
var rtn = await this[methodname](pobj, query, req); var rtn = await this[methodname](pobj, query, req);
rtn.requestId=this.getUUID()
req.params.param=pobj
system.execLogs(req.xctx.codetitle,req.params,null,rtn,null).then(res=>{
if(res && res.status==1){
console.log("log.....success")
}else{
console.log("log.....fail")
}
}).catch(e=>{
console.log("log.....fail")
})
return rtn; return rtn;
} catch (e) { } catch (e) {
let rtn={}
rtn.requestId=this.getUUID()
req.params.param=pobj
system.execLogs(req.xctx.codetitle,req.params,null,rtn,e).then(res=>{
if(res && res.status==1){
console.log("log.....success")
}else{
console.log("log.....fail")
}
}).catch(e=>{
console.log("log.....fail")
})
console.log(e.stack, "出现异常,请联系管理员......."); console.log(e.stack, "出现异常,请联系管理员.......");
return system.getResultFail(-200, "出现异常,请联系管理员"); return system.getResultFail(-200, "出现异常,请联系管理员");
} }
......
...@@ -277,10 +277,18 @@ class System { ...@@ -277,10 +277,18 @@ class System {
errorInfo: errorInfo,//错误信息 errorInfo: errorInfo,//错误信息
requestId: resultInfo.requestId || "" requestId: resultInfo.requestId || ""
} }
}; };
this.postJsonTypeReq(reqUrl,param).then(res=>{ let P=new Promise((resv,rej)=>{
console.log(res) this.postJsonTypeReq(reqUrl,param).then(res=>{
}); if(res.statusCode==200){
resv(res.data)
}else{
rej(null)
}
});
})
return P
} }
} }
......
...@@ -60,6 +60,7 @@ var settings = { ...@@ -60,6 +60,7 @@ var settings = {
database: function () { database: function () {
if (this.env == "dev") { if (this.env == "dev") {
var localsettings = require("./localsettings"); var localsettings = require("./localsettings");
console.log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>....")
return localsettings.database; return localsettings.database;
} else { } else {
return { return {
......
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