fix(系统设置): 用户组获取待关联用户时没有过滤已经删除的用户
This commit is contained in:
parent
8261617a8d
commit
07fe3541de
|
@ -33,5 +33,7 @@ public interface BaseUserMapper {
|
||||||
|
|
||||||
List<ExcludeOptionDTO> getExcludeSelectOption();
|
List<ExcludeOptionDTO> getExcludeSelectOption();
|
||||||
|
|
||||||
List<OptionDTO> getSelectOptionByIds(List<String> ids);
|
List<OptionDTO> getSelectOptionByIdsWithDeleted(List<String> ids);
|
||||||
|
|
||||||
|
List<OptionDTO> getSelectOptionWithDeleted();
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
<select id="findAll" resultType="io.metersphere.system.domain.User">
|
<select id="findAll" resultType="io.metersphere.system.domain.User">
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM user
|
FROM user
|
||||||
|
where deleted IS FALSE
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="batchSave">
|
<insert id="batchSave">
|
||||||
|
@ -95,8 +96,9 @@
|
||||||
<select id="getExcludeSelectOption" resultType="io.metersphere.sdk.dto.ExcludeOptionDTO">
|
<select id="getExcludeSelectOption" resultType="io.metersphere.sdk.dto.ExcludeOptionDTO">
|
||||||
select id, name
|
select id, name
|
||||||
from user
|
from user
|
||||||
|
where deleted is false
|
||||||
</select>
|
</select>
|
||||||
<select id="getSelectOptionByIds" resultType="io.metersphere.sdk.dto.OptionDTO">
|
<select id="getSelectOptionByIdsWithDeleted" resultType="io.metersphere.sdk.dto.OptionDTO">
|
||||||
SELECT id, name
|
SELECT id, name
|
||||||
FROM user
|
FROM user
|
||||||
WHERE id IN
|
WHERE id IN
|
||||||
|
@ -105,4 +107,8 @@
|
||||||
#{id}
|
#{id}
|
||||||
</foreach>
|
</foreach>
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getSelectOptionWithDeleted" resultType="io.metersphere.sdk.dto.OptionDTO">
|
||||||
|
select id, name
|
||||||
|
from user
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
|
@ -429,12 +429,16 @@ public class BaseUserService {
|
||||||
return baseUserMapper.getExcludeSelectOption();
|
return baseUserMapper.getExcludeSelectOption();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<OptionDTO> getSelectOptionByIds(List<String> ids) {
|
public List<OptionDTO> getSelectOptionWithDeleted() {
|
||||||
return baseUserMapper.getSelectOptionByIds(ids);
|
return baseUserMapper.getSelectOptionWithDeleted();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<OptionDTO> getSelectOptionByIdsWithDeleted(List<String> ids) {
|
||||||
|
return baseUserMapper.getSelectOptionByIdsWithDeleted(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> getUserNameMap() {
|
public Map<String, String> getUserNameMap() {
|
||||||
List<ExcludeOptionDTO> excludeSelectOption = getExcludeSelectOption();
|
List<OptionDTO> excludeSelectOption = getSelectOptionWithDeleted();
|
||||||
Map<String, String> nameMap = new HashMap<>();
|
Map<String, String> nameMap = new HashMap<>();
|
||||||
excludeSelectOption.forEach(option -> nameMap.put(option.getId(), option.getName()));
|
excludeSelectOption.forEach(option -> nameMap.put(option.getId(), option.getName()));
|
||||||
return nameMap;
|
return nameMap;
|
||||||
|
@ -450,7 +454,7 @@ public class BaseUserService {
|
||||||
if (CollectionUtils.isEmpty(userIds)) {
|
if (CollectionUtils.isEmpty(userIds)) {
|
||||||
return Collections.emptyMap();
|
return Collections.emptyMap();
|
||||||
}
|
}
|
||||||
return getSelectOptionByIds(userIds)
|
return getSelectOptionByIdsWithDeleted(userIds)
|
||||||
.stream()
|
.stream()
|
||||||
.collect(Collectors.toMap(OptionDTO::getId, OptionDTO::getName));
|
.collect(Collectors.toMap(OptionDTO::getId, OptionDTO::getName));
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,10 +12,12 @@ import io.metersphere.sdk.service.BaseUserService;
|
||||||
import io.metersphere.sdk.util.Pager;
|
import io.metersphere.sdk.util.Pager;
|
||||||
import io.metersphere.system.controller.param.GlobalUserRoleRelationQueryRequestDefinition;
|
import io.metersphere.system.controller.param.GlobalUserRoleRelationQueryRequestDefinition;
|
||||||
import io.metersphere.system.controller.param.GlobalUserRoleRelationUpdateRequestDefinition;
|
import io.metersphere.system.controller.param.GlobalUserRoleRelationUpdateRequestDefinition;
|
||||||
|
import io.metersphere.system.domain.UserExample;
|
||||||
import io.metersphere.system.domain.UserRole;
|
import io.metersphere.system.domain.UserRole;
|
||||||
import io.metersphere.system.domain.UserRoleRelation;
|
import io.metersphere.system.domain.UserRoleRelation;
|
||||||
import io.metersphere.system.domain.UserRoleRelationExample;
|
import io.metersphere.system.domain.UserRoleRelationExample;
|
||||||
import io.metersphere.system.dto.request.GlobalUserRoleRelationQueryRequest;
|
import io.metersphere.system.dto.request.GlobalUserRoleRelationQueryRequest;
|
||||||
|
import io.metersphere.system.mapper.UserMapper;
|
||||||
import io.metersphere.system.mapper.UserRoleMapper;
|
import io.metersphere.system.mapper.UserRoleMapper;
|
||||||
import io.metersphere.system.mapper.UserRoleRelationMapper;
|
import io.metersphere.system.mapper.UserRoleRelationMapper;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
@ -51,6 +53,8 @@ class GlobalUserRoleRelationControllerTests extends BaseTest {
|
||||||
@Resource
|
@Resource
|
||||||
private UserRoleMapper userRoleMapper;
|
private UserRoleMapper userRoleMapper;
|
||||||
@Resource
|
@Resource
|
||||||
|
private UserMapper userMapper;
|
||||||
|
@Resource
|
||||||
private BaseUserService baseUserService;
|
private BaseUserService baseUserService;
|
||||||
@Resource
|
@Resource
|
||||||
private BaseUserRoleRelationMapper baseUserRoleRelationMapper;
|
private BaseUserRoleRelationMapper baseUserRoleRelationMapper;
|
||||||
|
@ -156,6 +160,13 @@ class GlobalUserRoleRelationControllerTests extends BaseTest {
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
// 校验数量
|
// 校验数量
|
||||||
Assertions.assertTrue(options.size() == excludeSelectOption.size());
|
Assertions.assertTrue(options.size() == excludeSelectOption.size());
|
||||||
|
|
||||||
|
UserExample example = new UserExample();
|
||||||
|
example.createCriteria().andIdIn(excludeUserIds.stream().toList())
|
||||||
|
.andDeletedEqualTo(true);
|
||||||
|
// 校验获取的用户是不是都是未删除的用户
|
||||||
|
Assertions.assertTrue(CollectionUtils.isEmpty(userMapper.selectByExample(example)));
|
||||||
|
|
||||||
options.forEach(item -> {
|
options.forEach(item -> {
|
||||||
// 校验 exclude 字段
|
// 校验 exclude 字段
|
||||||
Assertions.assertTrue(item.getExclude() == excludeUserIds.contains(item.getId()));
|
Assertions.assertTrue(item.getExclude() == excludeUserIds.contains(item.getId()));
|
||||||
|
|
Loading…
Reference in New Issue