fix: 解决冲突

This commit is contained in:
chenjianxing 2021-01-26 15:12:33 +08:00
commit 824a5a9f0e
7 changed files with 58 additions and 30 deletions

View File

@ -55,6 +55,9 @@ public class ApiDefinitionExecResultService {
saveResult.setCreateTime(System.currentTimeMillis()); saveResult.setCreateTime(System.currentTimeMillis());
saveResult.setUserId(Objects.requireNonNull(SessionUtils.getUser()).getId()); saveResult.setUserId(Objects.requireNonNull(SessionUtils.getUser()).getId());
saveResult.setName(item.getName()); saveResult.setName(item.getName());
if (item.getName().indexOf("<->") != -1) {
saveResult.setName(item.getName().substring(0, item.getName().indexOf("<->")));
}
saveResult.setResourceId(item.getName()); saveResult.setResourceId(item.getName());
saveResult.setContent(JSON.toJSONString(item)); saveResult.setContent(JSON.toJSONString(item));
saveResult.setStartTime(item.getStartTime()); saveResult.setStartTime(item.getStartTime());

View File

@ -14,6 +14,7 @@ import io.metersphere.api.dto.scenario.request.RequestType;
import io.metersphere.api.dto.swaggerurl.SwaggerTaskResult; import io.metersphere.api.dto.swaggerurl.SwaggerTaskResult;
import io.metersphere.api.dto.swaggerurl.SwaggerUrlRequest; import io.metersphere.api.dto.swaggerurl.SwaggerUrlRequest;
import io.metersphere.api.jmeter.JMeterService; import io.metersphere.api.jmeter.JMeterService;
import io.metersphere.api.jmeter.RequestResult;
import io.metersphere.api.jmeter.TestResult; import io.metersphere.api.jmeter.TestResult;
import io.metersphere.api.parse.ApiImportParser; import io.metersphere.api.parse.ApiImportParser;
import io.metersphere.api.parse.ApiImportParserFactory; import io.metersphere.api.parse.ApiImportParserFactory;
@ -297,7 +298,7 @@ public class ApiDefinitionService {
} }
} }
private ApiDefinition importCreate(ApiDefinitionResult request, ApiDefinitionMapper batchMapper,ApiTestImportRequest apiTestImportRequest) { private ApiDefinition importCreate(ApiDefinitionResult request, ApiDefinitionMapper batchMapper, ApiTestImportRequest apiTestImportRequest) {
SaveApiDefinitionRequest saveReq = new SaveApiDefinitionRequest(); SaveApiDefinitionRequest saveReq = new SaveApiDefinitionRequest();
BeanUtils.copyBean(saveReq, request); BeanUtils.copyBean(saveReq, request);
final ApiDefinitionWithBLOBs apiDefinition = new ApiDefinitionWithBLOBs(); final ApiDefinitionWithBLOBs apiDefinition = new ApiDefinitionWithBLOBs();
@ -313,7 +314,7 @@ public class ApiDefinitionService {
apiDefinition.setDescription(request.getDescription()); apiDefinition.setDescription(request.getDescription());
List<ApiDefinition> sameRequest = getSameRequest(saveReq); List<ApiDefinition> sameRequest = getSameRequest(saveReq);
if(StringUtils.equals("fullCoverage",apiTestImportRequest.getModeId())){ if (StringUtils.equals("fullCoverage", apiTestImportRequest.getModeId())) {
if (CollectionUtils.isEmpty(sameRequest)) { if (CollectionUtils.isEmpty(sameRequest)) {
batchMapper.insert(apiDefinition); batchMapper.insert(apiDefinition);
} else { } else {
@ -321,9 +322,9 @@ public class ApiDefinitionService {
apiDefinition.setId(sameRequest.get(0).getId()); apiDefinition.setId(sameRequest.get(0).getId());
apiDefinitionMapper.updateByPrimaryKeyWithBLOBs(apiDefinition); apiDefinitionMapper.updateByPrimaryKeyWithBLOBs(apiDefinition);
} }
}else if(StringUtils.equals("incrementalMerge",apiTestImportRequest.getModeId())){ } else if (StringUtils.equals("incrementalMerge", apiTestImportRequest.getModeId())) {
batchMapper.insert(apiDefinition); batchMapper.insert(apiDefinition);
}else{ } else {
if (CollectionUtils.isEmpty(sameRequest)) { if (CollectionUtils.isEmpty(sameRequest)) {
batchMapper.insert(apiDefinition); batchMapper.insert(apiDefinition);
} else { } else {
@ -372,7 +373,11 @@ public class ApiDefinitionService {
public void addResult(TestResult res) { public void addResult(TestResult res) {
if (!res.getScenarios().isEmpty() && !res.getScenarios().get(0).getRequestResults().isEmpty()) { if (!res.getScenarios().isEmpty() && !res.getScenarios().get(0).getRequestResults().isEmpty()) {
cache.put(res.getTestId(), res.getScenarios().get(0).getRequestResults().get(0)); RequestResult result = res.getScenarios().get(0).getRequestResults().get(0);
if (result.getName().indexOf("<->") != -1) {
result.setName(result.getName().substring(0, result.getName().indexOf("<->")));
}
cache.put(res.getTestId(), result);
} else { } else {
MSException.throwException(Translator.get("test_not_found")); MSException.throwException(Translator.get("test_not_found"));
} }
@ -451,7 +456,7 @@ public class ApiDefinitionService {
item.setName(item.getName().substring(0, 255)); item.setName(item.getName().substring(0, 255));
} }
item.setNum(num++); item.setNum(num++);
importCreate(item, batchMapper,request); importCreate(item, batchMapper, request);
if (i % 300 == 0) { if (i % 300 == 0) {
sqlSession.flushStatements(); sqlSession.flushStatements();
} }
@ -614,7 +619,7 @@ public class ApiDefinitionService {
/*swagger定时导入*/ /*swagger定时导入*/
public void createSchedule(Schedule request) { public void createSchedule(Schedule request) {
/*保存swaggerUrl*/ /*保存swaggerUrl*/
SwaggerUrlProject swaggerUrlProject=new SwaggerUrlProject(); SwaggerUrlProject swaggerUrlProject = new SwaggerUrlProject();
swaggerUrlProject.setId(UUID.randomUUID().toString()); swaggerUrlProject.setId(UUID.randomUUID().toString());
swaggerUrlProject.setProjectId(request.getProjectId()); swaggerUrlProject.setProjectId(request.getProjectId());
swaggerUrlProject.setSwaggerUrl(request.getResourceId()); swaggerUrlProject.setSwaggerUrl(request.getResourceId());
@ -631,33 +636,38 @@ public class ApiDefinitionService {
this.addOrUpdateSwaggerImportCronJob(request); this.addOrUpdateSwaggerImportCronJob(request);
} }
//关闭 //关闭
public void updateSchedule(Schedule request){ public void updateSchedule(Schedule request) {
scheduleService.editSchedule(request); scheduleService.editSchedule(request);
this.addOrUpdateSwaggerImportCronJob(request); this.addOrUpdateSwaggerImportCronJob(request);
} }
//删除 //删除
public void deleteSchedule(ScheduleInfoSwaggerUrlRequest request){ public void deleteSchedule(ScheduleInfoSwaggerUrlRequest request) {
swaggerUrlProjectMapper.deleteByPrimaryKey(request.getId()); swaggerUrlProjectMapper.deleteByPrimaryKey(request.getId());
scheduleMapper.deleteByPrimaryKey(request.getTaskId()); scheduleMapper.deleteByPrimaryKey(request.getTaskId());
} }
//查询swaggerUrl详情 //查询swaggerUrl详情
public SwaggerUrlProject getSwaggerInfo(String resourceId){ public SwaggerUrlProject getSwaggerInfo(String resourceId) {
return swaggerUrlProjectMapper.selectByPrimaryKey(resourceId); return swaggerUrlProjectMapper.selectByPrimaryKey(resourceId);
} }
public String getResourceId(SwaggerUrlRequest swaggerUrlRequest){
SwaggerUrlProjectExample swaggerUrlProjectExample=new SwaggerUrlProjectExample(); public String getResourceId(SwaggerUrlRequest swaggerUrlRequest) {
SwaggerUrlProjectExample.Criteria criteria=swaggerUrlProjectExample.createCriteria(); SwaggerUrlProjectExample swaggerUrlProjectExample = new SwaggerUrlProjectExample();
SwaggerUrlProjectExample.Criteria criteria = swaggerUrlProjectExample.createCriteria();
criteria.andProjectIdEqualTo(swaggerUrlRequest.getProjectId()).andSwaggerUrlEqualTo(swaggerUrlRequest.getSwaggerUrl()).andModuleIdEqualTo(swaggerUrlRequest.getModuleId()); criteria.andProjectIdEqualTo(swaggerUrlRequest.getProjectId()).andSwaggerUrlEqualTo(swaggerUrlRequest.getSwaggerUrl()).andModuleIdEqualTo(swaggerUrlRequest.getModuleId());
List<SwaggerUrlProject> list=swaggerUrlProjectMapper.selectByExample(swaggerUrlProjectExample); List<SwaggerUrlProject> list = swaggerUrlProjectMapper.selectByExample(swaggerUrlProjectExample);
String resourceId=""; String resourceId = "";
if(list.size()==1){ if (list.size() == 1) {
resourceId=list.get(0).getId(); resourceId = list.get(0).getId();
} }
return resourceId; return resourceId;
} }
public List<SwaggerTaskResult> getSwaggerScheduleList(String projectId){
public List<SwaggerTaskResult> getSwaggerScheduleList(String projectId) {
return extSwaggerUrlScheduleMapper.getSwaggerTaskList(projectId); return extSwaggerUrlScheduleMapper.getSwaggerTaskList(projectId);
} }

View File

@ -412,6 +412,7 @@ public class HistoricalDataUpgradeService {
MsScenario step = new MsScenario(); MsScenario step = new MsScenario();
step.setId(scenario1.getId()); step.setId(scenario1.getId());
step.setName(scenario1.getName()); step.setName(scenario1.getName());
step.setEnable(scenario.isEnable());
step.setType("scenario"); step.setType("scenario");
step.setResourceId(UUID.randomUUID().toString()); step.setResourceId(UUID.randomUUID().toString());
step.setReferenced("REF"); step.setReferenced("REF");

View File

@ -14,7 +14,7 @@
<el-tag size="mini" style="margin-left: 20px" v-if="request.referenced==='Deleted'" type="danger">{{$t('api_test.automation.reference_deleted')}}</el-tag> <el-tag size="mini" style="margin-left: 20px" v-if="request.referenced==='Deleted'" type="danger">{{$t('api_test.automation.reference_deleted')}}</el-tag>
<el-tag size="mini" style="margin-left: 20px" v-if="request.referenced==='Copy'">{{ $t('commons.copy') }}</el-tag> <el-tag size="mini" style="margin-left: 20px" v-if="request.referenced==='Copy'">{{ $t('commons.copy') }}</el-tag>
<el-tag size="mini" style="margin-left: 20px" v-if="request.referenced ==='REF'">{{ $t('api_test.scenario.reference') }}</el-tag> <el-tag size="mini" style="margin-left: 20px" v-if="request.referenced ==='REF'">{{ $t('api_test.scenario.reference') }}</el-tag>
<ms-run :debug="false" :reportId="reportId" :run-data="runData" <ms-run :debug="true" :reportId="reportId" :run-data="runData"
@runRefresh="runRefresh" ref="runTest"/> @runRefresh="runRefresh" ref="runTest"/>
</template> </template>

View File

@ -42,6 +42,12 @@
this.isActive = true; this.isActive = true;
} }
}, },
watch: {
result() {
this.response = this.result;
this.isActive = true;
}
},
methods: { methods: {
getExecResult() { getExecResult() {
// //

View File

@ -25,15 +25,15 @@
</span> </span>
<span class="node-title">{{node.label}}</span> <span class="node-title">{{node.label}}</span>
</span> </span>
</template> </template>
</el-tree> </el-tree>
</div> </div>
<template v-slot:footer> <template v-slot:footer>
<ms-dialog-footer <ms-dialog-footer
@cancel="close" @cancel="close"
@confirm="save"/> @confirm="save"/>
</template> </template>
</el-dialog> </el-dialog>
</div> </div>
</template> </template>

View File

@ -257,9 +257,10 @@
<el-table-column prop="description" :label="$t('test_track.issue.description')"> <el-table-column prop="description" :label="$t('test_track.issue.description')">
<template v-slot:default="scope"> <template v-slot:default="scope">
<el-popover <el-popover
placement="left" placement="right"
width="400" width="500"
trigger="hover" trigger="hover"
popper-class="issues-popover"
> >
<ckeditor :editor="editor" disabled :config="readConfig" <ckeditor :editor="editor" disabled :config="readConfig"
v-model="scope.row.description"/> v-model="scope.row.description"/>
@ -748,3 +749,10 @@ p {
z-index: 999; z-index: 999;
} }
</style> </style>
<style>
.issues-popover {
height: 550px;
overflow: auto;
}
</style>