中扬CRM客户关系管理系统
#
luxiaotao1123
2022-11-08 4d39a74d7118a55897bf521d02016052acace7e6
src/main/java/com/zy/crm/common/utils/TreeUtils.java
@@ -7,6 +7,7 @@
import com.zy.crm.manager.service.NodeService;
import com.zy.crm.manager.service.TagService;
import com.zy.crm.system.entity.Dept;
import com.zy.crm.system.entity.Role;
import com.zy.crm.system.entity.User;
import com.zy.crm.system.service.DeptService;
import com.zy.crm.system.service.RoleService;
@@ -181,6 +182,16 @@
    @Cacheable(cacheNames="deptUserTree",key="#id")
    public ArrayList<Map<String, Object>> getDeptUserTree(String id, Long hostId, Long userId){
        ArrayList<Map<String, Object>> result = new ArrayList<>();
        User user = userService.selectById(userId);
        Role role = roleService.selectById(user.getRoleId());
        if (role.getCode().equals("salesman")) {
            Map<String, Object> map = new HashMap<>();
            map.put("title", user.getNickname());
            map.put("id", user.getId());
            map.put("key", "user_id");
            map.put("icon", "layui-icon layui-icon-friends");
            result.add(map);
        } else {
        Dept dept = deptService.selectById(id);
        // 主节点
        Map<String, Object> map = new HashMap<>();
@@ -192,6 +203,7 @@
        map.put("children", childrens);
        dealUserDept(dept, childrens, hostId, userId);
        result.add(map);
        }
        return result;
    }