use of io.github.tesla.ops.system.domain.Tree 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.Tree in project tesla by linking12.
the class UserServiceImpl method getTree.
@Override
public Tree<DeptDO> getTree() {
List<Tree<DeptDO>> trees = new ArrayList<Tree<DeptDO>>();
List<DeptDO> depts = deptMapper.list(new HashMap<String, Object>(16));
Long[] pDepts = deptMapper.listParentDept();
Long[] uDepts = userMapper.listAllDept();
Long[] allDepts = (Long[]) ArrayUtils.addAll(pDepts, uDepts);
for (DeptDO dept : depts) {
if (!ArrayUtils.contains(allDepts, dept.getDeptId())) {
continue;
}
Tree<DeptDO> tree = new Tree<DeptDO>();
tree.setId(dept.getDeptId().toString());
tree.setParentId(dept.getParentId().toString());
tree.setText(dept.getName());
Map<String, Object> state = new HashMap<>(16);
state.put("opened", true);
state.put("mType", "dept");
tree.setState(state);
trees.add(tree);
}
List<UserDO> users = userMapper.list(new HashMap<String, Object>(16));
for (UserDO user : users) {
Tree<DeptDO> tree = new Tree<DeptDO>();
tree.setId(user.getUserId().toString());
tree.setParentId(user.getDeptId().toString());
tree.setText(user.getName());
Map<String, Object> state = new HashMap<>(16);
state.put("opened", true);
state.put("mType", "user");
tree.setState(state);
trees.add(tree);
}
Tree<DeptDO> t = BuildTree.build(trees);
return t;
}
use of io.github.tesla.ops.system.domain.Tree in project tesla by linking12.
the class DeptServiceImpl method getTree.
@Override
public Tree<DeptDO> getTree() {
List<Tree<DeptDO>> trees = new ArrayList<Tree<DeptDO>>();
List<DeptDO> sysDepts = sysDeptMapper.list(new HashMap<String, Object>(16));
for (DeptDO sysDept : sysDepts) {
Tree<DeptDO> tree = new Tree<DeptDO>();
tree.setId(sysDept.getDeptId().toString());
tree.setParentId(sysDept.getParentId().toString());
tree.setText(sysDept.getName());
Map<String, Object> state = new HashMap<>(16);
state.put("opened", true);
tree.setState(state);
trees.add(tree);
}
// 默认顶级菜单为0,根据数据库实际情况调整
Tree<DeptDO> t = BuildTree.build(trees);
return t;
}
use of io.github.tesla.ops.system.domain.Tree 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.Tree 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;
}
Aggregations