Commit 5f811832 by 王昆

gsb

parent 231ca77d
...@@ -36,7 +36,22 @@ class AuthDao extends Dao { ...@@ -36,7 +36,22 @@ class AuthDao extends Dao {
if(params.saas_id) { if(params.saas_id) {
sql.push("AND t1.saas_id = :saas_id"); sql.push("AND t1.saas_id = :saas_id");
} }
if(params.authIds) {
sql.push("AND t1.id IN (:authIds)");
}
return this.customQuery(sql.join(" "), params); return this.customQuery(sql.join(" "), params);
} }
async byIds(ids) {
if(!ids || ids.length == 0) {
return [];
}
let sql = [];
sql.push("SELECT");
sql.push("t1.id, t1.`pid`, t1.`name`, t1.`icon`, t1.`path`");
sql.push("FROM uc_auth t1");
sql.push("WHERE t1.id IN (:ids)");
return this.customQuery(sql.join(" "), {ids: ids});
}
} }
module.exports = AuthDao; module.exports = AuthDao;
\ No newline at end of file
...@@ -99,6 +99,10 @@ class AuthService extends ServiceBase { ...@@ -99,6 +99,10 @@ class AuthService extends ServiceBase {
async byRoleIds(params) { async byRoleIds(params) {
return await this.dao.byRoleIds(params); return await this.dao.byRoleIds(params);
} }
async byIds(params) {
return await this.dao.byIds(params);
}
async menuByRoleIds(params) { async menuByRoleIds(params) {
params.menuType = 1; params.menuType = 1;
let all = await this.byRoleIds(params); let all = await this.byRoleIds(params);
...@@ -106,23 +110,27 @@ class AuthService extends ServiceBase { ...@@ -106,23 +110,27 @@ class AuthService extends ServiceBase {
return []; return [];
} }
let pmenus = []; let pids = [];
let pmenuMap = {};
for (let item of all) { for (let item of all) {
if (item.pid === 0) { if (item.pid === 0) {
pmenus.push(item); pids.push(item.id);
pmenuMap[item.id] = item; } else {
pids.push(item.pid);
} }
} }
let pmenuMap = {};
let pmenus = await this.byIds(pids);
for(let p of pmenus) {
pmenuMap[p.id] = p;
}
for (let item of all) { for (let item of all) {
let pid = item.pid; let pid = item.pid;
if (pid === 0) { if (pid === 0) {
continue; continue;
} }
let pmenu = pmenuMap[pid]; let pmenu = pmenuMap[pid];
if (!pmenu) { if (!pmenu) {
continue; continue;
} }
......
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