From 8e9e01a8b4841e9860a34dfc8ba30a7430757b55 Mon Sep 17 00:00:00 2001 From: song-cc-rock Date: Mon, 4 Sep 2023 15:30:44 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE):?= =?UTF-8?q?=20=E4=BC=98=E5=8C=96=E7=BB=84=E7=BB=87=E4=B8=8E=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE&=E7=BB=84=E7=BB=87=E7=94=A8=E6=88=B7=E7=BB=84?= =?UTF-8?q?=E4=B8=8B=E6=8B=89=E7=94=A8=E6=88=B7=E9=80=89=E9=A1=B9=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SystemOrganizationController.java | 6 ++- .../system/mapper/ExtUserMapper.java | 2 +- .../system/mapper/ExtUserMapper.xml | 4 ++ .../service/OrganizationUserRoleService.java | 41 +++++++++++++------ .../system/service/UserService.java | 4 +- .../OrganizationUserRoleControllerTests.java | 3 ++ .../dml/init_organization_user_role.sql | 4 +- 7 files changed, 45 insertions(+), 19 deletions(-) diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemOrganizationController.java b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemOrganizationController.java index 456c48d4ad..a1903b95cc 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemOrganizationController.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/SystemOrganizationController.java @@ -118,7 +118,9 @@ public class SystemOrganizationController { @Operation(summary = "系统设置-系统-组织与项目-获取成员下拉选项") @RequiresPermissions(value = {PermissionConstants.SYSTEM_ORGANIZATION_PROJECT_READ}) @Parameter(name = "sourceId", description = "组织ID或项目ID", schema = @Schema(requiredMode = Schema.RequiredMode.REQUIRED)) - public List getMemberOption(@PathVariable String sourceId) { - return userService.getMemberOption(sourceId); + public List getMemberOption(@PathVariable String sourceId, + @Schema(description = "查询关键字,根据邮箱和用户名查询") + @RequestParam(value = "keyword", required = false) String keyword) { + return userService.getMemberOption(sourceId, 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 cdb6ab9c88..db23176211 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 @@ -8,7 +8,7 @@ import java.util.List; public interface ExtUserMapper { - List getMemberOption(String sourceId); + List getMemberOption(@Param("sourceId") String sourceId, @Param("keyword") String keyword); List getUserListByOrgId(@Param("sourceId") String sourceId, @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 ddc94b9ac5..a2c4bab3f8 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 @@ -5,7 +5,11 @@ select distinct u.*, count(urr.id) > 0 as memberFlag from `user` u left join user_role_relation urr on urr.user_id = u.id and urr.source_id = #{sourceId} where u.deleted = 0 + + and (u.name like concat('%', #{keyword}, '%') or u.email like concat('%', #{keyword}, '%')) + group by u.id + limit 100