Search in sources :

Example 1 with Menu

use of com.dimple.project.system.domain.Menu in project DimpleBlog by martin-chips.

the class MenuServiceImpl method recursionFn.

/**
 * 递归列表
 *
 * @param list
 * @param t
 */
private void recursionFn(List<Menu> list, Menu t) {
    // 得到子节点列表
    List<Menu> childList = getChildList(list, t);
    t.setChildren(childList);
    for (Menu tChild : childList) {
        if (hasChild(list, tChild)) {
            // 判断是否有子节点
            Iterator<Menu> it = childList.iterator();
            while (it.hasNext()) {
                Menu n = it.next();
                recursionFn(list, n);
            }
        }
    }
}
Also used : Menu(com.dimple.project.system.domain.Menu)

Example 2 with Menu

use of com.dimple.project.system.domain.Menu in project DimpleBlog by martin-chips.

the class MenuServiceImpl method getChildList.

/**
 * 得到子节点列表
 */
private List<Menu> getChildList(List<Menu> list, Menu t) {
    List<Menu> tlist = new ArrayList<>();
    Iterator<Menu> it = list.iterator();
    while (it.hasNext()) {
        Menu n = it.next();
        if (n.getParentId().longValue() == t.getId().longValue()) {
            tlist.add(n);
        }
    }
    return tlist;
}
Also used : ArrayList(java.util.ArrayList) Menu(com.dimple.project.system.domain.Menu)

Example 3 with Menu

use of com.dimple.project.system.domain.Menu in project DimpleBlog by martin-chips.

the class MenuServiceImpl method getChildPerms.

/**
 * 根据父节点的ID获取所有子节点
 *
 * @param list     分类表
 * @param parentId 传入的父节点ID
 * @return String
 */
public List<Menu> getChildPerms(List<Menu> list, int parentId) {
    List<Menu> returnList = new ArrayList<>();
    for (Iterator<Menu> iterator = list.iterator(); iterator.hasNext(); ) {
        Menu t = iterator.next();
        // 一、根据传入的某个父节点ID,遍历该父节点的所有子节点
        if (t.getParentId() == parentId) {
            recursionFn(list, t);
            returnList.add(t);
        }
    }
    return returnList;
}
Also used : ArrayList(java.util.ArrayList) Menu(com.dimple.project.system.domain.Menu)

Example 4 with Menu

use of com.dimple.project.system.domain.Menu in project DimpleBlog by martin-chips.

the class MenuServiceImpl method buildMenus.

@Override
public List<RouterVo> buildMenus(List<Menu> menus) {
    List<RouterVo> routers = new LinkedList<>();
    for (Menu menu : menus) {
        RouterVo router = new RouterVo();
        router.setName(menu.getMenuName());
        router.setPath(getRouterPath(menu));
        router.setComponent(StringUtils.isEmpty(menu.getComponent()) ? "Layout" : menu.getComponent());
        router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon()));
        router.setName(menu.getMenuName());
        List<Menu> cMenus = menu.getChildren();
        if (!cMenus.isEmpty() && "M".equals(menu.getMenuType())) {
            router.setAlwaysShow(true);
            router.setRedirect("noRedirect");
            router.setChildren(buildMenus(cMenus));
        }
        routers.add(router);
    }
    return routers;
}
Also used : MetaVo(com.dimple.project.system.domain.vo.MetaVo) Menu(com.dimple.project.system.domain.Menu) LinkedList(java.util.LinkedList) RouterVo(com.dimple.project.system.domain.vo.RouterVo)

Example 5 with Menu

use of com.dimple.project.system.domain.Menu in project DimpleBlog by martin-chips.

the class MenuServiceImpl method checkMenuNameUnique.

@Override
public String checkMenuNameUnique(Menu menu) {
    Long menuId = StringUtils.isNull(menu.getId()) ? -1L : menu.getId();
    Menu info = menuMapper.checkMenuNameUnique(menu.getMenuName(), menu.getParentId());
    if (StringUtils.isNotNull(info) && info.getId().longValue() != menuId.longValue()) {
        return UserConstants.NOT_UNIQUE;
    }
    return UserConstants.UNIQUE;
}
Also used : Menu(com.dimple.project.system.domain.Menu)

Aggregations

Menu (com.dimple.project.system.domain.Menu)7 ArrayList (java.util.ArrayList)2 GetMapping (org.springframework.web.bind.annotation.GetMapping)2 LoginUser (com.dimple.framework.security.LoginUser)1 AjaxResult (com.dimple.framework.web.domain.AjaxResult)1 SysUser (com.dimple.project.system.domain.SysUser)1 MetaVo (com.dimple.project.system.domain.vo.MetaVo)1 RouterVo (com.dimple.project.system.domain.vo.RouterVo)1 LinkedList (java.util.LinkedList)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1