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 {
async refQuery(qobj,queryobj,req) {
if(qobj.refwhere){
qobj.refwhere.app_id=req.appid;
qobj.refwhere.company_id=req.tanentid;
qobj.refwhere.company_id=req.tocompanyid;
}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);
......@@ -74,8 +74,8 @@ class CtlBase {
}
}
if (req && req.tanentid) {//设置默认的公司id
qobj.company_id = req.tanentid;
if (req && req.tocompanyid) {//设置默认的公司id
qobj.company_id = req.tocompanyid;
// qobj.owner_id=req.tanentid;
}
var rd = await this.service.create(qobj,queryobj,req);
......@@ -158,15 +158,15 @@ class CtlBase {
//只要当前APP支持saas,并且非平台那么就设置
if (req.session.app && req.session.app.id != settings.platformid) {
if (req.session.app.isSaas && tocompany) {
req.tanentid = tocompany.id;
pobj.tanentid = tocompany.id;
req.tocompanyid = tocompany.id;
pobj.tocompanyid = tocompany.id;
} else {
req.tanentid = null;
pobj.tanentid = null;
req.tocompanyid = null;
pobj.tocompanyid = null;
}
} else {
req.tanentid = settings.platformcompanyid;
pobj.tanentid = settings.platformcompanyid;
req.tocompanyid = settings.platformcompanyid;
pobj.tocompanyid = settings.platformcompanyid;
}
}
......
......@@ -10,12 +10,12 @@ class AuthCtl extends CtlBase{
}
async saveAuths(qobj,query,req){
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);
}
async findAuthsByRole(qobj,query,req){
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);
}
}
......
......@@ -119,7 +119,7 @@ class UserCtl extends CtlBase {
fmuser.owner_id=settings.platformid;
}else{//否则 todo
if(!fmuser.owner_id && req.session.tocompany){
fmuser.owner_id=req.tanentid;
fmuser.owner_id=req.tocompanyid;
}
}
var ruser = await this.service.register(fmuser);
......@@ -143,7 +143,7 @@ class UserCtl extends CtlBase {
//管理员新增用户,设置默认密码
async create(pobj, queryobj, req) {
pobj.appid = req.appid;
pobj.owner_id=req.tanentid;
pobj.owner_id=req.tocompanyid;
//新增用户时,获取当前用户的租户id
pobj.tanentor_id=req.session.user.tanentor_id;
var rtn=await this.service.createUser(pobj);
......@@ -177,6 +177,8 @@ class UserCtl extends CtlBase {
// }
//非开放平台登录方法
async goLoginForApp(p,q,req){
//判断应用的类型,如果是非UI应用
//那么需要直接进入当前应用为上下文
var app=p;
var appid=app.id;
var jumpUrl = app.authUrl;
......@@ -194,6 +196,7 @@ class UserCtl extends CtlBase {
if (existedUser != null) {
await this.cacheManager["OpenCodeCache"].cache(req.session.id, existedUser, 60);
jumpUrl = jumpUrl + "?code=" + req.session.id;
//如果非web应用,直接进入后台
return system.getResult({ user: existedUser, jumpUrl: jumpUrl });
}else {
return system.getResultFail(-1, "账号或密码有误.");
......@@ -209,9 +212,16 @@ class UserCtl extends CtlBase {
} else{
pobj.u.isNavto=false;
}
//登录其它应用,是当前应用的用户要进入其它应用,上下文是当前应用,用户是当前应用的用户
//这种场景是重用目标应用时,比如管理平台重用
//非重用目标应用,需要切换为目标应用的用户
//而要进入其它应用切换身份,需要在设置上下文时,设为目标应用的ID
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进入,所以是自主登录
pobj.u.owner_id=pobj.tanentid;
pobj.u.owner_id=pobj.tocompanyid;
}
var existedUser = await this.service.getUserByUserNamePwd(pobj.u);
if (existedUser != null) {
......@@ -219,6 +229,7 @@ class UserCtl extends CtlBase {
await this.cacheManager["OpenCodeCache"].cache(req.session.id, existedUser, 60);
jumpUrl = jumpUrl + "?code=" + req.session.id;
if (req.session.toapp) {
//srcKey是进入到平台管理后,显示来源APP的信息;进入其它应用时,也传递以备后用
jumpUrl = jumpUrl + "&srcKey=" + req.session.app.appkey;
}
} else {
......
......@@ -29,7 +29,7 @@ class MetaCtl extends CtlBase {
if (!appkey) {
appkey = settings.appKey;
//为了查询权限
req.tanentid=settings.platformcompanyid;
req.tocompanyid=settings.platformcompanyid;
}
var app = await this.appS.getApp(appkey);
var rs = await this.getRsConfig2(null, req);
......@@ -85,7 +85,7 @@ class MetaCtl extends CtlBase {
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 => {
if (r.authstrs && r.authstrs != "") {
return r.authstrs;
......@@ -147,7 +147,7 @@ class MetaCtl extends CtlBase {
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 => {
if (r.authstrs && r.authstrs != "") {
if (r.codepath) {
......@@ -199,7 +199,7 @@ class MetaCtl extends CtlBase {
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 => {
if (r.authstrs && r.authstrs != "") {
if (r.codepath) {
......@@ -385,7 +385,7 @@ class MetaCtl extends CtlBase {
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 => {
if (r.authstrs && r.authstrs != "") {
if (r.codepath) {
......
......@@ -16,7 +16,7 @@ class RoleDao extends Dao{
// // }
// }
w["app_id"]=obj.appid;
w["company_id"]=obj.tanentid;
w["company_id"]=obj.tocompanyid;
return w;
}
extraModelFilter(){
......
......@@ -71,7 +71,7 @@ class UserDao extends Dao{
if(obj.codepath && obj.codepath!=""){
if(obj.codepath.indexOf("appuser")>0 || obj.codepath.indexOf("organization")>0){//说明是应用管理员的查询
w["app_id"]=obj.appid;
w["owner_id"]=obj.tanentid;
w["owner_id"]=obj.tocompanyid;
}
}
if(linkAttrs.length>0){
......
......@@ -15,7 +15,7 @@ class PConfigDao extends Dao{
// // }
// }
w["app_id"]=obj.appid;
w["company_id"]=obj.tanentid;
w["company_id"]=obj.tocompanyid;
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