diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/OrganizationProjectController.java b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/OrganizationProjectController.java index 3563408c55..0ba099bff7 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/OrganizationProjectController.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/OrganizationProjectController.java @@ -13,6 +13,7 @@ import io.metersphere.sdk.log.constants.OperationLogType; import io.metersphere.sdk.util.PageUtils; import io.metersphere.sdk.util.Pager; import io.metersphere.sdk.util.SessionUtils; +import io.metersphere.system.domain.User; import io.metersphere.system.dto.UserExtend; import io.metersphere.system.request.OrganizationProjectRequest; import io.metersphere.system.request.ProjectAddMemberBatchRequest; @@ -20,6 +21,7 @@ import io.metersphere.system.request.ProjectAddMemberRequest; import io.metersphere.system.request.ProjectMemberRequest; import io.metersphere.system.service.OrganizationProjectLogService; import io.metersphere.system.service.OrganizationProjectService; +import io.metersphere.system.service.UserService; import io.metersphere.validation.groups.Created; import io.metersphere.validation.groups.Updated; import io.swagger.v3.oas.annotations.Operation; @@ -41,6 +43,8 @@ import java.util.List; public class OrganizationProjectController { @Resource private OrganizationProjectService organizationProjectService; + @Resource + private UserService userService; @PostMapping("/add") @RequiresPermissions(PermissionConstants.ORGANIZATION_PROJECT_READ_ADD) @@ -141,5 +145,11 @@ public class OrganizationProjectController { return organizationProjectService.removeProjectMember(projectId, userId, SessionUtils.getUserId()); } + @GetMapping("/user-list") + @Operation(summary = "获取用户列表") + @RequiresPermissions(PermissionConstants.ORGANIZATION_PROJECT_READ) + public List getUserList() { + return userService.getUserList(); + } } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemProjectController.java b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemProjectController.java index cc696e9494..5771452ffd 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemProjectController.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemProjectController.java @@ -13,6 +13,7 @@ import io.metersphere.sdk.log.constants.OperationLogType; import io.metersphere.sdk.util.PageUtils; import io.metersphere.sdk.util.Pager; import io.metersphere.sdk.util.SessionUtils; +import io.metersphere.system.domain.User; import io.metersphere.system.dto.UserExtend; import io.metersphere.system.request.ProjectAddMemberBatchRequest; import io.metersphere.system.request.ProjectAddMemberRequest; @@ -20,6 +21,7 @@ import io.metersphere.system.request.ProjectMemberRequest; import io.metersphere.system.request.ProjectRequest; import io.metersphere.system.service.SystemProjectLogService; import io.metersphere.system.service.SystemProjectService; +import io.metersphere.system.service.UserService; import io.metersphere.validation.groups.Created; import io.metersphere.validation.groups.Updated; import io.swagger.v3.oas.annotations.Operation; @@ -41,6 +43,8 @@ import java.util.List; public class SystemProjectController { @Resource private SystemProjectService systemProjectService; + @Resource + private UserService userService; @PostMapping("/add") @RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ_ADD) @@ -141,5 +145,11 @@ public class SystemProjectController { return systemProjectService.removeProjectMember(projectId, userId, SessionUtils.getUserId()); } + @GetMapping("/user-list") + @Operation(summary = "获取用户列表") + @RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ) + public List getUserList() { + return userService.getUserList(); + } } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/UserExtend.java b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/UserExtend.java index beb9c30d2f..61ca52764c 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/UserExtend.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/UserExtend.java @@ -4,12 +4,14 @@ import io.metersphere.system.domain.User; import lombok.Data; import lombok.EqualsAndHashCode; +import java.io.Serializable; + /** * @author song-cc-rock */ @Data @EqualsAndHashCode(callSuper = false) -public class UserExtend extends User { +public class UserExtend extends User implements Serializable { /** * 是否管理员(组织, 项目) @@ -20,4 +22,6 @@ public class UserExtend extends User { * 是否成员(组织, 项目) */ private boolean memberFlag; + + private static final long serialVersionUID = 1L; } diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/OrganizationProjectControllerTests.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/OrganizationProjectControllerTests.java index cbb7525317..27047e9db7 100644 --- a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/OrganizationProjectControllerTests.java +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/OrganizationProjectControllerTests.java @@ -65,6 +65,7 @@ public class OrganizationProjectControllerTests extends BaseTest { private final static String removeProjectMember = prefix + "/remove-member/"; private final static String disableProject = prefix + "/disable/"; private final static String enableProject = prefix + "/enable/"; + private final static String userList = prefix + "/user-list"; private static final ResultMatcher BAD_REQUEST_MATCHER = status().isBadRequest(); private static final ResultMatcher ERROR_REQUEST_MATCHER = status().is5xxServerError(); @@ -706,4 +707,13 @@ public class OrganizationProjectControllerTests extends BaseTest { this.responseGet(enableProject + id, ERROR_REQUEST_MATCHER); } + @Test + @Order(21) + public void testUserList() throws Exception { + this.requestGetWithOkAndReturn(userList); + + // @@校验权限 + requestGetPermissionTest(PermissionConstants.ORGANIZATION_PROJECT_READ, userList); + } + } diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/SystemProjectControllerTests.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/SystemProjectControllerTests.java index 467cdb5925..6e553652b7 100644 --- a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/SystemProjectControllerTests.java +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/SystemProjectControllerTests.java @@ -63,6 +63,7 @@ public class SystemProjectControllerTests extends BaseTest { private final static String removeProjectMember = prefix + "/remove-member/"; private final static String disableProject = prefix + "/disable/"; private final static String enableProject = prefix + "/enable/"; + private final static String userList = prefix + "/user-list"; private static final ResultMatcher BAD_REQUEST_MATCHER = status().isBadRequest(); private static final ResultMatcher ERROR_REQUEST_MATCHER = status().is5xxServerError(); @@ -669,4 +670,12 @@ public class SystemProjectControllerTests extends BaseTest { this.responseGet(enableProject + id, ERROR_REQUEST_MATCHER); } + @Test + @Order(21) + public void testUserList() throws Exception { + this.requestGetWithOkAndReturn(userList); + + // @@校验权限 + requestGetPermissionTest(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ, userList); + } }