Commit c540810d by 蒋勇

d

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