Example #1
0
 public List<Menu> getMenus(final String pid) {
   List<Menu> all = null;
   if (StringUtils.isBlank(pid)) {
     all = menuDao.list("from Menu where parent is null");
   } else {
     all = menuDao.list("from Menu where parent =?", pid);
   }
   eachMenu(all);
   return all;
 }
Example #2
0
 /**
  * 返回菜单树
  *
  * @return
  */
 public Menu getTreeMenus() {
   List<Menu> menus = menuDao.listAll();
   Menu root = getRootMenu(menus);
   CollectionSort.sortList(menus, "sno", true);
   eachMenu(menus, root);
   return root;
 }
Example #3
0
 /**
  * 用户所具有的菜单,关联权限
  *
  * @param userId
  * @return
  */
 @Transactional(readOnly = true)
 public List<Menu> getUserMenuObject(String userId, String roleId, String isAdmin) {
   List<Menu> menus = null;
   if (!"1".equals(isAdmin)) { // 非管理员
     String sql =
         "select * from ( select t01.* from t_cor_menu t01 join (\n"
             + "SELECT t4.resource_id from t_cor_user t1 join \n"
             + "t_cor_user_role t2 on t1.id_=t2.user_id\n"
             + "join t_cor_role t3 on t2.role_id=t3.id_\n"
             + "join t_cor_authority t4 on t4.role_id=t3.id_ where t1.id_=? and t3.enabled_='1' and t1.enabled_='1') t02 \n"
             + "on t01.resource_id=t02.resource_id) t  order by t.sno_ asc";
     menus = menuDao.listBySql(sql, userId);
   } else {
     menus = menuDao.listAll();
   }
   if (menus == null || menus.isEmpty()) {
     return null;
   }
   Menu root = getRootMenu(menus);
   eachMenu(menus, root);
   List<Menu> trees = root.getRows();
   CollectionSort.sortList(trees, "sno", true);
   return trees;
 }
Example #4
0
 /**
  * 保存
  *
  * @param menu
  * @return
  */
 public Menu saveMenu(Menu menu) {
   menu.setParent(menuDao.get(menu.getParent().getId()));
   menu.setCreatedDate(new Date());
   menu.setSno(menuDao.getMaxSno());
   return menuDao.save(menu);
 }
Example #5
0
 @Transactional(readOnly = false)
 public void updateSort(String[] ids, String pid) {
   for (int i = 0; i < ids.length; i++) {
     menuDao.updateParent(pid, i, ids[i]);
   }
 }