From 7d85370e86f07cc56ee4b61e1dcc6f25ae164963 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Thu, 25 Aug 2022 14:47:22 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):?= =?UTF-8?q?=20=E4=BC=98=E5=8C=96=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E8=BF=87=E7=A8=8B=E4=B8=AD=E7=9A=84=E9=83=A8?= =?UTF-8?q?=E5=88=86=E5=AF=B9=E7=94=A8=E6=88=B7=E6=93=8D=E4=BD=9C=E7=9A=84?= =?UTF-8?q?=E6=AD=A5=E9=AA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 优化接口测试执行过程中的部分对用户操作的步骤,避免一次性查出数据库中的全部用户信息 --- .../api/service/ShareInfoService.java | 11 ++++- .../base/mapper/ext/ExtUserMapper.java | 3 -- .../base/mapper/ext/ExtUserMapper.xml | 45 ++++++++++--------- .../io/metersphere/service/UserService.java | 12 +++-- 4 files changed, 41 insertions(+), 30 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/ShareInfoService.java b/backend/src/main/java/io/metersphere/api/service/ShareInfoService.java index 706da4ecff..808d393fce 100644 --- a/backend/src/main/java/io/metersphere/api/service/ShareInfoService.java +++ b/backend/src/main/java/io/metersphere/api/service/ShareInfoService.java @@ -70,7 +70,6 @@ public class ShareInfoService { public Pager> selectApiInfoByParam(ApiDocumentRequest apiDocumentRequest, int goPage, int pageSize) { this.iniApiDocumentRequest(apiDocumentRequest); - Map userIdMap = userService.queryName(); Page page = PageHelper.startPage(goPage, pageSize, true); List apiDocumentInfoDTOS = new ArrayList<>(); @@ -81,14 +80,22 @@ public class ShareInfoService { List apiModuleIdList = new ArrayList<>(); LogUtil.info("查找模块相关信息"); + List userIdList = new ArrayList<>(); apiDocumentInfoDTOS.forEach(item -> { if (StringUtils.isNotBlank(item.getModuleId()) && !apiModuleIdList.contains(item.getModuleId())) { apiModuleIdList.add(item.getModuleId()); + if (!userIdList.contains(item.getUserId())) { + userIdList.add(item.getUserId()); + } + if (!userIdList.contains(item.getCreateUser())) { + userIdList.add(item.getCreateUser()); + } } }); + Map seletedUserMap = userService.getUserIdMapByIds(userIdList); Map moduleNameMap = apiModuleService.getApiModuleNameDicByIds(apiModuleIdList); LogUtil.info("开始遍历组装数据"); - List returnList = this.conversionModelListToDTO(apiDocumentInfoDTOS, userIdMap, moduleNameMap); + List returnList = this.conversionModelListToDTO(apiDocumentInfoDTOS, seletedUserMap, moduleNameMap); return PageUtils.setPageInfo(page, returnList); } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtUserMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtUserMapper.java index f498354869..407a1d7bfc 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtUserMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtUserMapper.java @@ -24,9 +24,6 @@ public interface ExtUserMapper { @MapKey("id") Map queryNameByIds(List userIds); - @MapKey("id") - Map queryName(); - List selectAllId(); List selectIdsByQuery(@Param("request") UserRequest request); diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtUserMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtUserMapper.xml index 445ab5f0a7..a833724e09 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtUserMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtUserMapper.xml @@ -46,7 +46,7 @@ AND (u.name like CONCAT('%', #{userRequest.name},'%') - or u.id like CONCAT('%', #{userRequest.name},'%')) + or u.id like CONCAT('%', #{userRequest.name},'%')) AND u.email like CONCAT('%', #{userRequest.email},'%') @@ -73,19 +73,22 @@ - update user - set - password=#{password,jdbcType=VARCHAR}, - update_time = #{updateTime,jdbcType=BIGINT} - where id=#{id,jdbcType=VARCHAR} - + update user + set password=#{password,jdbcType=VARCHAR}, + update_time = #{updateTime,jdbcType=BIGINT} + where id = #{id,jdbcType=VARCHAR} + + select param_value + from system_parameter + where param_key = #{paramKey,jdbcType=VARCHAR} + - - - update user set last_project_id = #{projectId} where id = #{userId} - and (last_project_id is null or last_project_id = '') + update user + set last_project_id = #{projectId} + where id = #{userId} + and (last_project_id is null or last_project_id = '') - update user set last_workspace_id = #{workspaceId} where id = #{userId} - and (last_workspace_id is null or last_workspace_id = '') + update user + set last_workspace_id = #{workspaceId} + where id = #{userId} + and (last_workspace_id is null or last_workspace_id = '') \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/service/UserService.java b/backend/src/main/java/io/metersphere/service/UserService.java index c4030fcee9..039ec94474 100644 --- a/backend/src/main/java/io/metersphere/service/UserService.java +++ b/backend/src/main/java/io/metersphere/service/UserService.java @@ -101,10 +101,6 @@ public class UserService { return extUserMapper.queryNameByIds(userIds); } - public Map queryName() { - return extUserMapper.queryName(); - } - public UserDTO insert(UserRequest userRequest) { checkUserParam(userRequest); String id = userRequest.getId(); @@ -1502,4 +1498,12 @@ public class UserService { public List getProjectMemberOption(String projectId) { return extUserGroupMapper.getProjectMemberOption(projectId); } + + public Map getUserIdMapByIds(List userIdList) { + return extUserMapper.queryNameByIds(userIdList); + } + + public User selectById(String id) { + return userMapper.selectByPrimaryKey(id); + } }