fix(接口测试): 修复接口列表不显示创建人的缺陷

--bug=1037484 --user=王孝刚 【接口测试】接口定义-API列表没有创建人字段
https://www.tapd.cn/55049933/s/1479075
This commit is contained in:
wxg0103 2024-03-22 11:50:51 +08:00 committed by 刘瑞斌
parent 31549256e4
commit d6decdbcdc
3 changed files with 19 additions and 1 deletions

View File

@ -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<String> userIds = extractUserIds(List.of(apiDefinitionDTO));
Map<String, String> userMap = userLoginService.getUserNameMap(new ArrayList<>(userIds));
apiDefinitionDTO.setCreateUserName(userMap.get(apiDefinitionDTO.getCreateUser()));
apiDefinitionDTO.setUpdateUserName(userMap.get(apiDefinitionDTO.getUpdateUser()));
return apiDefinitionDTO;
}

View File

@ -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<ApiDefinitionFollower> followers = apiDefinitionFollowerMapper.selectByExample(example);
copyApiDefinitionDTO.setFollow(CollectionUtils.isNotEmpty(followers));
Set<String> userIds = List.of(apiDefinitionDTO).stream()
.flatMap(apiDefinition -> Stream.of(apiDefinition.getUpdateUser(), apiDefinition.getDeleteUser(), apiDefinition.getCreateUser()))
.collect(Collectors.toSet());
Map<String, String> userMap = userLoginService.getUserNameMap(new ArrayList<>(userIds));
copyApiDefinitionDTO.setCreateUserName(userMap.get(apiDefinitionDTO.getCreateUser()));
copyApiDefinitionDTO.setUpdateUserName(userMap.get(apiDefinitionDTO.getUpdateUser()));
List<ApiDefinitionCustomFieldDTO> customFields = extApiDefinitionCustomFieldMapper.getApiCustomFields(Collections.singletonList(apiDefinition.getId()), apiDefinition.getProjectId());
if (!customFields.isEmpty()) {
Map<String, List<ApiDefinitionCustomFieldDTO>> customFieldMap = customFields.stream().collect(Collectors.groupingBy(ApiDefinitionCustomFieldDTO::getApiId));

View File

@ -383,6 +383,11 @@
},
width: 180,
},
{
title: 'common.creator',
dataIndex: 'createUserName',
width: 180,
},
{
title: hasOperationPermission.value ? 'common.operation' : '',
slotName: 'action',