com.ruoyi.system.domain.SysMenu Java Examples
The following examples show how to use
com.ruoyi.system.domain.SysMenu.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SysMenuServiceImpl.java From supplierShop with MIT License | 6 votes |
/** * 根据角色ID查询菜单 * * @param role 角色对象 * @return 菜单列表 */ @Override public List<Ztree> roleMenuTreeData(SysRole role, Long userId) { Long roleId = role.getRoleId(); List<Ztree> ztrees = new ArrayList<Ztree>(); List<SysMenu> menuList = selectMenuAll(userId); if (StringUtils.isNotNull(roleId)) { List<String> roleMenuList = menuMapper.selectMenuTree(roleId); ztrees = initZtree(menuList, roleMenuList, true); } else { ztrees = initZtree(menuList, null, true); } return ztrees; }
Example #2
Source File: SysMenuServiceImpl.java From ruoyiplus with MIT License | 6 votes |
/** * 根据父节点的ID获取所有子节点 * * @param list 分类表 * @param parentId 传入的父节点ID * @return String */ public List<SysMenu> getChildPerms(List<SysMenu> list, int parentId) { List<SysMenu> returnList = new ArrayList<SysMenu>(); for (Iterator<SysMenu> iterator = list.iterator(); iterator.hasNext();) { SysMenu t = (SysMenu) iterator.next(); // 一、根据传入的某个父节点ID,遍历该父节点的所有子节点 if (t.getParentId() == parentId) { recursionFn(list, t); returnList.add(t); } } return returnList; }
Example #3
Source File: SysMenuServiceImpl.java From supplierShop with MIT License | 6 votes |
/** * 递归列表 * * @param list * @param t */ private void recursionFn(List<SysMenu> list, SysMenu t) { // 得到子节点列表 List<SysMenu> childList = getChildList(list, t); t.setChildren(childList); for (SysMenu tChild : childList) { if (hasChild(list, tChild)) { // 判断是否有子节点 Iterator<SysMenu> it = childList.iterator(); while (it.hasNext()) { SysMenu n = (SysMenu) it.next(); recursionFn(list, n); } } } }
Example #4
Source File: SysMenuServiceImpl.java From supplierShop with MIT License | 6 votes |
/** * 对象转菜单树 * * @param menuList 菜单列表 * @param roleMenuList 角色已存在菜单列表 * @param permsFlag 是否需要显示权限标识 * @return 树结构列表 */ public List<Ztree> initZtree(List<SysMenu> menuList, List<String> roleMenuList, boolean permsFlag) { List<Ztree> ztrees = new ArrayList<Ztree>(); boolean isCheck = StringUtils.isNotNull(roleMenuList); for (SysMenu menu : menuList) { Ztree ztree = new Ztree(); ztree.setId(menu.getMenuId()); ztree.setpId(menu.getParentId()); ztree.setName(transMenuName(menu, permsFlag)); ztree.setTitle(menu.getMenuName()); if (isCheck) { ztree.setChecked(roleMenuList.contains(menu.getMenuId() + menu.getPerms())); } ztrees.add(ztree); } return ztrees; }
Example #5
Source File: SysMenuServiceImpl.java From supplierShop with MIT License | 6 votes |
/** * 根据父节点的ID获取所有子节点 * * @param list 分类表 * @param parentId 传入的父节点ID * @return String */ public List<SysMenu> getChildPerms(List<SysMenu> list, int parentId) { List<SysMenu> returnList = new ArrayList<SysMenu>(); for (Iterator<SysMenu> iterator = list.iterator(); iterator.hasNext();) { SysMenu t = (SysMenu) iterator.next(); // 一、根据传入的某个父节点ID,遍历该父节点的所有子节点 if (t.getParentId() == parentId) { recursionFn(list, t); returnList.add(t); } } return returnList; }
Example #6
Source File: SysMenuServiceImpl.java From ruoyiplus with MIT License | 6 votes |
/** * 对象转菜单树 * * @param menuList 菜单列表 * @param isCheck 是否需要选中 * @param roleMenuList 角色已存在菜单列表 * @param permsFlag 是否需要显示权限标识 * @return */ public List<Map<String, Object>> getTrees(List<SysMenu> menuList, boolean isCheck, List<String> roleMenuList, boolean permsFlag) { List<Map<String, Object>> trees = new ArrayList<Map<String, Object>>(); for (SysMenu menu : menuList) { Map<String, Object> deptMap = new HashMap<String, Object>(); deptMap.put("id", menu.getMenuId()); deptMap.put("pId", menu.getParentId()); deptMap.put("name", transMenuName(menu, roleMenuList, permsFlag)); deptMap.put("title", menu.getMenuName()); if (isCheck) { deptMap.put("checked", roleMenuList.contains(menu.getMenuId() + menu.getPerms())); } else { deptMap.put("checked", false); } trees.add(deptMap); } return trees; }
Example #7
Source File: SysMenuServiceImpl.java From RuoYi with Apache License 2.0 | 6 votes |
/** * 对象转菜单树 * * @param menuList 菜单列表 * @param roleMenuList 角色已存在菜单列表 * @param permsFlag 是否需要显示权限标识 * @return 菜单树 */ private List<Ztree> initZtree(List<SysMenu> menuList, List<String> roleMenuList, boolean permsFlag){ List<Ztree> ztrees = new ArrayList<>(); boolean isCheck = CollectionUtil.isNotEmpty(roleMenuList); if(CollectionUtil.isNotEmpty(menuList)){ menuList.forEach(menu ->{ Ztree ztree = new Ztree(); ztree.setId(menu.getMenuId()); ztree.setPId(menu.getParentId()); ztree.setName(transMenuName(menu, permsFlag)); ztree.setTitle(menu.getMenuName()); if (isCheck){ ztree.setChecked(roleMenuList.contains(menu.getMenuId() + menu.getPerms())); } ztrees.add(ztree); }); } return ztrees; }
Example #8
Source File: SysMenuController.java From RuoYi with Apache License 2.0 | 5 votes |
/** * 新增保存菜单 */ @Log(title = "菜单管理", businessType = BusinessType.INSERT) @RequiresPermissions("system:menu:add") @PostMapping("/add") @ResponseBody public AjaxResult addSave(SysMenu menu) { menu.setCreateBy(ShiroUtils.getLoginName()); ShiroUtils.clearCachedAuthorizationInfo(); return toAjax(menuService.insertMenu(menu)); }
Example #9
Source File: SysMenuServiceImpl.java From RuoYi with Apache License 2.0 | 5 votes |
/** * 根据父节点的ID获取所有子节点 * * @param list 分类表 * @param parentId 传入的父节点ID * @return String */ private List<SysMenu> getChildPerms(List<SysMenu> list, int parentId) { List<SysMenu> returnList = new ArrayList<>(); list.stream().filter(t -> t.getParentId() == parentId).forEach(t -> { recursionFn(list, t); returnList.add(t); }); return returnList; }
Example #10
Source File: SysMenuServiceImpl.java From supplierShop with MIT License | 5 votes |
/** * 查询菜单集合 * * @return 所有菜单信息 */ @Override public List<SysMenu> selectMenuAll(Long userId) { List<SysMenu> menuList = null; if (SysUser.isAdmin(userId)) { menuList = menuMapper.selectMenuAll(); } else { menuList = menuMapper.selectMenuAllByUserId(userId); } return menuList; }
Example #11
Source File: SysMenuServiceImpl.java From supplierShop with MIT License | 5 votes |
/** * 查询所有菜单 * * @return 菜单列表 */ @Override public List<Ztree> menuTreeData(Long userId) { List<SysMenu> menuList = selectMenuAll(userId); List<Ztree> ztrees = initZtree(menuList); return ztrees; }
Example #12
Source File: SysMenuServiceImpl.java From supplierShop with MIT License | 5 votes |
/** * 查询系统所有权限 * * @return 权限列表 */ @Override public LinkedHashMap<String, String> selectPermsAll(Long userId) { LinkedHashMap<String, String> section = new LinkedHashMap<>(); List<SysMenu> permissions = selectMenuAll(userId); if (StringUtils.isNotEmpty(permissions)) { for (SysMenu menu : permissions) { section.put(menu.getUrl(), MessageFormat.format(PREMISSION_STRING, menu.getPerms())); } } return section; }
Example #13
Source File: SysMenuServiceImpl.java From ruoyiplus with MIT License | 5 votes |
/** * 校验菜单名称是否唯一 * * @param menu 菜单信息 * @return 结果 */ @Override public String checkMenuNameUnique(SysMenu menu) { Long menuId = StringUtils.isNull(menu.getMenuId()) ? -1L : menu.getMenuId(); SysMenu info = menuMapper.checkMenuNameUnique(menu.getMenuName(), menu.getParentId()); if (StringUtils.isNotNull(info) && info.getMenuId().longValue() != menuId.longValue()) { return UserConstants.MENU_NAME_NOT_UNIQUE; } return UserConstants.MENU_NAME_UNIQUE; }
Example #14
Source File: SysMenuServiceImpl.java From supplierShop with MIT License | 5 votes |
public String transMenuName(SysMenu menu, boolean permsFlag) { StringBuffer sb = new StringBuffer(); sb.append(menu.getMenuName()); if (permsFlag) { sb.append("<font color=\"#888\"> " + menu.getPerms() + "</font>"); } return sb.toString(); }
Example #15
Source File: SysMenuController.java From RuoYi with Apache License 2.0 | 5 votes |
/** * 修改保存菜单 */ @Log(title = "菜单管理", businessType = BusinessType.UPDATE) @RequiresPermissions("system:menu:edit") @PostMapping("/edit") @ResponseBody public AjaxResult editSave(SysMenu menu) { menu.setUpdateBy(ShiroUtils.getLoginName()); ShiroUtils.clearCachedAuthorizationInfo(); return toAjax(menuService.updateMenu(menu)); }
Example #16
Source File: SysMenuController.java From ruoyiplus with MIT License | 5 votes |
/** * 新增保存菜单 */ @Log(title = "菜单管理", businessType = BusinessType.INSERT) @RequiresPermissions("system:menu:add") @PostMapping("/add") @ResponseBody public AjaxResult addSave(SysMenu menu) { menu.setCreateBy(ShiroUtils.getLoginName()); ShiroUtils.clearCachedAuthorizationInfo(); return toAjax(menuService.insertMenu(menu)); }
Example #17
Source File: SysMenuController.java From ruoyiplus with MIT License | 5 votes |
@RequiresPermissions("system:menu:list") @GetMapping("/list") @ResponseBody public List<SysMenu> list(SysMenu menu) { List<SysMenu> menuList = menuService.selectMenuList(menu); return menuList; }
Example #18
Source File: SysMenuServiceImpl.java From supplierShop with MIT License | 5 votes |
/** * 得到子节点列表 */ private List<SysMenu> getChildList(List<SysMenu> list, SysMenu t) { List<SysMenu> tlist = new ArrayList<SysMenu>(); Iterator<SysMenu> it = list.iterator(); while (it.hasNext()) { SysMenu n = (SysMenu) it.next(); if (n.getParentId().longValue() == t.getMenuId().longValue()) { tlist.add(n); } } return tlist; }
Example #19
Source File: SysMenuController.java From ruoyiplus with MIT License | 5 votes |
@RequiresPermissions("system:menu:list") @GetMapping("/listTreeGridData") @ResponseBody public Map listTreeGridData(SysMenu menu) { Map retMap = new HashMap(); List<SysMenu> menuList = menuService.selectMenuList(menu); retMap.put("msg",""); retMap.put("code",0); retMap.put("data",menuList); retMap.put("count",menuList!=null?menuList.size():0); retMap.put("is",true); retMap.put("tip","操作成功"); return retMap; }
Example #20
Source File: SysMenuController.java From RuoYi with Apache License 2.0 | 5 votes |
@RequiresPermissions("system:menu:list") @GetMapping("/list") @ResponseBody public List<SysMenu> list(SysMenu menu) { Long userId = ShiroUtils.getUserId(); return menuService.selectMenuList(menu, userId); }
Example #21
Source File: SysMenuServiceImpl.java From ruoyiplus with MIT License | 5 votes |
/** * 得到子节点列表 */ private List<SysMenu> getChildList(List<SysMenu> list, SysMenu t) { List<SysMenu> tlist = new ArrayList<SysMenu>(); Iterator<SysMenu> it = list.iterator(); while (it.hasNext()) { SysMenu n = (SysMenu) it.next(); if (n.getParentId().longValue() == t.getMenuId().longValue()) { tlist.add(n); } } return tlist; }
Example #22
Source File: SysIndexController.java From ruoyiplus with MIT License | 5 votes |
@GetMapping("/index") public String index(ModelMap mmap) { // 取身份信息 SysUser user = getSysUser(); // 根据用户id取出菜单 List<SysMenu> menus = menuService.selectMenusByUser(user); mmap.put("menus", menus); mmap.put("user", user); mmap.put("copyrightYear", Global.getCopyrightYear()); return "index"; }
Example #23
Source File: SysMenuServiceImpl.java From RuoYi with Apache License 2.0 | 5 votes |
/** * 递归列表 * * @param list 菜单列表 */ private void recursionFn(List<SysMenu> list, SysMenu t) { // 得到子节点列表 List<SysMenu> childList = getChildList(list, t); t.setChildren(childList); for (SysMenu tChild : childList) { if (hasChild(list, tChild)) { // 判断是否有子节点 for (SysMenu n : childList) { recursionFn(list, n); } } } }
Example #24
Source File: SysMenuServiceImpl.java From ruoyiplus with MIT License | 5 votes |
/** * 查询系统所有权限 * * @return 权限列表 */ @Override public LinkedHashMap<String, String> selectPermsAll() { LinkedHashMap<String, String> section = new LinkedHashMap<>(); List<SysMenu> permissions = menuMapper.selectMenuAll(); if (StringUtils.isNotEmpty(permissions)) { for (SysMenu menu : permissions) { section.put(menu.getUrl(), MessageFormat.format(PREMISSION_STRING, menu.getPerms())); } } return section; }
Example #25
Source File: SysMenuServiceImpl.java From ruoyiplus with MIT License | 5 votes |
/** * 查询所有菜单 * * @return 菜单列表 */ @Override public List<Map<String, Object>> menuTreeData() { List<Map<String, Object>> trees = new ArrayList<Map<String, Object>>(); List<SysMenu> menuList = menuMapper.selectMenuAll(); trees = getTrees(menuList, false, null, false); return trees; }
Example #26
Source File: SysMenuServiceImpl.java From RuoYi with Apache License 2.0 | 5 votes |
private String transMenuName(SysMenu menu, boolean permsFlag) { StringBuilder sb = new StringBuilder(); sb.append(menu.getMenuName()); if (permsFlag) { sb.append("<font color=\"#888\"> ").append(menu.getPerms()).append("</font>"); } return sb.toString(); }
Example #27
Source File: SysMenuController.java From supplierShop with MIT License | 5 votes |
/** * 校验菜单名称 */ @PostMapping("/checkMenuNameUnique") @ResponseBody public String checkMenuNameUnique(SysMenu menu) { return menuService.checkMenuNameUnique(menu); }
Example #28
Source File: SysMenuController.java From supplierShop with MIT License | 5 votes |
/** * 修改保存菜单 */ @Log(title = "菜单管理", businessType = BusinessType.UPDATE) @RequiresPermissions("system:menu:edit") @PostMapping("/edit") @ResponseBody public AjaxResult editSave(@Validated SysMenu menu) { if (UserConstants.MENU_NAME_NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) { return error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在"); } menu.setUpdateBy(ShiroUtils.getLoginName()); ShiroUtils.clearCachedAuthorizationInfo(); return toAjax(menuService.updateMenu(menu)); }
Example #29
Source File: SysMenuController.java From supplierShop with MIT License | 5 votes |
/** * 新增保存菜单 */ @Log(title = "菜单管理", businessType = BusinessType.INSERT) @RequiresPermissions("system:menu:add") @PostMapping("/add") @ResponseBody public AjaxResult addSave(@Validated SysMenu menu) { if (UserConstants.MENU_NAME_NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) { return error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在"); } menu.setCreateBy(ShiroUtils.getLoginName()); ShiroUtils.clearCachedAuthorizationInfo(); return toAjax(menuService.insertMenu(menu)); }
Example #30
Source File: SysMenuController.java From supplierShop with MIT License | 5 votes |
@RequiresPermissions("system:menu:list") @PostMapping("/list") @ResponseBody public List<SysMenu> list(SysMenu menu) { Long userId = ShiroUtils.getUserId(); List<SysMenu> menuList = menuService.selectMenuList(menu, userId); return menuList; }