提交 e0d46a2c 作者: 洪东保

咨询窗口登陆接口慢修复

父级 b3c5e274
package com.cmeeting.ad.service.impl;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
......@@ -119,41 +120,19 @@ public class UserServiceImpl implements UserService {
RobotSecurityUser robotSecurityUser = JSON.parseObject(data.toJSONString(), RobotSecurityUser.class);
String userId = String.format("%08d", robotSecurityUser.getUserId());
// //权限控制
// List<CoreModulePermissions> auths = authMapper.getAuthByTargetId(permissionApplicationId, permissionTenantId);
// //先判断智能体是否有直接授权给当前登录人
// boolean userAccess = auths.stream().anyMatch(item -> item.getType().equals(1) && item.getRelId().equals(userId));
// //未直接授权到人,判断是否有授权给当前登录人所在组织
// if (!userAccess) {
// List<CoreModulePermissions> authDepts = auths.stream().filter(item -> item.getType().equals(0)).collect(Collectors.toList());
// List<String> deptPath = new ArrayList<>();
// for (CoreModulePermissions authDept : authDepts) {
// String deptId = authDept.getRelId();
// getDeptPath(deptPath, deptId);
// }
// //已被授权部门下的userid
// List<String> accessUserIds = !CollectionUtils.isEmpty(deptPath) ? sysUserSyncMapper.getUsersByDept(deptPath) : new ArrayList<>();
// if (!accessUserIds.contains(userId)) {
// throw new RobotBaseException("您暂无权限");
// }
// }
List<ModulePermission> auths = iModulePermissionService.list(new LambdaQueryWrapper<ModulePermission>().eq(ModulePermission::getPurpose, 0));
boolean userAccess = auths.stream().anyMatch(item -> item.getType().equals(1) && item.getRelId().equals(userId));
SysUserSync sysUserSync = sysUserSyncMapper.selectOne(new LambdaQueryWrapper<SysUserSync>().eq(SysUserSync::getUserId, userId).select(SysUserSync::getName, SysUserSync::getDeptId));
//未直接授权到人,判断是否有授权给当前登录人所在组织
if (!userAccess) {
List<ModulePermission> authDepts = auths.stream().filter(item -> item.getType().equals(0)).collect(Collectors.toList());
Set<String> authDepts = auths.stream().filter(item -> item.getType().equals(0)).map(ModulePermission::getRelId).collect(Collectors.toSet());
List<String> deptPath = new ArrayList<>();
for (ModulePermission authDept : authDepts) {
String deptId = authDept.getRelId();
getDeptPath(deptPath, deptId);
}
//已被授权部门下的userid
List<String> accessUserIds = !CollectionUtils.isEmpty(deptPath) ? sysUserSyncMapper.getUsersByDept(deptPath) : new ArrayList<>();
if (!accessUserIds.contains(userId)) {
getDeptPath(deptPath, sysUserSync.getDeptId());
if (deptPath.stream().noneMatch(authDepts::contains)) {
throw new RobotBaseException("您暂无权限");
}
}
SysUserSync sysUserSync = sysUserSyncMapper.selectOne(new LambdaQueryWrapper<SysUserSync>().eq(SysUserSync::getUserId, userId).select(SysUserSync::getName));
return auth(userId, sysUserSync.getName(), RecordTemplateConstant.TEMPLATE_TYPE_CUSTOM);
}
......@@ -216,18 +195,14 @@ public class UserServiceImpl implements UserService {
if (!deptPath.contains(deptId)) {
deptPath.add(deptId);
}
List<String> subDeptIds = sysUserSyncMapper.getSubDeptId(deptId);
if (CollectionUtils.isEmpty(subDeptIds)) {
String parentId = sysUserSyncMapper.getParDeptId(deptId);
if (StrUtil.isBlank(parentId)) {
return;
}
for (String subDeptId : subDeptIds) {
//部门id去重
if (!deptPath.contains(subDeptId)) {
deptPath.add(subDeptId);
getDeptPath(deptPath, subDeptId);
if (!deptPath.contains(parentId)) {
deptPath.add(parentId);
getDeptPath(deptPath, parentId);
}
}
}
}
\ No newline at end of file
......@@ -26,6 +26,7 @@ public interface SysUserSyncMapper extends BaseMapper<SysUserSync> {
List<SysDept> getSimpleDeptList();
List<String> getSubDeptId(@Param(value = "deptId")String deptId);
String getParDeptId(@Param(value = "deptId")String deptId);
List<String> getUsersByDept(@Param(value = "deptIds") List<String> deptIds);
......
......@@ -171,4 +171,9 @@
</if>
</where>
</select>
<select id="getParDeptId" resultType="java.lang.String">
SELECT parent_id
FROM sys_user_sync_category
WHERE dept_id = #{deptId}
</select>
</mapper>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论