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";
}
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;
}
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;
}
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;
}
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;
}
Aggregations