|
@@ -72,6 +72,7 @@ import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.temporal.ChronoUnit;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
@@ -1129,6 +1130,14 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
|
if (SecurityUtils.getRoles().contains(1) || SecurityUtils.getRoles().contains(2)) {
|
|
|
return baseMapper.getUserVosPage(page, userDTO, new DataScope());
|
|
|
} else if (SecurityUtils.getRoles().contains(19)) {
|
|
|
+ Integer userId = SecurityUtils.getUser().getId();
|
|
|
+ // CSM只能查看自己维护的企业下的用户, 以及下属维护的企业下的用户
|
|
|
+ Set<Integer> userIdList = new HashSet<>();
|
|
|
+ userIdList.add(userId);
|
|
|
+ // 递归查询下属关联的userId
|
|
|
+ AtomicInteger limitCount = new AtomicInteger(10);
|
|
|
+ this.recurseCsmLowerUserId(userIdList, userIdList, limitCount);
|
|
|
+ userDTO.setCsmUserIdList(userIdList);
|
|
|
return baseMapper.getUserVosPage(page, userDTO, new DataScope());
|
|
|
} else if (SecurityUtils.getRoles().contains(35)) {
|
|
|
// BC总负责人数据权限
|
|
@@ -1210,6 +1219,29 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|
|
return page1;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 递归查询CSM所有下级的用户ID
|
|
|
+ *
|
|
|
+ * @param allIds 所有ID
|
|
|
+ * @param parentIds 父级ID
|
|
|
+ * @param limitCount 递归次数限制
|
|
|
+ */
|
|
|
+ private void recurseCsmLowerUserId(Set<Integer> allIds, Set<Integer> parentIds, AtomicInteger limitCount) {
|
|
|
+ // 限制调用次数
|
|
|
+ if (limitCount.decrementAndGet() <= 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SysCsmUserRelation> csmUserRelations = sysCsmUserRelationMapper.selectList(Wrappers.<SysCsmUserRelation>lambdaQuery()
|
|
|
+ .in(SysCsmUserRelation::getParentId, parentIds));
|
|
|
+ if (CollUtil.isNotEmpty(csmUserRelations)) {
|
|
|
+ Set<Integer> userIds = csmUserRelations.stream().map(SysCsmUserRelation::getUserId).collect(Collectors.toSet());
|
|
|
+ this.recurseCsmLowerUserId(allIds, userIds, limitCount);
|
|
|
+ allIds.addAll(userIds);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 通过ID查询用户信息
|
|
|
*
|