From 9c555775a68bb958ed8c9074aee1c8c8de403e15 Mon Sep 17 00:00:00 2001 From: WangXu10 Date: Mon, 4 Sep 2023 10:08:27 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE):?= =?UTF-8?q?=20=E7=B3=BB=E7=BB=9F=E6=97=A5=E5=BF=97-=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=8E=A5=E5=8F=A3=E6=94=AF=E6=8C=81=E8=BF=9C?= =?UTF-8?q?=E7=A8=8B=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/OperationLogController.java | 6 ++++-- .../controller/SystemProjectController.java | 10 ++++------ .../system/mapper/ExtUserMapper.java | 2 ++ .../system/mapper/ExtUserMapper.xml | 18 ++++++++++++++++++ .../system/service/UserService.java | 7 ++----- .../OperationLogControllerTests.java | 5 +++-- .../SystemProjectControllerTests.java | 10 ++++------ 7 files changed, 37 insertions(+), 21 deletions(-) diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/OperationLogController.java b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/OperationLogController.java index ca0d7762bc..9d60362a81 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/OperationLogController.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/OperationLogController.java @@ -16,6 +16,7 @@ import io.metersphere.system.service.OrganizationService; import io.metersphere.system.service.SystemProjectService; import io.metersphere.system.service.UserService; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; import org.apache.commons.lang3.StringUtils; @@ -74,8 +75,9 @@ public class OperationLogController { @GetMapping("/user/list") @Operation(summary = "系统设置-系统-日志-系统日志页面,获取用户列表") @RequiresPermissions(PermissionConstants.SYSTEM_LOG_READ) - public List getUserList() { - List userList = userService.getUserList(); + public List getUserList(@Schema(description = "查询关键字,根据邮箱和用户名查询") + @RequestParam(value = "keyword", required = false) String keyword) { + List userList = userService.getUserList(keyword); return userList; } } 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 aa7777ce24..55ff490f09 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 @@ -5,10 +5,7 @@ import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import io.metersphere.project.domain.Project; import io.metersphere.sdk.constants.PermissionConstants; -import io.metersphere.sdk.dto.AddProjectRequest; -import io.metersphere.sdk.dto.ProjectDTO; -import io.metersphere.sdk.dto.ProjectExtendDTO; -import io.metersphere.sdk.dto.UpdateProjectRequest; +import io.metersphere.sdk.dto.*; import io.metersphere.sdk.log.annotation.Log; import io.metersphere.sdk.log.constants.OperationLogType; import io.metersphere.sdk.util.PageUtils; @@ -149,8 +146,9 @@ public class SystemProjectController { @GetMapping("/user-list") @Operation(summary = "系统设置-系统-组织与项目-项目-系统-组织及项目, 获取管理员下拉选项") @RequiresPermissions(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ) - public List getUserList() { - return userService.getUserList(); + public List getUserList(@Schema(description = "查询关键字,根据邮箱和用户名查询") + @RequestParam(value = "keyword", required = false) String keyword) { + return userService.getUserList(keyword); } } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtUserMapper.java b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtUserMapper.java index ea81175a9a..4f05cf1e54 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtUserMapper.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtUserMapper.java @@ -11,4 +11,6 @@ public interface ExtUserMapper { List getMemberOption(String sourceId); List getUserListByOrgId(@Param("sourceId") String sourceId); + + List selectUserList(@Param("keyword") String keyword); } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtUserMapper.xml b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtUserMapper.xml index a4ecd5725e..2ceaf81510 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtUserMapper.xml +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtUserMapper.xml @@ -19,4 +19,22 @@ WHERE urr.source_id = #{sourceId} and u.deleted = false + + + + \ No newline at end of file diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserService.java index 3cf16e7610..2f7df6c843 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserService.java @@ -297,11 +297,8 @@ public class UserService { return insertIndex; } - public List getUserList() { - UserExample example = new UserExample(); - example.createCriteria().andDeletedEqualTo(false); - example.setOrderByClause("update_time desc"); - return userMapper.selectByExample(example); + public List getUserList(String keyword) { + return extUserMapper.selectUserList(keyword.trim()); } /** diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/OperationLogControllerTests.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/OperationLogControllerTests.java index eb115697a9..5d35706cf4 100644 --- a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/OperationLogControllerTests.java +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/OperationLogControllerTests.java @@ -138,10 +138,11 @@ public class OperationLogControllerTests extends BaseTest { @Test @Order(3) public void testUserList() throws Exception { - this.requestGetWithOkAndReturn(USER_LIST); + String keyword = "a"; + this.requestGetWithOkAndReturn(USER_LIST + "?keyword=" + keyword); // @@校验权限 - requestGetPermissionTest(PermissionConstants.SYSTEM_LOG_READ, USER_LIST); + requestGetPermissionTest(PermissionConstants.SYSTEM_LOG_READ, USER_LIST + "?keyword=" + keyword); } @Test 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 f2cad2bfcf..21a1ae02f8 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 @@ -8,10 +8,7 @@ import io.metersphere.sdk.constants.InternalUserRole; import io.metersphere.sdk.constants.PermissionConstants; import io.metersphere.sdk.constants.SessionConstants; import io.metersphere.sdk.controller.handler.ResultHolder; -import io.metersphere.sdk.dto.AddProjectRequest; -import io.metersphere.sdk.dto.ProjectDTO; -import io.metersphere.sdk.dto.ProjectExtendDTO; -import io.metersphere.sdk.dto.UpdateProjectRequest; +import io.metersphere.sdk.dto.*; import io.metersphere.sdk.log.constants.OperationLogType; import io.metersphere.sdk.util.JSON; import io.metersphere.sdk.util.Pager; @@ -708,9 +705,10 @@ public class SystemProjectControllerTests extends BaseTest { @Test @Order(21) public void testUserList() throws Exception { - this.requestGetWithOkAndReturn(userList); + String keyword = "a"; + this.requestGetWithOkAndReturn(userList + "?keyword=" + keyword); // @@校验权限 - requestGetPermissionTest(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ, userList); + requestGetPermissionTest(PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ, userList + "?keyword=" + keyword); } }