Search in sources :

Example 1 with DeptDO

use of io.github.tesla.ops.system.domain.DeptDO 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;
}
Also used : HashMap(java.util.HashMap) UserDO(io.github.tesla.ops.system.domain.UserDO) ArrayList(java.util.ArrayList) Tree(io.github.tesla.ops.system.domain.Tree) BuildTree(io.github.tesla.ops.utils.BuildTree) DeptDO(io.github.tesla.ops.system.domain.DeptDO)

Example 2 with DeptDO

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

the class DeptController method edit.

@GetMapping("/edit/{deptId}")
@RequiresPermissions("sys:dept:edit")
String edit(@PathVariable("deptId") Long deptId, Model model) {
    DeptDO sysDept = sysDeptService.get(deptId);
    model.addAttribute("sysDept", sysDept);
    if (Constant.DEPT_ROOT_ID.equals(sysDept.getParentId())) {
        model.addAttribute("parentDeptName", "无");
    } else {
        DeptDO parDept = sysDeptService.get(sysDept.getParentId());
        model.addAttribute("parentDeptName", parDept.getName());
    }
    return prefix + "/edit";
}
Also used : DeptDO(io.github.tesla.ops.system.domain.DeptDO) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 3 with DeptDO

use of io.github.tesla.ops.system.domain.DeptDO 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;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) BuildTree(io.github.tesla.ops.utils.BuildTree) Tree(io.github.tesla.ops.system.domain.Tree) DeptDO(io.github.tesla.ops.system.domain.DeptDO)

Aggregations

DeptDO (io.github.tesla.ops.system.domain.DeptDO)3 Tree (io.github.tesla.ops.system.domain.Tree)2 BuildTree (io.github.tesla.ops.utils.BuildTree)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 UserDO (io.github.tesla.ops.system.domain.UserDO)1 RequiresPermissions (org.apache.shiro.authz.annotation.RequiresPermissions)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1