refactor(项目设置): 添加项目成员选项过滤掉已经添加的成员

--bug=1027791 --user=陈建星 【项目设置】github#25583,项目管理-项目成员,可以添加重复多次添加同一个成员,建议加一个唯一性校验 https://www.tapd.cn/55049933/s/1397290
This commit is contained in:
jianxing 2023-07-25 16:08:11 +08:00 committed by jianxing
parent b241ceadab
commit 177016932e
4 changed files with 22 additions and 2 deletions

View File

@ -4,6 +4,7 @@ import io.metersphere.base.domain.User;
import io.metersphere.base.domain.UserGroup;
import io.metersphere.commons.constants.OperLogConstants;
import io.metersphere.commons.constants.OperLogModule;
import io.metersphere.commons.constants.PermissionConstants;
import io.metersphere.commons.constants.UserGroupConstants;
import io.metersphere.commons.user.SessionUser;
import io.metersphere.commons.utils.SessionUtils;
@ -15,6 +16,7 @@ import io.metersphere.request.member.EditSeleniumServerRequest;
import io.metersphere.request.member.QueryMemberRequest;
import io.metersphere.service.BaseUserService;
import jakarta.annotation.Resource;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;
import java.util.*;
@ -39,6 +41,11 @@ public class BaseUserController {
return baseUserService.getMemberList(request);
}
@GetMapping("/add/project/member/option/{projectId}")
@RequiresPermissions(PermissionConstants.PROJECT_USER_READ)
public List<User> getAddProjectMemberOption(@PathVariable(value = "projectId") String projectId) {
return baseUserService.getAddProjectMemberOption(projectId);
}
@GetMapping("/switch/source/ws/{sourceId}")
public UserDTO switchWorkspace(@PathVariable(value = "sourceId") String sourceId) {

View File

@ -718,6 +718,19 @@ public class BaseUserService {
return baseUserGroupMapper.getMemberList(request);
}
public List<User> getAddProjectMemberOption(String projectId) {
Project project = projectMapper.selectByPrimaryKey(projectId);
QueryMemberRequest request = new QueryMemberRequest();
request.setWorkspaceId(project.getWorkspaceId());
List<User> memberList = getMemberList(request);
request.setProjectId(projectId);
Set<String> projectUserIds = getProjectMemberList(request)
.stream().map(i -> i.getId())
.collect(Collectors.toSet());
return memberList.stream().filter(i -> !projectUserIds.contains(i.getId()))
.collect(Collectors.toList());
}
public void createOssUser(User user) {
user.setCreateTime(System.currentTimeMillis());
user.setUpdateTime(System.currentTimeMillis());

View File

@ -30,7 +30,7 @@ export default {
},
userList: [],
loading: false,
userResourceUrl: 'user/ws/current/member/list'
userResourceUrl: 'user/add/project/member/option/' + getCurrentProjectID()
};
},
computed: {

View File

@ -166,7 +166,7 @@
:group-scope-id="workspaceId"
ref="addMember"
:project-id="rowProjectId"
:user-resource-url="'user/ws/current/member/list'"
:user-resource-url="'user/add/project/member/option/' + rowProjectId"
@submit="submitForm"/>
<ms-delete-confirm :title="$t('project.delete')" @delete="_handleDelete" ref="deleteConfirm"/>