Commit 325f757a by 蒋勇

d

parent 7bf4c33d
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/bigdata/main.js"
}
]
}
\ No newline at end of file
...@@ -47,9 +47,9 @@ class CtlBase { ...@@ -47,9 +47,9 @@ class CtlBase {
async refQuery(qobj,queryobj,req) { async refQuery(qobj,queryobj,req) {
if(qobj.refwhere){ if(qobj.refwhere){
qobj.refwhere.app_id=req.appid; qobj.refwhere.app_id=req.appid;
qobj.refwhere.company_id=req.tanentid; qobj.refwhere.company_id=req.tocompanyid;
}else{ }else{
qobj.refwhere = { app_id: req.appid,company_id:req.tanentid}; qobj.refwhere = { app_id: req.appid,company_id:req.tocompanyid};
} }
var rd = await this.service.refQuery(qobj); var rd = await this.service.refQuery(qobj);
...@@ -74,8 +74,8 @@ class CtlBase { ...@@ -74,8 +74,8 @@ class CtlBase {
} }
} }
if (req && req.tanentid) {//设置默认的公司id if (req && req.tocompanyid) {//设置默认的公司id
qobj.company_id = req.tanentid; qobj.company_id = req.tocompanyid;
// qobj.owner_id=req.tanentid; // qobj.owner_id=req.tanentid;
} }
var rd = await this.service.create(qobj,queryobj,req); var rd = await this.service.create(qobj,queryobj,req);
...@@ -158,15 +158,15 @@ class CtlBase { ...@@ -158,15 +158,15 @@ class CtlBase {
//只要当前APP支持saas,并且非平台那么就设置 //只要当前APP支持saas,并且非平台那么就设置
if (req.session.app && req.session.app.id != settings.platformid) { if (req.session.app && req.session.app.id != settings.platformid) {
if (req.session.app.isSaas && tocompany) { if (req.session.app.isSaas && tocompany) {
req.tanentid = tocompany.id; req.tocompanyid = tocompany.id;
pobj.tanentid = tocompany.id; pobj.tocompanyid = tocompany.id;
} else { } else {
req.tanentid = null; req.tocompanyid = null;
pobj.tanentid = null; pobj.tocompanyid = null;
} }
} else { } else {
req.tanentid = settings.platformcompanyid; req.tocompanyid = settings.platformcompanyid;
pobj.tanentid = settings.platformcompanyid; pobj.tocompanyid = settings.platformcompanyid;
} }
} }
......
...@@ -10,12 +10,12 @@ class AuthCtl extends CtlBase{ ...@@ -10,12 +10,12 @@ class AuthCtl extends CtlBase{
} }
async saveAuths(qobj,query,req){ async saveAuths(qobj,query,req){
var auths=qobj.aus; var auths=qobj.aus;
var xrtn=await this.service.saveAuths(auths,req.appid,req.tanentid); var xrtn=await this.service.saveAuths(auths,req.appid,req.tocompanyid);
return system.getResult(xrtn); return system.getResult(xrtn);
} }
async findAuthsByRole(qobj,query,req){ async findAuthsByRole(qobj,query,req){
var rolecodestrs=qobj.rolecode; var rolecodestrs=qobj.rolecode;
var xrtn=await this.service.findAuthsByRole(rolecodestrs,req.appid,req.tanentid); var xrtn=await this.service.findAuthsByRole(rolecodestrs,req.appid,req.tocompanyid);
return system.getResult(xrtn); return system.getResult(xrtn);
} }
} }
......
...@@ -119,7 +119,7 @@ class UserCtl extends CtlBase { ...@@ -119,7 +119,7 @@ class UserCtl extends CtlBase {
fmuser.owner_id=settings.platformid; fmuser.owner_id=settings.platformid;
}else{//否则 todo }else{//否则 todo
if(!fmuser.owner_id && req.session.tocompany){ if(!fmuser.owner_id && req.session.tocompany){
fmuser.owner_id=req.tanentid; fmuser.owner_id=req.tocompanyid;
} }
} }
var ruser = await this.service.register(fmuser); var ruser = await this.service.register(fmuser);
...@@ -143,7 +143,7 @@ class UserCtl extends CtlBase { ...@@ -143,7 +143,7 @@ class UserCtl extends CtlBase {
//管理员新增用户,设置默认密码 //管理员新增用户,设置默认密码
async create(pobj, queryobj, req) { async create(pobj, queryobj, req) {
pobj.appid = req.appid; pobj.appid = req.appid;
pobj.owner_id=req.tanentid; pobj.owner_id=req.tocompanyid;
//新增用户时,获取当前用户的租户id //新增用户时,获取当前用户的租户id
pobj.tanentor_id=req.session.user.tanentor_id; pobj.tanentor_id=req.session.user.tanentor_id;
var rtn=await this.service.createUser(pobj); var rtn=await this.service.createUser(pobj);
...@@ -177,6 +177,8 @@ class UserCtl extends CtlBase { ...@@ -177,6 +177,8 @@ class UserCtl extends CtlBase {
// } // }
//非开放平台登录方法 //非开放平台登录方法
async goLoginForApp(p,q,req){ async goLoginForApp(p,q,req){
//判断应用的类型,如果是非UI应用
//那么需要直接进入当前应用为上下文
var app=p; var app=p;
var appid=app.id; var appid=app.id;
var jumpUrl = app.authUrl; var jumpUrl = app.authUrl;
...@@ -194,6 +196,7 @@ class UserCtl extends CtlBase { ...@@ -194,6 +196,7 @@ class UserCtl extends CtlBase {
if (existedUser != null) { if (existedUser != null) {
await this.cacheManager["OpenCodeCache"].cache(req.session.id, existedUser, 60); await this.cacheManager["OpenCodeCache"].cache(req.session.id, existedUser, 60);
jumpUrl = jumpUrl + "?code=" + req.session.id; jumpUrl = jumpUrl + "?code=" + req.session.id;
//如果非web应用,直接进入后台
return system.getResult({ user: existedUser, jumpUrl: jumpUrl }); return system.getResult({ user: existedUser, jumpUrl: jumpUrl });
}else { }else {
return system.getResultFail(-1, "账号或密码有误."); return system.getResultFail(-1, "账号或密码有误.");
...@@ -209,9 +212,16 @@ class UserCtl extends CtlBase { ...@@ -209,9 +212,16 @@ class UserCtl extends CtlBase {
} else{ } else{
pobj.u.isNavto=false; pobj.u.isNavto=false;
} }
//登录其它应用,是当前应用的用户要进入其它应用,上下文是当前应用,用户是当前应用的用户
//这种场景是重用目标应用时,比如管理平台重用
//非重用目标应用,需要切换为目标应用的用户
//而要进入其它应用切换身份,需要在设置上下文时,设为目标应用的ID
pobj.u.app_id = appid; pobj.u.app_id = appid;
if(req.session.toapp && req.session.toapp.id!=settings.platformid){
pobj.u.app_id=req.session.toapp.id;
}
if(!pobj.u.owner_id){//说明不是从平台界面,利用go进入,所以是自主登录 if(!pobj.u.owner_id){//说明不是从平台界面,利用go进入,所以是自主登录
pobj.u.owner_id=pobj.tanentid; pobj.u.owner_id=pobj.tocompanyid;
} }
var existedUser = await this.service.getUserByUserNamePwd(pobj.u); var existedUser = await this.service.getUserByUserNamePwd(pobj.u);
if (existedUser != null) { if (existedUser != null) {
...@@ -219,6 +229,7 @@ class UserCtl extends CtlBase { ...@@ -219,6 +229,7 @@ class UserCtl extends CtlBase {
await this.cacheManager["OpenCodeCache"].cache(req.session.id, existedUser, 60); await this.cacheManager["OpenCodeCache"].cache(req.session.id, existedUser, 60);
jumpUrl = jumpUrl + "?code=" + req.session.id; jumpUrl = jumpUrl + "?code=" + req.session.id;
if (req.session.toapp) { if (req.session.toapp) {
//srcKey是进入到平台管理后,显示来源APP的信息;进入其它应用时,也传递以备后用
jumpUrl = jumpUrl + "&srcKey=" + req.session.app.appkey; jumpUrl = jumpUrl + "&srcKey=" + req.session.app.appkey;
} }
} else { } else {
......
...@@ -29,7 +29,7 @@ class MetaCtl extends CtlBase { ...@@ -29,7 +29,7 @@ class MetaCtl extends CtlBase {
if (!appkey) { if (!appkey) {
appkey = settings.appKey; appkey = settings.appKey;
//为了查询权限 //为了查询权限
req.tanentid=settings.platformcompanyid; req.tocompanyid=settings.platformcompanyid;
} }
var app = await this.appS.getApp(appkey); var app = await this.appS.getApp(appkey);
var rs = await this.getRsConfig2(null, req); var rs = await this.getRsConfig2(null, req);
...@@ -85,7 +85,7 @@ class MetaCtl extends CtlBase { ...@@ -85,7 +85,7 @@ class MetaCtl extends CtlBase {
tmpRoles.push(r.code); tmpRoles.push(r.code);
}); });
//按照角色获取权限列表 //按照角色获取权限列表
var auths = await this.authS.findAuthsByRole(tmpRoles, req.session.user.app_id,req.tanentid); var auths = await this.authS.findAuthsByRole(tmpRoles, req.session.user.app_id,req.tocompanyid);
var codeauthattrs = auths.map(r => { var codeauthattrs = auths.map(r => {
if (r.authstrs && r.authstrs != "") { if (r.authstrs && r.authstrs != "") {
return r.authstrs; return r.authstrs;
...@@ -147,7 +147,7 @@ class MetaCtl extends CtlBase { ...@@ -147,7 +147,7 @@ class MetaCtl extends CtlBase {
tmpRoles.push(r.code); tmpRoles.push(r.code);
}); });
//按照角色获取权限列表 //按照角色获取权限列表
var auths = await this.authS.findAuthsByRole(tmpRoles, req.session.user.app_id,req.tanentid); var auths = await this.authS.findAuthsByRole(tmpRoles, req.session.user.app_id,req.tocompanyid);
var codepathattrs = auths.map(r => { var codepathattrs = auths.map(r => {
if (r.authstrs && r.authstrs != "") { if (r.authstrs && r.authstrs != "") {
if (r.codepath) { if (r.codepath) {
...@@ -199,7 +199,7 @@ class MetaCtl extends CtlBase { ...@@ -199,7 +199,7 @@ class MetaCtl extends CtlBase {
tmpRoles.push(r.code); tmpRoles.push(r.code);
}); });
//按照角色获取权限列表 //按照角色获取权限列表
var auths = await this.authS.findAuthsByRole(tmpRoles, req.session.user.app_id,req.tanentid); var auths = await this.authS.findAuthsByRole(tmpRoles, req.session.user.app_id,req.tocompanyid);
var codepathattrs = auths.map(r => { var codepathattrs = auths.map(r => {
if (r.authstrs && r.authstrs != "") { if (r.authstrs && r.authstrs != "") {
if (r.codepath) { if (r.codepath) {
...@@ -385,7 +385,7 @@ class MetaCtl extends CtlBase { ...@@ -385,7 +385,7 @@ class MetaCtl extends CtlBase {
tmpRoles.push(r.code); tmpRoles.push(r.code);
}); });
//按照角色获取权限列表 //按照角色获取权限列表
var auths = await this.authS.findAuthsByRole(tmpRoles, req.session.user.app_id,req.tanentid); var auths = await this.authS.findAuthsByRole(tmpRoles, req.session.user.app_id,req.tocompanyid);
var codepathattrs = auths.map(r => { var codepathattrs = auths.map(r => {
if (r.authstrs && r.authstrs != "") { if (r.authstrs && r.authstrs != "") {
if (r.codepath) { if (r.codepath) {
......
...@@ -16,7 +16,7 @@ class RoleDao extends Dao{ ...@@ -16,7 +16,7 @@ class RoleDao extends Dao{
// // } // // }
// } // }
w["app_id"]=obj.appid; w["app_id"]=obj.appid;
w["company_id"]=obj.tanentid; w["company_id"]=obj.tocompanyid;
return w; return w;
} }
extraModelFilter(){ extraModelFilter(){
......
...@@ -71,7 +71,7 @@ class UserDao extends Dao{ ...@@ -71,7 +71,7 @@ class UserDao extends Dao{
if(obj.codepath && obj.codepath!=""){ if(obj.codepath && obj.codepath!=""){
if(obj.codepath.indexOf("appuser")>0 || obj.codepath.indexOf("organization")>0){//说明是应用管理员的查询 if(obj.codepath.indexOf("appuser")>0 || obj.codepath.indexOf("organization")>0){//说明是应用管理员的查询
w["app_id"]=obj.appid; w["app_id"]=obj.appid;
w["owner_id"]=obj.tanentid; w["owner_id"]=obj.tocompanyid;
} }
} }
if(linkAttrs.length>0){ if(linkAttrs.length>0){
......
...@@ -15,7 +15,7 @@ class PConfigDao extends Dao{ ...@@ -15,7 +15,7 @@ class PConfigDao extends Dao{
// // } // // }
// } // }
w["app_id"]=obj.appid; w["app_id"]=obj.appid;
w["company_id"]=obj.tanentid; w["company_id"]=obj.tocompanyid;
return w; return w;
} }
} }
......
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