feat(接口测试): 同步弹窗加场景复制判断以及工作台加更新时间判断

--user=郭雨琦
This commit is contained in:
guoyuqi 2022-08-17 19:44:34 +08:00 committed by xiaomeinvG
parent 4d1a44823c
commit c824ae45ab
5 changed files with 32 additions and 6 deletions

View File

@ -389,4 +389,9 @@ public class ApiDefinitionController {
apiDefinitionService.deleteApiDefinitionByVersion(refId, version);
}
@GetMapping("/be/cited/scenario/{definitionId}")
public Integer getCitedScenarioCount(@PathVariable String definitionId) {
return apiDefinitionService.getCitedScenarioCount(definitionId);
}
}

View File

@ -170,9 +170,12 @@ public class ApiDefinitionService {
private ApiAutomationService apiAutomationService;
@Resource
private FileAssociationService fileAssociationService;
@Resource
private ApiScenarioReferenceIdMapper apiScenarioReferenceIdMapper;
private final ThreadLocal<Long> currentApiOrder = new ThreadLocal<>();
private final ThreadLocal<Long> currentApiCaseOrder = new ThreadLocal<>();
private static final String COPY = "Copy";
public List<ApiDefinitionResult> list(ApiDefinitionRequest request) {
request = this.initRequest(request, true, true);
@ -860,7 +863,7 @@ public class ApiDefinitionService {
saveFollows(test.getId(), request.getFollows());
}
// 存储附件关系
fileAssociationService.saveApi(test.getId(), request.getRequest(),FileAssociationType.API.name());
fileAssociationService.saveApi(test.getId(), request.getRequest(), FileAssociationType.API.name());
return getById(test.getId());
}
@ -938,7 +941,7 @@ public class ApiDefinitionService {
for (int i = 0; i < caseList.size(); i++) {
ApiTestCaseWithBLOBs apiTestCaseWithBLOBs = caseList.get(i);
apiTestCaseWithBLOBs.setApiDefinitionId(apiDefinition.getId());
if (apiDefinition.getToBeUpdated() && StringUtils.equalsIgnoreCase(apiTestCaseWithBLOBs.getVersionId(), "old_case")) {
if (apiDefinition.getToBeUpdated() != null && apiDefinition.getToBeUpdated() && StringUtils.equalsIgnoreCase(apiTestCaseWithBLOBs.getVersionId(), "old_case")) {
apiTestCaseWithBLOBs.setToBeUpdated(true);
} else {
apiTestCaseWithBLOBs.setToBeUpdated(false);
@ -2695,4 +2698,11 @@ public class ApiDefinitionService {
extApiDefinitionMapper.updateNoModuleApiToDefaultModule(projectId, protocol, status, versionId, id);
}
}
public Integer getCitedScenarioCount(String testId) {
ApiScenarioReferenceIdExample apiScenarioReferenceIdExample = new ApiScenarioReferenceIdExample();
apiScenarioReferenceIdExample.createCriteria().andDataTypeEqualTo(ReportTriggerMode.API.name()).andReferenceTypeEqualTo(COPY).andReferenceIdEqualTo(testId);
List<ApiScenarioReferenceId> apiScenarioReferenceIds = apiScenarioReferenceIdMapper.selectByExample(apiScenarioReferenceIdExample);
return apiScenarioReferenceIds.size();
}
}

View File

@ -1305,6 +1305,7 @@ public class ApiTestCaseService {
Long toBeUpdatedTime = this.getToBeUpdatedTime(request.getProjectId());
if (toBeUpdatedTime != null) {
request.setToBeUpdateTime(toBeUpdatedTime);
request.setUpdateTime(toBeUpdatedTime);
}
List<String> syncRuleCaseStatus = apiTestCaseSyncService.getSyncRuleCaseStatus(request.getProjectId());
if (CollectionUtils.isEmpty(syncRuleCaseStatus)) {

View File

@ -513,10 +513,11 @@
and t1.to_be_updated = #{request.toBeUpdated}
</if>
<if test="request.toBeUpdated !=null and request.toBeUpdated == true and request.toBeUpdateTime !=null and request.statusList.size() > 0">
and (t1.to_be_update_time >= #{request.toBeUpdateTime} or t1.status in
and (t1.to_be_update_time >= #{request.toBeUpdateTime} or ( t1.status in
<foreach collection="request.statusList" item="value" separator="," open="(" close=")">
#{value}
</foreach>)
</foreach>
and t1.update_time>= #{request.updateTime} ))
</if>
<if test="request.toBeUpdated !=null and request.toBeUpdated == true and request.toBeUpdateTime !=null and request.statusList.size() == 0">
and t1.to_be_update_time >= #{request.toBeUpdateTime}

View File

@ -370,7 +370,8 @@ export default {
syncCase: true,
sendNotice: true,
},
noShowSyncRuleRelation: false
noShowSyncRuleRelation: false,
citedScenarioCount: 0
};
},
props: {moduleOptions: {}, request: {}, response: {}, basisData: {}, syncTabs: Array, projectId: String},
@ -583,7 +584,7 @@ export default {
this.httpForm.versionId = this.$refs.versionHistory.currentVersion.id;
}
}
if (hasLicense() && this.httpForm.caseTotal > 0 && !this.httpForm.isCopy) {
if (hasLicense() && (this.httpForm.caseTotal > 0 || this.citedScenarioCount > 0) && !this.httpForm.isCopy) {
if ((this.httpForm.method !== this.beforeHttpForm.method) && !this.noShowSyncRuleRelation) {
this.batchSyncApiVisible = true;
}
@ -964,6 +965,13 @@ export default {
this.noShowSyncRuleRelation = false;
this.saveApi();
}
},
getCitedScenarioCount() {
this.$get('/api/definition/be/cited/scenario/' + this.httpForm.id, response => {
if (response.data) {
this.citedScenarioCount = response.data;
}
});
}
},
@ -993,6 +1001,7 @@ export default {
if (hasLicense()) {
this.getVersionHistory();
this.getSyncRule();
this.getCitedScenarioCount();
}
},
mounted() {