Commit f63628d0 by 蒋勇

d

parent caaaa7ee
......@@ -40,19 +40,20 @@ class CtlBase {
//当自由用户注册时,需要根据前端传来的companykey,查询出公司,给companyid赋值
req.xctx = {
appkey: req.headers["xappkey"],//用于系统管理区分应用,比如角色
fromappkey:req.headers["xfromappkey"],//来源APP,如果没有来源与appkey相同
companyid: custtags?custtags[0].split("_")[1]:null,
fromcompanykey:req.headers["xfromcompanykey"],//专用于自由用户注册,自由用户用于一定属于某个存在的公司
password: custtags?custtags[lastindex].split("_")[1]:null,
username: req.headers["x-consumer-username"],
userid:req.headers["x-consumer-custom-id"],
credid: req.headers["x-credential-identifier"],
companykey:req.headers["xcompanykey"],//专用于自由用户注册,自由用户用于一定属于某个存在的公司
regrole:req.headers["xregrole"],
bizpath:req.headers["xbizpath"],
}
if(!req.xctx.appkey){
return [-200,"请求头缺少应用x-app-key"]
}else{
let app=await this.cacheManager["AppCache"].cache(req.xctx.appkey);
let app=await this.cacheManager["AppCache"].cache(req.xctx.fromappkey);
req.xctx.appid=app.id;
if(!pobj.app_id){
pobj.app_id=app.id;//传递参数对象里注入app_id
......@@ -63,8 +64,8 @@ class CtlBase {
// if(!req.xctx.companyid && !req.xctx.companykey){
// return [-200,"请求头缺少应用x-app-key"]
// }
if(!req.xctx.companyid && req.xctx.companykey && req.xctx.companykey!="null"){
let comptmp=await this.cacheManager["CompanyCache"].cache(req.xctx.companykey);
if(!req.xctx.companyid && req.xctx.fromcompanykey && req.xctx.fromcompanykey!="null"){
let comptmp=await this.cacheManager["CompanyCache"].cache(req.xctx.fromcompanykey);
req.xctx.companyid=comptmp.id;
}
if(req.xctx.companyid){//在请求传递数据对象注入公司id
......
......@@ -46,7 +46,10 @@ class DbFactory{
this.db.models.user.belongsTo(this.db.models.app,{constraints: false,});
this.db.models.role.belongsTo(this.db.models.app, {constraints: false,});
this.db.models.org.belongsTo(this.db.models.app,{constraints: false,});
this.db.models.auth.belongsTo(this.db.models.app,{constraints: false,});
this.db.models.auth.belongsTo(this.db.models.app,{constraints: false,});
this.db.models.auth.belongsTo(this.db.models.company,{constraints: false,});
this.db.models.auth.belongsTo(this.db.models.role,{constraints: false,});
this.db.models.app.belongsTo(this.db.models.user,{as:"creator",constraints: false,});
......@@ -54,7 +57,7 @@ class DbFactory{
this.db.models.user.belongsTo(this.db.models.company,{constraints: false,});
this.db.models.role.belongsTo(this.db.models.company, {constraints: false,});
this.db.models.org.belongsTo(this.db.models.company,{constraints: false,});
this.db.models.auth.belongsTo(this.db.models.company,{constraints: false,});
this.db.models.route.belongsTo(this.db.models.app,{constraints: false,});
this.db.models.plugin.belongsTo(this.db.models.app,{constraints: false,});
......
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