From d10f45872ffda7c6447e9bb1911ddc86614bf3ea Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Tue, 14 May 2024 17:51:05 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E7=94=A8=E4=BE=8B=E7=AE=A1=E7=90=86):?= =?UTF-8?q?=20=E7=94=A8=E4=BE=8B=E8=AF=A6=E6=83=85=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BA=BA=E5=92=8C=E6=9B=B4=E6=96=B0=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../functional/dto/FunctionalCaseDetailDTO.java | 9 +++++++++ .../functional/service/FunctionalCaseService.java | 9 +++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/dto/FunctionalCaseDetailDTO.java b/backend/services/case-management/src/main/java/io/metersphere/functional/dto/FunctionalCaseDetailDTO.java index f716996c36..d40f2d6df0 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/dto/FunctionalCaseDetailDTO.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/dto/FunctionalCaseDetailDTO.java @@ -68,6 +68,15 @@ public class FunctionalCaseDetailDTO implements Serializable { @Schema(description = "创建时间") private Long createTime; + @Schema(description = "更新人") + private String updateUser; + + @Schema(description = "更新人姓名") + private String updateUserName; + + @Schema(description = "更新时间") + private Long updateTime; + @Schema(description = "用例步骤(JSON),step_model 为 Step 时启用") private String steps; diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseService.java index 5897ea2cda..2f0f23a654 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseService.java @@ -36,6 +36,7 @@ import io.metersphere.sdk.util.Translator; import io.metersphere.system.domain.CustomFieldOption; import io.metersphere.system.domain.OperationHistoryExample; import io.metersphere.system.domain.User; +import io.metersphere.system.domain.UserExample; import io.metersphere.system.dto.OperationHistoryDTO; import io.metersphere.system.dto.request.OperationHistoryRequest; import io.metersphere.system.dto.sdk.*; @@ -377,8 +378,12 @@ public class FunctionalCaseService { String name = functionalCaseModuleService.getModuleName(functionalCaseDetailDTO.getModuleId()); functionalCaseDetailDTO.setModuleName(name); - User user = userMapper.selectByPrimaryKey(functionalCaseDetailDTO.getCreateUser()); - functionalCaseDetailDTO.setCreateUserName(user.getName()); + UserExample userExample = new UserExample(); + userExample.createCriteria().andIdIn(List.of(functionalCaseDetailDTO.getCreateUser(), functionalCaseDetailDTO.getUpdateUser())); + List users = userMapper.selectByExample(userExample); + Map userMap = users.stream().collect(Collectors.toMap(User::getId, User::getName)); + functionalCaseDetailDTO.setCreateUserName(userMap.get(functionalCaseDetailDTO.getCreateUser())); + functionalCaseDetailDTO.setUpdateUserName(userMap.get(functionalCaseDetailDTO.getUpdateUser())); } private void handleCount(FunctionalCaseDetailDTO functionalCaseDetailDTO) {