parent
3084e16062
commit
056558a871
|
@ -626,7 +626,14 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
|||
if (apiImport.getEsbApiParamsMap() != null) {
|
||||
fullCoverage = true;
|
||||
}
|
||||
String updateVersionId = getUpdateVersionId(request, fullCoverage);
|
||||
Set<String> versionSet = new HashSet<>();
|
||||
|
||||
if (fullCoverage) {
|
||||
setFullVersionSet(request, versionSet);
|
||||
} else {
|
||||
String updateVersionId = getUpdateVersionId(request);
|
||||
versionSet.add(updateVersionId);
|
||||
}
|
||||
|
||||
//需要新增的模块,key 为模块路径
|
||||
Map<String, ApiModule> moduleMap = new HashMap<>();
|
||||
|
@ -669,9 +676,9 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
|||
List<ApiDefinitionWithBLOBs> repeatApiDefinitionWithBLOBs;
|
||||
|
||||
if (chooseModule != null) {
|
||||
repeatApiDefinitionWithBLOBs = extApiDefinitionMapper.selectRepeatByBLOBsSameUrl(optionData, projectId, chooseModule.getId(), updateVersionId);
|
||||
repeatApiDefinitionWithBLOBs = extApiDefinitionMapper.selectRepeatByBLOBsSameUrl(optionData, projectId, chooseModule.getId(), versionSet);
|
||||
} else {
|
||||
repeatApiDefinitionWithBLOBs = extApiDefinitionMapper.selectRepeatByBLOBs(optionData, projectId, updateVersionId);
|
||||
repeatApiDefinitionWithBLOBs = extApiDefinitionMapper.selectRepeatByBLOBs(optionData, projectId, versionSet);
|
||||
}
|
||||
|
||||
//处理数据
|
||||
|
@ -777,20 +784,29 @@ public class ApiModuleService extends NodeTreeService<ApiModuleDTO> {
|
|||
}
|
||||
}
|
||||
|
||||
private String getUpdateVersionId(ApiTestImportRequest request, Boolean fullCoverage) {
|
||||
String updateVersionId;
|
||||
if (!fullCoverage) {
|
||||
if (request.getVersionId() == null) {
|
||||
updateVersionId = request.getDefaultVersion();
|
||||
} else {
|
||||
updateVersionId = request.getVersionId();
|
||||
}
|
||||
private void setFullVersionSet(ApiTestImportRequest request, Set<String> versionSet) {
|
||||
String creatVersionId;
|
||||
if (request.getVersionId() != null) {
|
||||
creatVersionId = request.getVersionId();
|
||||
} else {
|
||||
if (request.getUpdateVersionId() == null) {
|
||||
updateVersionId = request.getDefaultVersion();
|
||||
} else {
|
||||
updateVersionId = request.getUpdateVersionId();
|
||||
}
|
||||
creatVersionId = request.getDefaultVersion();
|
||||
}
|
||||
versionSet.add(creatVersionId);
|
||||
String updateVersionId;
|
||||
if (request.getUpdateVersionId() != null) {
|
||||
updateVersionId = request.getUpdateVersionId();
|
||||
} else {
|
||||
updateVersionId = request.getDefaultVersion();
|
||||
}
|
||||
versionSet.add(updateVersionId);
|
||||
}
|
||||
|
||||
private String getUpdateVersionId(ApiTestImportRequest request) {
|
||||
String updateVersionId;
|
||||
if (request.getVersionId() == null) {
|
||||
updateVersionId = request.getDefaultVersion();
|
||||
} else {
|
||||
updateVersionId = request.getVersionId();
|
||||
}
|
||||
return updateVersionId;
|
||||
}
|
||||
|
|
|
@ -511,7 +511,15 @@ public class ApiScenarioModuleService extends NodeTreeService<ApiScenarioModuleD
|
|||
chooseModule = idModuleMap.get(chooseModuleId);
|
||||
}
|
||||
|
||||
String updateVersionId = getUpdateVersionId(request, fullCoverage);
|
||||
Set<String> versionSet = new HashSet<>();
|
||||
|
||||
if (fullCoverage) {
|
||||
setFullVersionSet(request, versionSet);
|
||||
} else {
|
||||
String updateVersionId = getUpdateVersionId(request);
|
||||
versionSet.add(updateVersionId);
|
||||
}
|
||||
|
||||
|
||||
List<ApiScenarioWithBLOBs> optionData = new ArrayList<>();
|
||||
|
||||
|
@ -525,9 +533,9 @@ public class ApiScenarioModuleService extends NodeTreeService<ApiScenarioModuleD
|
|||
//系统内重复的数据
|
||||
List<ApiScenarioWithBLOBs> repeatApiScenarioWithBLOBs;
|
||||
if (chooseModule != null) {
|
||||
repeatApiScenarioWithBLOBs = extApiScenarioMapper.selectRepeatByBLOBsSameUrl(optionData, projectId, chooseModule.getId(), updateVersionId);
|
||||
repeatApiScenarioWithBLOBs = extApiScenarioMapper.selectRepeatByBLOBsSameUrl(optionData, projectId, chooseModule.getId(), versionSet);
|
||||
} else {
|
||||
repeatApiScenarioWithBLOBs = extApiScenarioMapper.selectRepeatByBLOBs(optionData, projectId, updateVersionId);
|
||||
repeatApiScenarioWithBLOBs = extApiScenarioMapper.selectRepeatByBLOBs(optionData, projectId, versionSet);
|
||||
}
|
||||
|
||||
Map<String, ApiScenarioWithBLOBs> nameModuleMap = null;
|
||||
|
@ -566,6 +574,23 @@ public class ApiScenarioModuleService extends NodeTreeService<ApiScenarioModuleD
|
|||
return updateScenarioModuleDTO;
|
||||
}
|
||||
|
||||
private void setFullVersionSet(ApiTestImportRequest request, Set<String> versionSet) {
|
||||
String creatVersionId;
|
||||
if (request.getVersionId() != null) {
|
||||
creatVersionId = request.getVersionId();
|
||||
} else {
|
||||
creatVersionId = request.getDefaultVersion();
|
||||
}
|
||||
versionSet.add(creatVersionId);
|
||||
String updateVersionId;
|
||||
if (request.getUpdateVersionId() != null) {
|
||||
updateVersionId = request.getUpdateVersionId();
|
||||
} else {
|
||||
updateVersionId = request.getDefaultVersion();
|
||||
}
|
||||
versionSet.add(updateVersionId);
|
||||
}
|
||||
|
||||
private void removeRepeat(List<ApiScenarioWithBLOBs> optionData, Map<String, ApiScenarioWithBLOBs> nameModuleMap, Map<String, ApiScenarioWithBLOBs> repeatDataMap) {
|
||||
if (repeatDataMap != null) {
|
||||
repeatDataMap.forEach((k, v) -> {
|
||||
|
@ -622,20 +647,12 @@ public class ApiScenarioModuleService extends NodeTreeService<ApiScenarioModuleD
|
|||
}
|
||||
}
|
||||
|
||||
private String getUpdateVersionId(ApiTestImportRequest request, Boolean fullCoverage) {
|
||||
private String getUpdateVersionId(ApiTestImportRequest request) {
|
||||
String updateVersionId;
|
||||
if (!fullCoverage) {
|
||||
if (request.getVersionId() == null) {
|
||||
updateVersionId = request.getDefaultVersion();
|
||||
} else {
|
||||
updateVersionId = request.getVersionId();
|
||||
}
|
||||
if (request.getVersionId() == null) {
|
||||
updateVersionId = request.getDefaultVersion();
|
||||
} else {
|
||||
if (request.getUpdateVersionId() == null) {
|
||||
updateVersionId = request.getDefaultVersion();
|
||||
} else {
|
||||
updateVersionId = request.getUpdateVersionId();
|
||||
}
|
||||
updateVersionId = request.getVersionId();
|
||||
}
|
||||
return updateVersionId;
|
||||
}
|
||||
|
|
|
@ -93,9 +93,9 @@ public interface ExtApiDefinitionMapper {
|
|||
|
||||
int toBeUpdateApi(@Param("ids") List<String> ids, @Param("toBeUpdate") Boolean toBeUpdate);
|
||||
|
||||
List<ApiDefinitionWithBLOBs> selectRepeatByBLOBs(@Param("blobs") List<ApiDefinitionWithBLOBs> blobs, @Param("projectId") String projectId, @Param("versionId") String versionId);
|
||||
List<ApiDefinitionWithBLOBs> selectRepeatByBLOBs(@Param("blobs") List<ApiDefinitionWithBLOBs> blobs, @Param("projectId") String projectId, @Param("versionIds") Set<String> versionIds);
|
||||
|
||||
List<ApiDefinitionWithBLOBs> selectRepeatByBLOBsSameUrl(@Param("blobs") List<ApiDefinitionWithBLOBs> blobs, @Param("projectId") String projectId, @Param("moduleId") String moduleId, @Param("versionId") String versionId);
|
||||
List<ApiDefinitionWithBLOBs> selectRepeatByBLOBsSameUrl(@Param("blobs") List<ApiDefinitionWithBLOBs> blobs, @Param("projectId") String projectId, @Param("moduleId") String moduleId, @Param("versionIds") Set<String> versionIds);
|
||||
|
||||
|
||||
int countById(String id);
|
||||
|
|
|
@ -1016,7 +1016,10 @@
|
|||
<include refid="Same_Where_Clause"/>
|
||||
and status != 'Trash'
|
||||
and project_id = #{projectId}
|
||||
and version_id = #{versionId}
|
||||
and version_id in
|
||||
<foreach collection="versionIds" item="versionId" separator="," open="(" close=")">
|
||||
#{versionId}
|
||||
</foreach>
|
||||
</select>
|
||||
<select id="selectRepeatByBLOBsSameUrl" resultType="io.metersphere.base.domain.ApiDefinitionWithBLOBs">
|
||||
SELECT * from api_definition
|
||||
|
@ -1024,7 +1027,10 @@
|
|||
and status != 'TRASH'
|
||||
and project_id = #{projectId}
|
||||
and module_id = #{moduleId}
|
||||
and version_id = #{versionId}
|
||||
and version_id in
|
||||
<foreach collection="versionIds" item="versionId" separator="," open="(" close=")">
|
||||
#{versionId}
|
||||
</foreach>
|
||||
</select>
|
||||
<sql id="Same_Where_Clause">
|
||||
<where>
|
||||
|
|
|
@ -91,9 +91,9 @@ public interface ExtApiScenarioMapper {
|
|||
|
||||
List<ApiScenarioWithBLOBs> selectByStatusIsNotTrash();
|
||||
|
||||
List<ApiScenarioWithBLOBs> selectRepeatByBLOBs(@Param("blobs") List<ApiScenarioWithBLOBs> blobs, @Param("projectId") String projectId, @Param("versionId") String versionId);
|
||||
List<ApiScenarioWithBLOBs> selectRepeatByBLOBs(@Param("blobs") List<ApiScenarioWithBLOBs> blobs, @Param("projectId") String projectId, @Param("versionIds") Set<String> versionIds);
|
||||
|
||||
List<ApiScenarioWithBLOBs> selectRepeatByBLOBsSameUrl(@Param("blobs") List<ApiScenarioWithBLOBs> blobs, @Param("projectId") String projectId, @Param("moduleId") String moduleId, @Param("versionId") String versionId);
|
||||
List<ApiScenarioWithBLOBs> selectRepeatByBLOBsSameUrl(@Param("blobs") List<ApiScenarioWithBLOBs> blobs, @Param("projectId") String projectId, @Param("moduleId") String moduleId, @Param("versionIds") Set<String> versionIds);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -776,7 +776,10 @@
|
|||
<include refid="Same_Where_Clause"/>
|
||||
and status != 'Trash'
|
||||
and project_id = #{projectId}
|
||||
and version_id = #{versionId}
|
||||
and version_id in
|
||||
<foreach collection="versionIds" item="versionId" separator="," open="(" close=")">
|
||||
#{versionId}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="selectRepeatByBLOBsSameUrl" resultType="io.metersphere.base.domain.ApiScenarioWithBLOBs">
|
||||
|
@ -785,7 +788,10 @@
|
|||
and status != 'TRASH'
|
||||
and api_scenario_module_id = #{moduleId}
|
||||
and project_id = #{projectId}
|
||||
and version_id = #{versionId}
|
||||
and version_id in
|
||||
<foreach collection="versionIds" item="versionId" separator="," open="(" close=")">
|
||||
#{versionId}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<sql id="Same_Where_Clause">
|
||||
|
|
Loading…
Reference in New Issue