refactor(用户组权限): 超级管理员权限问题

This commit is contained in:
shiziyuan9527 2023-01-30 11:38:55 +08:00 committed by lyh
parent e9816cbd43
commit 0ef9f20aba
1 changed files with 7 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package io.metersphere.service;
import io.metersphere.base.domain.Group; import io.metersphere.base.domain.Group;
import io.metersphere.base.domain.Project; import io.metersphere.base.domain.Project;
import io.metersphere.base.domain.ProjectExample;
import io.metersphere.base.domain.UserGroup; import io.metersphere.base.domain.UserGroup;
import io.metersphere.base.mapper.ProjectMapper; import io.metersphere.base.mapper.ProjectMapper;
import io.metersphere.base.mapper.ext.BaseProjectMapper; import io.metersphere.base.mapper.ext.BaseProjectMapper;
@ -34,6 +35,12 @@ public class BaseCheckPermissionService {
public Set<String> getUserRelatedProjectIds() { public Set<String> getUserRelatedProjectIds() {
if (SessionUtils.getUserId() != null && baseUserService.isSuperUser(SessionUtils.getUserId())) {
List<Project> projects = projectMapper.selectByExample(new ProjectExample());
if (CollectionUtils.isNotEmpty(projects)) {
return projects.stream().map(Project::getId).collect(Collectors.toSet());
}
}
UserDTO userDTO = baseUserService.getUserDTO(SessionUtils.getUserId()); UserDTO userDTO = baseUserService.getUserDTO(SessionUtils.getUserId());
List<String> groupIds = userDTO.getGroups() List<String> groupIds = userDTO.getGroups()
.stream() .stream()