Commit 5ef7ab6b authored by 张龙发's avatar 张龙发

还原获取菜单方法

parent 75e4395b
...@@ -30,33 +30,34 @@ public class MenuController extends Controller { ...@@ -30,33 +30,34 @@ public class MenuController extends Controller {
private MenuService menuService; private MenuService menuService;
/** /**
* 获取权限菜单 * 获取权限菜单
*/ */
public void index() { public void index() {
String username = this.getAttrForStr("username"); String username = this.getAttrForStr("username");
Integer userId = Db.queryInt(Db.getSql("getUserId"), username); Integer userId = Db.queryInt(Db.getSql("getUserId"), username);
List<System> systems = System.dao.template("getSystems", Kv.by("username", username)).find(); List<System> systems = System.dao.template("getSystems").find();
Kv kvSystems = CollectionUtil.toIntMap(systems, "ID"); Kv kvSystems = CollectionUtil.toIntMap(systems, "ID");
List<Menu> menus = null; List<Menu> menus = null;
if ("admin".equals(username)) { if ("admin".equals(username)) {
menus = Menu.dao.template("getMenus").find(); menus = Menu.dao.template("getMenus").find();
} else { } else {
menus = Menu.dao.template("getMenusByUser", Kv.by("userId", userId)).find(); menus = Menu.dao.template("getMenusByUser", Kv.by("userId", userId)).find();
} }
List<MenuStar> stars = MenuStar.dao.template("getMenuStar", userId).find(); List<MenuStar> stars = MenuStar.dao.template("getMenuStar", userId).find();
for (Menu menu : menus) { for (Menu menu : menus) {
System system = (System) kvSystems.get(menu.getSystemId()); System system = (System) kvSystems.get(menu.getSystemId());
if (system != null) { if (system != null) {
menu.put("system", system.getName()); menu.put("system", system.getName());
menu.put("url", system.getUrl()); menu.put("url", system.getUrl());
menu.put("star", exist(menu.getId(), stars)); menu.put("star", exist(menu.getId(), stars));
List<Menu> abilities = system.get("menus", new ArrayList<Menu>()); List<Menu> abilities = system.get("menus", new ArrayList<Menu>());
abilities.add(menu); abilities.add(menu);
system.put("menus", abilities); system.put("menus", abilities);
} }
} }
this.renderJson(Ret.ok("apps", systems)); this.renderJson(Ret.ok("apps", systems));
} }
/** /**
* 获取菜单列表 * 获取菜单列表
......
...@@ -38,11 +38,10 @@ select * from AS_USER where USERNAME=#para(0) ...@@ -38,11 +38,10 @@ select * from AS_USER where USERNAME=#para(0)
### 获取系统,应用菜单使用 ### 获取系统,应用菜单使用
#sql("getSystems") #sql("getSystems")
select sys.id as ID,sys.NAME as NAME,sys.TITLE as TITLE, sys.TYPE as TYPE, sys.URL as URL, sys.DESCRIPTION as DESCRIPTION select ID, NAME, TITLE, TYPE, URL, DESCRIPTION from AS_SYSTEM order by ID
from AS_SYSTEM sys left join as_menu me on sys.id=me.system_id where me.id in (select menu_id from as_role_menu where role_id in(select role_id from as_role_user where user_id =(select id from as_user where username='#(username)')))
group by sys.id,sys.NAME,sys.TITLE,sys.TYPE,sys.URL,sys.DESCRIPTION order by sys.ID
#end #end
### 获取系统 ### 获取系统
#sql("findSystemList") #sql("findSystemList")
select * from AS_SYSTEM t select * from AS_SYSTEM t
......
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