diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionService.java index 2613ed4a78..6579368327 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionService.java @@ -889,6 +889,10 @@ public class ApiDefinitionService extends MoveNodeService { example.createCriteria().andApiDefinitionIdEqualTo(id).andUserIdEqualTo(userId); apiDefinitionDTO.setFollow(apiDefinitionFollowerMapper.countByExample(example) > 0); BeanUtils.copyBean(apiDefinitionDTO, apiDefinition); + Set userIds = extractUserIds(List.of(apiDefinitionDTO)); + Map userMap = userLoginService.getUserNameMap(new ArrayList<>(userIds)); + apiDefinitionDTO.setCreateUserName(userMap.get(apiDefinitionDTO.getCreateUser())); + apiDefinitionDTO.setUpdateUserName(userMap.get(apiDefinitionDTO.getUpdateUser())); return apiDefinitionDTO; } diff --git a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDefinitionControllerTests.java b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDefinitionControllerTests.java index 328ed8592e..2888d162b9 100644 --- a/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDefinitionControllerTests.java +++ b/backend/services/api-test/src/test/java/io/metersphere/api/controller/ApiDefinitionControllerTests.java @@ -42,6 +42,7 @@ import io.metersphere.system.dto.request.OperationHistoryVersionRequest; import io.metersphere.system.dto.sdk.BaseCondition; import io.metersphere.system.log.constants.OperationLogType; import io.metersphere.system.mapper.OperationHistoryMapper; +import io.metersphere.system.service.UserLoginService; import io.metersphere.system.uid.IDGenerator; import io.metersphere.system.uid.NumGenerator; import io.metersphere.system.utils.Pager; @@ -71,6 +72,7 @@ import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.*; import java.util.stream.Collectors; +import java.util.stream.Stream; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @@ -160,6 +162,8 @@ public class ApiDefinitionControllerTests extends BaseTest { private ApiScenarioMapper apiScenarioMapper; @Resource private ApiScenarioStepMapper apiScenarioStepMapper; + @Resource + private UserLoginService userLoginService; private static String fileMetadataId; private static String uploadFileId; @@ -396,7 +400,12 @@ public class ApiDefinitionControllerTests extends BaseTest { example.createCriteria().andApiDefinitionIdEqualTo(apiDefinition.getId()).andUserIdEqualTo("admin"); List followers = apiDefinitionFollowerMapper.selectByExample(example); copyApiDefinitionDTO.setFollow(CollectionUtils.isNotEmpty(followers)); - + Set userIds = List.of(apiDefinitionDTO).stream() + .flatMap(apiDefinition -> Stream.of(apiDefinition.getUpdateUser(), apiDefinition.getDeleteUser(), apiDefinition.getCreateUser())) + .collect(Collectors.toSet()); + Map userMap = userLoginService.getUserNameMap(new ArrayList<>(userIds)); + copyApiDefinitionDTO.setCreateUserName(userMap.get(apiDefinitionDTO.getCreateUser())); + copyApiDefinitionDTO.setUpdateUserName(userMap.get(apiDefinitionDTO.getUpdateUser())); List customFields = extApiDefinitionCustomFieldMapper.getApiCustomFields(Collections.singletonList(apiDefinition.getId()), apiDefinition.getProjectId()); if (!customFields.isEmpty()) { Map> customFieldMap = customFields.stream().collect(Collectors.groupingBy(ApiDefinitionCustomFieldDTO::getApiId)); diff --git a/frontend/src/views/api-test/management/components/management/api/apiTable.vue b/frontend/src/views/api-test/management/components/management/api/apiTable.vue index 3f67d63311..93ac7fa97b 100644 --- a/frontend/src/views/api-test/management/components/management/api/apiTable.vue +++ b/frontend/src/views/api-test/management/components/management/api/apiTable.vue @@ -383,6 +383,11 @@ }, width: 180, }, + { + title: 'common.creator', + dataIndex: 'createUserName', + width: 180, + }, { title: hasOperationPermission.value ? 'common.operation' : '', slotName: 'action',