Commit 5f811832 by 王昆

gsb

parent 231ca77d
......@@ -36,7 +36,22 @@ class AuthDao extends Dao {
if(params.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);
}
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;
\ No newline at end of file
......@@ -99,6 +99,10 @@ class AuthService extends ServiceBase {
async byRoleIds(params) {
return await this.dao.byRoleIds(params);
}
async byIds(params) {
return await this.dao.byIds(params);
}
async menuByRoleIds(params) {
params.menuType = 1;
let all = await this.byRoleIds(params);
......@@ -106,23 +110,27 @@ class AuthService extends ServiceBase {
return [];
}
let pmenus = [];
let pmenuMap = {};
let pids = [];
for (let item of all) {
if (item.pid === 0) {
pmenus.push(item);
pmenuMap[item.id] = item;
pids.push(item.id);
} 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) {
let pid = item.pid;
if (pid === 0) {
continue;
}
let pmenu = pmenuMap[pid];
if (!pmenu) {
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