fix(接口测试): 接口定义不传版本参数保存失败

This commit is contained in:
AgAngle 2024-03-05 11:17:05 +08:00 committed by 刘瑞斌
parent fc4e678645
commit 1665206b38
2 changed files with 4 additions and 1 deletions

View File

@ -186,6 +186,7 @@ public class ApiDefinitionService {
ProjectService.checkResourceExist(request.getProjectId());
ApiDefinition apiDefinition = new ApiDefinition();
BeanUtils.copyBean(apiDefinition, request);
apiDefinition.setVersionId(StringUtils.defaultIfBlank(request.getVersionId(), extBaseProjectVersionMapper.getDefaultVersion(request.getProjectId())));
checkAddExist(apiDefinition);
checkResponseNameCode(request.getResponse());
apiDefinition.setId(IDGenerator.nextStr());
@ -197,7 +198,6 @@ public class ApiDefinitionService {
apiDefinition.setUpdateUser(userId);
apiDefinition.setCreateTime(System.currentTimeMillis());
apiDefinition.setUpdateTime(System.currentTimeMillis());
apiDefinition.setVersionId(StringUtils.defaultIfBlank(request.getVersionId(), extBaseProjectVersionMapper.getDefaultVersion(request.getProjectId())));
apiDefinition.setRefId(apiDefinition.getId());
if (CollectionUtils.isNotEmpty(request.getTags())) {
apiDefinition.setTags(request.getTags());

View File

@ -248,8 +248,11 @@ public class ApiDefinitionControllerTests extends BaseTest {
request.setPath("/api/admin/posts");
request.setUploadFileIds(null);
request.setLinkFileIds(null);
String versionId = request.getVersionId();
request.setVersionId(null);
mvcResult = this.requestPostWithOkAndReturn(ADD, request);
resultData = getResultData(mvcResult, ApiDefinition.class);
request.setVersionId(versionId);
assertAddApiDefinition(request, msHttpElement, resultData.getId());
testHandleFileAssociationUpgrade();