def initMenu(self, userName): """ 初始化菜单项目 """ Logger.info('MenuManagement.initMenu begin'); self.menuList = [] # 获取所有菜单项目 menu = DBAuthority.selectMenu(userName) for subMenu in menu: # 查找子菜单所属的主菜单 flg=True for menu in self.menuList: if subMenu["parentId"] == menu["id"]: menu["subMenu"].append(subMenu) flg=False; if flg: # 创建主菜单 temp = DBMenu.selectByMenuId(subMenu["parentId"]) menu = {} menu['id'] = temp['menuId'] menu['text'] = temp['text'] menu['url'] = temp['url'] menu['sort'] = temp['sort'] menu["subMenu"] = [] menu["subMenu"].append(subMenu) self.menuList.append(menu) self.menuList.sort(key=self.sort) # sorted(self.menuList,key=sort) ''' # 获取一级菜单项目 menu = DBAuthority.selectMenu(userName, 0) for item in menu: subMenu = DBAuthority.selectMenu(userName, item["id"]) menuItem = {}; menuItem["id"] = item["id"] menuItem["text"] = item["text"] menuItem["url"] = item["url"] menuItem["subMenu"] = subMenu self.menuList.append(menuItem) ''' # 整理菜单项目 for item in self.menuList: item['url'] = item['subMenu'][0]['url'] Logger.info('MenuManagement.initMenu end');
def selectAll(self): ''' 查询所有菜单项目 ''' value = DBMenu.selectAll() return value