Commit c540810d by 蒋勇

d

parent f63628d0
...@@ -3,19 +3,18 @@ const http = require("http") ...@@ -3,19 +3,18 @@ const http = require("http")
const querystring = require('querystring'); const querystring = require('querystring');
var settings=require("../../../../config/settings"); var settings=require("../../../../config/settings");
const CtlBase = require("../../ctl.base"); const CtlBase = require("../../ctl.base");
const logCtl = system.getObject("web.common.oplogCtl");
class AuthCtl extends CtlBase{ class AuthCtl extends CtlBase{
constructor(){ constructor(){
super("auth",CtlBase.getServiceName(AuthCtl)); super("auth",CtlBase.getServiceName(AuthCtl));
} }
async saveAuths(qobj,query,req){ async saveAuths(pobj,query,req){
var auths=qobj.aus; var auths=pobj.auths;
var xrtn=await this.service.saveAuths(auths,req.appid,req.tocompanyid); var xrtn=await this.service.saveAuths(auths,pobj.app_id,pobj.company_id);
return system.getResult(xrtn); return system.getResult(xrtn);
} }
async findAuthsByRole(qobj,query,req){ async findAuthsByRoles(pobj,query,req){
var rolecodestrs=qobj.rolecode; var roleids=pobj.roleids;
var xrtn=await this.service.findAuthsByRole(rolecodestrs,req.appid,req.tocompanyid); var xrtn=await this.service.findAuthsByRole(roleids,pobj.app_id,pobj.company_id);
return system.getResult(xrtn); return system.getResult(xrtn);
} }
} }
......
...@@ -5,12 +5,12 @@ class AuthService extends ServiceBase{ ...@@ -5,12 +5,12 @@ class AuthService extends ServiceBase{
super("auth",ServiceBase.getDaoName(AuthService)); super("auth",ServiceBase.getDaoName(AuthService));
} }
//字符串数组参数 //字符串数组参数
async findAuthsByRole(rolecodestr,appid,comid){ async findAuthsByRole(roleids,appid,comid){
//{where:{id:{[this.db.Op.in]:ids}}} //{where:{id:{[this.db.Op.in]:ids}}}
//var newattrs=rolecodestr.split(","); //var newattrs=rolecodestr.split(",");
var aths=await this.dao.model.findAll({ var aths=await this.dao.model.findAll({
attributes:["bizcode","authstrs","codepath"], attributes:["bizcode","authstrs","codepath"],
where:{rolecode:{[this.db.Op.in]:rolecodestr},app_id:appid,company_id:comid}}); where:{role_id:{[this.db.Op.in]:roleids}}});
return aths; return aths;
} }
async saveAuths(auths,appid,cmid){ async saveAuths(auths,appid,cmid){
...@@ -25,17 +25,17 @@ class AuthService extends ServiceBase{ ...@@ -25,17 +25,17 @@ class AuthService extends ServiceBase{
tmpAuth.company_id=cmid; tmpAuth.company_id=cmid;
var objrtn=await self.dao.model.findOrCreate({ var objrtn=await self.dao.model.findOrCreate({
defaults:tmpAuth, defaults:tmpAuth,
where:{rolecode:tmpAuth.rolecode,bizcode:tmpAuth.bizcode},//注意这里bizcode存储的是节点的code值 where:{role_id:tmpAuth.role_id,bizcode:tmpAuth.bizcode},//注意这里bizcode存储的是节点的code值
transaction:t, transaction:t,
}); });
console.log("vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv"); console.log("vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv");
console.log(objrtn); console.log(objrtn);
if(!objrtn[1].created){ if(!objrtn[1].created){
//就执行更新操作 //就执行更新操作
await objrtn[0].update(tmpAuth,{where:{rolecode:tmpAuth.rolecode,bizcode:tmpAuth.bizcode,app_id:tmpAuth.app_id},transaction:t}) await objrtn[0].update(tmpAuth,{where:{role_id:tmpAuth.role_id,bizcode:tmpAuth.bizcode},transaction:t})
} }
} }
var aths=await self.dao.model.findAll({where:{rolecode:tmpAuth.rolecode,app_id:tmpAuth.app_id},transaction:t}); var aths=await self.dao.model.findAll({where:{role_id:tmpAuth.role_id,app_id:tmpAuth.app_id},transaction:t});
return aths; return aths;
}); });
} }
......
...@@ -88,16 +88,16 @@ class AppService extends ServiceBase { ...@@ -88,16 +88,16 @@ class AppService extends ServiceBase {
funcobjs.forEach((item) => { funcobjs.forEach((item) => {
if (item.children) { if (item.children) {
if(parentfunc){ if(parentfunc){
item.bizCode=parentfunc.bizCode+"/"+item.name item.codepath=parentfunc.codepath+"/"+item.name
}else{ }else{
item.bizCode=item.name item.codepath=item.name
} }
this.translateWithBizCode(item.children,item) this.translateWithBizCode(item.children,item)
} else { } else {
if(parentfunc){ if(parentfunc){
item.bizCode=parentfunc.bizCode+"/"+item.name item.codepath=parentfunc.codepath+"/"+item.name
}else{ }else{
item.bizCode=item.name item.codepath=item.name
} }
} }
}) })
......
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