diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtGroupMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtGroupMapper.xml
index 371914ebe9..0e39fbe996 100644
--- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtGroupMapper.xml
+++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtGroupMapper.xml
@@ -41,6 +41,23 @@
+ union distinct
+ select g.*, p.name as scopeName from `group` g, project p
+
+ and g.scope_id = p.id
+
+ AND g.type in
+
+ #{type}
+
+
+
+ AND g.scope_id in
+
+ #{scope}
+
+
+
) temp
where temp.name like CONCAT('%', #{request.name},'%')
diff --git a/backend/src/main/java/io/metersphere/controller/request/GroupRequest.java b/backend/src/main/java/io/metersphere/controller/request/GroupRequest.java
index a3210f9ed2..db01165221 100644
--- a/backend/src/main/java/io/metersphere/controller/request/GroupRequest.java
+++ b/backend/src/main/java/io/metersphere/controller/request/GroupRequest.java
@@ -5,5 +5,6 @@ import lombok.Data;
@Data
public class GroupRequest {
private String resourceId;
+ private String projectId;
private String type;
}
diff --git a/backend/src/main/java/io/metersphere/controller/request/group/EditGroupRequest.java b/backend/src/main/java/io/metersphere/controller/request/group/EditGroupRequest.java
index 4ca04f9667..827ff96441 100644
--- a/backend/src/main/java/io/metersphere/controller/request/group/EditGroupRequest.java
+++ b/backend/src/main/java/io/metersphere/controller/request/group/EditGroupRequest.java
@@ -28,4 +28,5 @@ public class EditGroupRequest extends Group {
private String userGroupId;
private List orders;
private boolean onlyQueryCurrentProject = false;
+ private boolean onlyQueryGlobal = false;
}
diff --git a/backend/src/main/java/io/metersphere/service/GroupService.java b/backend/src/main/java/io/metersphere/service/GroupService.java
index a5f4391509..a18d8a7d6f 100644
--- a/backend/src/main/java/io/metersphere/service/GroupService.java
+++ b/backend/src/main/java/io/metersphere/service/GroupService.java
@@ -26,7 +26,6 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
-import org.apache.poi.ss.formula.functions.T;
import org.mybatis.spring.SqlSessionUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -229,6 +228,9 @@ public class GroupService {
if (!StringUtils.equals(type, UserGroupType.SYSTEM)) {
criteria.andTypeEqualTo(type);
}
+ if (BooleanUtils.isTrue(request.isOnlyQueryGlobal())) {
+ criteria.andScopeIdEqualTo(GLOBAL);
+ }
return groupMapper.selectByExample(example);
}
@@ -262,6 +264,9 @@ public class GroupService {
String resourceId = request.getResourceId();
String type = request.getType();
List scopeList = Arrays.asList(GLOBAL, resourceId);
+ if (StringUtils.equals(type, UserGroupType.PROJECT) && StringUtils.isNotBlank(request.getProjectId())) {
+ scopeList = Arrays.asList(GLOBAL, resourceId, request.getProjectId());
+ }
GroupExample groupExample = new GroupExample();
groupExample.createCriteria().andScopeIdIn(scopeList)
.andTypeEqualTo(type);
@@ -313,7 +318,8 @@ public class GroupService {
private Pager> getUserGroup(String groupType, EditGroupRequest request) {
List types;
String workspaceId = SessionUtils.getCurrentWorkspaceId();
- List scopes = Arrays.asList(GLOBAL, workspaceId);
+ String projectId = SessionUtils.getCurrentProjectId();
+ List scopes = Arrays.asList(GLOBAL, workspaceId, projectId);
int goPage = request.getGoPage();
int pageSize = request.getPageSize();
Page