...
|
...
|
@@ -25,7 +25,11 @@ var errorMessage = { |
|
|
util.setLogger(res.app.logger);
|
|
|
var options = {
|
|
|
url:oldService.login,
|
|
|
form:'["'+user+'","'+password+'",'+WEBSITE+']'//'["zhiyuan","lzy111111",1]'//
|
|
|
form:{
|
|
|
account:user,
|
|
|
password:password,
|
|
|
website:WEBSITE
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//调用登陆
|
...
|
...
|
@@ -34,9 +38,8 @@ var errorMessage = { |
|
|
res.json(errorMessage);
|
|
|
return;
|
|
|
} else {
|
|
|
console.log(ret);
|
|
|
//调用菜单
|
|
|
_callGetMenu(ret.data.pid,ret.data.role_id,function(err,data){
|
|
|
_callGetMenu(ret.data.pid,function(err,data){
|
|
|
if(err) {
|
|
|
res.json(errorMessage);
|
|
|
} else {
|
...
|
...
|
@@ -44,11 +47,10 @@ var errorMessage = { |
|
|
var userInfo = {
|
|
|
auth:userData,
|
|
|
menu:data.menu,
|
|
|
allRight:data.allRight
|
|
|
noRight:data.noRight
|
|
|
}
|
|
|
userInfo.auth.uid = userData.pid;
|
|
|
userInfo.auth.name = userData.truename;
|
|
|
|
|
|
res.json({
|
|
|
code:20003,
|
|
|
data:userInfo
|
...
|
...
|
@@ -64,23 +66,26 @@ var errorMessage = { |
|
|
* @param {Number} pid 操作员ID
|
|
|
* @param {Function} callback 回调
|
|
|
*/
|
|
|
function _callGetMenu(pid,roleid,callback) {
|
|
|
function _callGetMenu(pid,callback) {
|
|
|
var options = {
|
|
|
url:oldService.getResourceByPid,
|
|
|
form:'['+pid+','+roleid+','+WEBSITE+']'
|
|
|
form:{
|
|
|
pid:pid,
|
|
|
website:WEBSITE
|
|
|
}
|
|
|
}
|
|
|
console.log(options);
|
|
|
|
|
|
util.httpCall(options,function(err,ret){
|
|
|
if(err) {
|
|
|
callback(err);
|
|
|
} else {
|
|
|
var menuData = {menu:[],right:{}};
|
|
|
if(ret.data) {
|
|
|
if(ret.data && ret.data.length>0) {
|
|
|
menuData = _makeMenu(ret.data);
|
|
|
}
|
|
|
|
|
|
_getAllRight(function(ret){
|
|
|
menuData.allRight = ret;
|
|
|
_getAllMenu(function(ret){
|
|
|
menuData.noRight = filterRight(ret,menuData);
|
|
|
delete menuData.right;
|
|
|
callback(null,menuData);
|
|
|
});
|
|
|
|
...
|
...
|
@@ -97,17 +102,14 @@ console.log(options); |
|
|
function filterRight(ret,menuData) {
|
|
|
var noRight = {};
|
|
|
//匹配没有权限
|
|
|
for(var key in ret){
|
|
|
var item=ret[key];
|
|
|
for(var i in item.sub){
|
|
|
var v=item.sub[i];
|
|
|
if(v.menu_url!=='') {
|
|
|
if(!menuData.right[v.menu_url]) {
|
|
|
noRight[v.menu_url] = true;
|
|
|
}
|
|
|
_.forEach(ret,function(v,k){
|
|
|
if(v.module_url!=='') {
|
|
|
if(!menuData.right[v.module_url]) {
|
|
|
noRight[v.module_url] = true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
return noRight;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -118,7 +120,7 @@ function filterRight(ret,menuData) { |
|
|
function _getAllMenu (callback) {
|
|
|
var options = {
|
|
|
url:oldService.getAllResByWebsite+'?website='+WEBSITE+'&sort=',
|
|
|
form:'['+WEBSITE+']'
|
|
|
method:'GET'
|
|
|
}
|
|
|
|
|
|
util.httpCall(options,function(err,ret){
|
...
|
...
|
@@ -138,94 +140,30 @@ function _getAllMenu (callback) { |
|
|
function _makeMenu (data) {
|
|
|
var menu = [];
|
|
|
var right = {};
|
|
|
for(var key in data){
|
|
|
|
|
|
var v=data[key];
|
|
|
var item = {
|
|
|
title:v.menu_name,
|
|
|
_.forEach(data,function(v){
|
|
|
var item = {
|
|
|
title:v.resource_name,
|
|
|
}
|
|
|
if(v.parent_id === "0") {
|
|
|
item.parent = 'menu-template';
|
|
|
var itemSubs = [];
|
|
|
_.forEach(v.sub,function(val) {
|
|
|
var sub = {
|
|
|
title:val.menu_name,
|
|
|
href:val.menu_url,
|
|
|
title:val.resource_name,
|
|
|
href:val.module_url,
|
|
|
icon: 'list-alt'
|
|
|
}
|
|
|
right[val.menu_url] = true;
|
|
|
right[val.module_url] = true;
|
|
|
itemSubs.push(sub);
|
|
|
});
|
|
|
|
|
|
item.menu = itemSubs;
|
|
|
}
|
|
|
menu.push(item);
|
|
|
}
|
|
|
// _.forEach(data,function(v){
|
|
|
// var item = {
|
|
|
// title:v.menu_name,
|
|
|
// }
|
|
|
// if(v.parent_id === "0") {
|
|
|
// item.parent = 'menu-template';
|
|
|
// var itemSubs = [];
|
|
|
// _.forEach(v.sub,function(val) {
|
|
|
// console.log(v.sub);
|
|
|
// var sub = {
|
|
|
// title:val.menu_name,
|
|
|
// href:val.menu_url,
|
|
|
// icon: 'list-alt'
|
|
|
// }
|
|
|
// right[val.menu_url] = true;
|
|
|
// itemSubs.push(sub);
|
|
|
// });
|
|
|
|
|
|
// item.menu = itemSubs;
|
|
|
// }
|
|
|
// menu.push(item);
|
|
|
// });
|
|
|
});
|
|
|
|
|
|
return {
|
|
|
menu:menu,
|
|
|
right:right
|
|
|
};
|
|
|
} |
|
|
|
|
|
/**
|
|
|
* 验证权限
|
|
|
*/
|
|
|
exports.validateAuthor=function(pid,roleid,path,callback){
|
|
|
var options = {
|
|
|
url:oldService.isUsedMenuAuth,
|
|
|
form:'['+pid+','+roleid+', "'+path+'", "", "", '+WEBSITE+']'
|
|
|
}
|
|
|
util.httpCall(options,function(err,ret){
|
|
|
if(err) {
|
|
|
callback({});
|
|
|
} else {
|
|
|
callback(ret.data);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
function _getAllRight(callback){
|
|
|
var options = {
|
|
|
url:oldService.allRight,
|
|
|
form:'[false]'
|
|
|
}
|
|
|
console.log(options);
|
|
|
util.httpCall(options,function(err,ret){
|
|
|
if(err) {
|
|
|
callback({});
|
|
|
} else {
|
|
|
var map={};
|
|
|
ret.data.forEach(function(data){
|
|
|
console.log(data);
|
|
|
if(data.platform_id==WEBSITE){
|
|
|
map[data.path]=true;
|
|
|
}
|
|
|
|
|
|
});
|
|
|
callback(map);
|
|
|
}
|
|
|
});
|
|
|
} |
...
|
...
|
|