首页 > 其他分享 >权限篇

权限篇

时间:2024-10-31 14:19:37浏览次数:1  
标签:case null return getUserQueues userInfo 权限 userRole

// 查权限下技能组
private List<WinQueue> getQueuesPermission(BasicUserInfo userInfo) { UserRole userRole = roleService.queryUserRole(userInfo); UserTypeEnum userTypeEnum = UserTypeEnum.getEnumByCode(userRole.getUserType()); List<WinQueue> winQueues; switch (userTypeEnum) { case RoleBigAccount: case RoleAll: case RoleGroup: case RoleDepartment: winQueues = queueRepository.queryQueues(userRole.getVccId(), null); break; case RoleQueue: winQueues = queueRepository.queryQueues(userRole.getVccId(), userRole.getUserQueues() == null ? null : String.join(",", userRole.getUserQueues())); break; case RoleAgent: log.warn("vccId:{} userId:{} agentId:{} 当前为坐席权限,不能查看技能组",userInfo.getVccId(), userInfo.getUserId(),userInfo.getAgId()); winQueues = new ArrayList<>(); break; default: log.warn("vccId:{} userId:{} agentId:{} 当前为未知权限,不能查看技能组",userInfo.getVccId(), userInfo.getUserId(),userInfo.getAgId()); winQueues = new ArrayList<>(); break; } return winQueues; }

// 查权限下坐席
private List<Agent> getAgents(BasicUserInfo userInfo) {
UserRole userRole = roleService.queryUserRole(userInfo);
switch (RoleType.findByCode(userRole.getUserType())) {
case ROLE_BIG_ACCOUNT:
case ROLE_ALL:
return queryAgents(userInfo, true, null, null, null);
case ROLE_QUEUE:
if (userRole.getIsEnableGroup()) {
return queryAgents(userInfo, true, null, null, null);
}
if (null != userRole.getUserQueues() && !userRole.getUserQueues().isEmpty()) {
return getAgentsByQues(userRole.getUserQueues());
} else {
return queryAgents(userInfo, false, userInfo.getAgId(), null, null);
}
// 该角色在业务场景中已废弃,待manage管理中下线该角色
case ROLE_GROUP:
return getGroupAgentsByGroups(userRole.getUserQueues());
case ROLE_DEPARTMENT:
String strQueues = CollectionUtils.isEmpty(userRole.getUserQueues()) ? "" : String.join(",", userRole.getUserQueues());
return getAgentWithDepartmentIds(userInfo, strQueues);
default:
return queryAgents(userInfo, false, userInfo.getAgId(), null, null);
}
}
//查权限下部门
public List<DepartmentTree> queryDepartmentTree(BasicUserInfo basicUserInfo) {
UserInfo userInfo = MyBeanUtils.copy(basicUserInfo, UserInfo.class);
UserRole userRole = roleService.queryUserRole(basicUserInfo);
UserTypeEnum userTypeEnum = UserTypeEnum.getEnumByCode(userRole.getUserType());
List<DepartmentTree> departmentTrees = new ArrayList<>();
switch (userTypeEnum) {
case RoleBigAccount:
case RoleAll:
case RoleGroup:
case RoleQueue:
departmentTrees = this.getDepartmentTree(basicUserInfo,null);
break;
case RoleDepartment:
List<String> queues = Optional.ofNullable(userRole.getUserQueues()).orElse(new ArrayList<>());
departmentTrees = this.getDepartmentTree(basicUserInfo, queues);
break;
case RoleAgent:
log.warn("user:{} 当前为坐席权限,不能查看部门", userInfo);
break;
default:
log.warn("user:{} 当前为未知权限,不能查看部门", userInfo);
break;

}
return departmentTrees;
}
 

其中 角色的权限在其中启到了很重要的作用. 角色权限可以在技能组,坐席,部门上设置,可以选本坐席/归属技能组/归属部门,也可以选其他的,还可以不限,最特殊的场景,就是选了维度限制,具体的又不选

 

标签:case,null,return,getUserQueues,userInfo,权限,userRole
From: https://www.cnblogs.com/long-yuan/p/18517686

相关文章