fix(系统设置): 修复用户管理中根据组织级自定义用户组反查组织失败的缺陷
--bug=1044417 --user=宋天阳 【系统设置】新建用户A-给A分配系统成员/组织成员/项目成员-修改A的组织/项目用户组-发现用户被移除了组织-之后登录访问报错资源错误 https://www.tapd.cn/55049933/s/1553599
This commit is contained in:
parent
6373a4a5f7
commit
9896894491
|
@ -17,4 +17,16 @@ public class UserTableResponse extends User {
|
|||
private List<Organization> organizationList = new ArrayList<>();
|
||||
@Schema(description = "用户所属用户组")
|
||||
private List<UserRole> userRoleList = new ArrayList<>();
|
||||
|
||||
public void setOrganization(Organization organization) {
|
||||
if (!organizationList.contains(organization)) {
|
||||
organizationList.add(organization);
|
||||
}
|
||||
}
|
||||
|
||||
public void setUserRole(UserRole userRole) {
|
||||
if (!userRoleList.contains(userRole)) {
|
||||
userRoleList.add(userRole);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package io.metersphere.system.mapper;
|
||||
|
||||
import io.metersphere.system.dto.user.UserRoleRelationUserDTO;
|
||||
import io.metersphere.system.domain.UserRoleRelation;
|
||||
import io.metersphere.system.dto.request.GlobalUserRoleRelationQueryRequest;
|
||||
import io.metersphere.system.dto.user.UserRoleRelationUserDTO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -10,6 +10,8 @@ import java.util.List;
|
|||
public interface ExtUserRoleRelationMapper {
|
||||
List<UserRoleRelation> selectGlobalRoleByUserIdList(@Param("userIds") List<String> userIdList);
|
||||
|
||||
List<UserRoleRelation> selectRoleByUserIdList(@Param("userIds") List<String> userIdList);
|
||||
|
||||
List<UserRoleRelation> selectGlobalRoleByUserId(String userId);
|
||||
|
||||
List<UserRoleRelationUserDTO> listGlobal(@Param("request") GlobalUserRoleRelationQueryRequest request);
|
||||
|
|
|
@ -10,13 +10,21 @@
|
|||
<foreach collection="userIds" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
<!-- <foreach collection="userIds" item="userId" open="(" close=")" separator="OR">-->
|
||||
<!-- user_id = #{userId}-->
|
||||
<!-- </foreach>-->
|
||||
AND role_id IN (
|
||||
SELECT id FROM user_role WHERE scope_id = 'global'
|
||||
)
|
||||
</select>
|
||||
|
||||
<select id="selectRoleByUserIdList" resultType="io.metersphere.system.domain.UserRoleRelation">
|
||||
SELECT * FROM
|
||||
user_role_relation
|
||||
WHERE
|
||||
user_id IN
|
||||
<foreach collection="userIds" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="selectGlobalRoleByUserId" resultType="io.metersphere.system.domain.UserRoleRelation">
|
||||
SELECT *
|
||||
FROM user_role_relation
|
||||
|
|
|
@ -98,7 +98,7 @@ public class UserRoleRelationService {
|
|||
}
|
||||
|
||||
public Map<String, UserTableResponse> selectGlobalUserRoleAndOrganization(@Valid @NotEmpty List<String> userIdList) {
|
||||
List<UserRoleRelation> userRoleRelationList = extUserRoleRelationMapper.selectGlobalRoleByUserIdList(userIdList);
|
||||
List<UserRoleRelation> userRoleRelationList = extUserRoleRelationMapper.selectRoleByUserIdList(userIdList);
|
||||
List<String> userRoleIdList = userRoleRelationList.stream().map(UserRoleRelation::getRoleId).distinct().collect(Collectors.toList());
|
||||
List<String> sourceIdList = userRoleRelationList.stream().map(UserRoleRelation::getSourceId).distinct().collect(Collectors.toList());
|
||||
Map<String, UserRole> userRoleMap = new HashMap<>();
|
||||
|
@ -125,11 +125,11 @@ public class UserRoleRelationService {
|
|||
}
|
||||
UserRole userRole = userRoleMap.get(userRoleRelation.getRoleId());
|
||||
if (userRole != null && StringUtils.equalsIgnoreCase(userRole.getType(), UserRoleScope.SYSTEM)) {
|
||||
userInfo.getUserRoleList().add(userRole);
|
||||
userInfo.setUserRole(userRole);
|
||||
}
|
||||
Organization organization = organizationMap.get(userRoleRelation.getSourceId());
|
||||
if (organization != null && !userInfo.getOrganizationList().contains(organization)) {
|
||||
userInfo.getOrganizationList().add(organization);
|
||||
userInfo.setOrganization(organization);
|
||||
}
|
||||
}
|
||||
return returnMap;
|
||||
|
|
Loading…
Reference in New Issue