Search in sources :

Example 1 with MenuDO

use of io.github.tesla.ops.system.domain.MenuDO in project tesla by linking12.

the class MenuController method edit.

@Log("编辑菜单")
@RequiresPermissions("sys:menu:edit")
@GetMapping("/edit/{id}")
String edit(Model model, @PathVariable("id") Long id) {
    MenuDO mdo = menuService.get(id);
    Long pId = mdo.getParentId();
    model.addAttribute("pId", pId);
    if (pId == 0) {
        model.addAttribute("pName", "根目录");
    } else {
        model.addAttribute("pName", menuService.get(pId).getName());
    }
    model.addAttribute("menu", mdo);
    return prefix + "/edit";
}
Also used : MenuDO(io.github.tesla.ops.system.domain.MenuDO) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) GetMapping(org.springframework.web.bind.annotation.GetMapping) Log(io.github.tesla.ops.common.Log)

Example 2 with MenuDO

use of io.github.tesla.ops.system.domain.MenuDO in project tesla by linking12.

the class MenuServiceImpl method getTree.

@Override
public Tree<MenuDO> getTree(Long id) {
    List<MenuDO> menus = menuMapper.list(new HashMap<String, Object>(16));
    List<Long> menuIds = roleMenuMapper.listMenuIdByRoleId(id);
    List<Long> temp = menuIds;
    for (MenuDO menu : menus) {
        if (temp.contains(menu.getParentId())) {
            menuIds.remove(menu.getParentId());
        }
    }
    List<Tree<MenuDO>> trees = new ArrayList<Tree<MenuDO>>();
    List<MenuDO> menuDOs = menuMapper.list(new HashMap<String, Object>(16));
    for (MenuDO sysMenuDO : menuDOs) {
        Tree<MenuDO> tree = new Tree<MenuDO>();
        tree.setId(sysMenuDO.getMenuId().toString());
        tree.setParentId(sysMenuDO.getParentId().toString());
        tree.setText(sysMenuDO.getName());
        Map<String, Object> state = new HashMap<>(16);
        Long menuId = sysMenuDO.getMenuId();
        if (menuIds.contains(menuId)) {
            state.put("selected", true);
        } else {
            state.put("selected", false);
        }
        tree.setState(state);
        trees.add(tree);
    }
    Tree<MenuDO> t = BuildTree.build(trees);
    return t;
}
Also used : MenuDO(io.github.tesla.ops.system.domain.MenuDO) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Tree(io.github.tesla.ops.system.domain.Tree) BuildTree(io.github.tesla.ops.utils.BuildTree)

Example 3 with MenuDO

use of io.github.tesla.ops.system.domain.MenuDO in project tesla by linking12.

the class MenuServiceImpl method getSysMenuTree.

@Cacheable
@Override
public Tree<MenuDO> getSysMenuTree(Long id) {
    List<Tree<MenuDO>> trees = new ArrayList<Tree<MenuDO>>();
    List<MenuDO> menuDOs = menuMapper.listMenuByUserId(id);
    for (MenuDO sysMenuDO : menuDOs) {
        Tree<MenuDO> tree = new Tree<MenuDO>();
        tree.setId(sysMenuDO.getMenuId().toString());
        tree.setParentId(sysMenuDO.getParentId().toString());
        tree.setText(sysMenuDO.getName());
        Map<String, Object> attributes = new HashMap<>(16);
        attributes.put("url", sysMenuDO.getUrl());
        attributes.put("icon", sysMenuDO.getIcon());
        tree.setAttributes(attributes);
        trees.add(tree);
    }
    Tree<MenuDO> t = BuildTree.build(trees);
    return t;
}
Also used : MenuDO(io.github.tesla.ops.system.domain.MenuDO) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Tree(io.github.tesla.ops.system.domain.Tree) BuildTree(io.github.tesla.ops.utils.BuildTree) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 4 with MenuDO

use of io.github.tesla.ops.system.domain.MenuDO in project tesla by linking12.

the class MenuServiceImpl method listMenuTree.

@Override
public List<Tree<MenuDO>> listMenuTree(Long id) {
    List<Tree<MenuDO>> trees = new ArrayList<Tree<MenuDO>>();
    List<MenuDO> menuDOs = menuMapper.listMenuByUserId(id);
    for (MenuDO sysMenuDO : menuDOs) {
        Tree<MenuDO> tree = new Tree<MenuDO>();
        tree.setId(sysMenuDO.getMenuId().toString());
        tree.setParentId(sysMenuDO.getParentId().toString());
        tree.setText(sysMenuDO.getName());
        Map<String, Object> attributes = new HashMap<>(16);
        attributes.put("url", sysMenuDO.getUrl());
        attributes.put("icon", sysMenuDO.getIcon());
        tree.setAttributes(attributes);
        trees.add(tree);
    }
    List<Tree<MenuDO>> list = BuildTree.buildList(trees, "0");
    return list;
}
Also used : MenuDO(io.github.tesla.ops.system.domain.MenuDO) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Tree(io.github.tesla.ops.system.domain.Tree) BuildTree(io.github.tesla.ops.utils.BuildTree)

Example 5 with MenuDO

use of io.github.tesla.ops.system.domain.MenuDO in project tesla by linking12.

the class MenuServiceImpl method getTree.

@Override
public Tree<MenuDO> getTree() {
    List<Tree<MenuDO>> trees = new ArrayList<Tree<MenuDO>>();
    List<MenuDO> menuDOs = menuMapper.list(new HashMap<>(16));
    for (MenuDO sysMenuDO : menuDOs) {
        Tree<MenuDO> tree = new Tree<MenuDO>();
        tree.setId(sysMenuDO.getMenuId().toString());
        tree.setParentId(sysMenuDO.getParentId().toString());
        tree.setText(sysMenuDO.getName());
        trees.add(tree);
    }
    Tree<MenuDO> t = BuildTree.build(trees);
    return t;
}
Also used : MenuDO(io.github.tesla.ops.system.domain.MenuDO) ArrayList(java.util.ArrayList) Tree(io.github.tesla.ops.system.domain.Tree) BuildTree(io.github.tesla.ops.utils.BuildTree)

Aggregations

MenuDO (io.github.tesla.ops.system.domain.MenuDO)5 Tree (io.github.tesla.ops.system.domain.Tree)4 BuildTree (io.github.tesla.ops.utils.BuildTree)4 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)3 Log (io.github.tesla.ops.common.Log)1 RequiresPermissions (org.apache.shiro.authz.annotation.RequiresPermissions)1 Cacheable (org.springframework.cache.annotation.Cacheable)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1