fix(通用功能): 修复一个版本模块修改其他版本不跟随问题

--bug=1021055--user=郭雨琦
https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001021055
This commit is contained in:
guoyuqi 2022-12-20 17:59:59 +08:00 committed by xiaomeinvG
parent e97fb6027c
commit a3c0ec4aca
11 changed files with 51 additions and 3 deletions

View File

@ -85,6 +85,8 @@ public interface ExtApiDefinitionMapper {
void addLatestVersion(String refId); void addLatestVersion(String refId);
void updateVersionModule(@Param("refId") String refId, @Param("versionId") String versionId, @Param("moduleId") String moduleId, @Param("modulePath") String modulePath);
List<String> selectRefIdsForVersionChange(@Param("versionId") String versionId, @Param("projectId") String projectId); List<String> selectRefIdsForVersionChange(@Param("versionId") String versionId, @Param("projectId") String projectId);
String selectNameById(String testId); String selectNameById(String testId);

View File

@ -1168,6 +1168,14 @@
SELECT id FROM api_module WHERE project_id = #{projectId} AND protocol = #{protocol} SELECT id FROM api_module WHERE project_id = #{projectId} AND protocol = #{protocol}
) )
</update> </update>
<update id="updateVersionModule">
UPDATE api_definition
SET module_id = #{moduleId},
module_path = #{modulePath}
WHERE ref_id = #{refId}
AND version_id != #{versionId}
</update>
<select id="selectRefIdsForVersionChange" resultType="java.lang.String"> <select id="selectRefIdsForVersionChange" resultType="java.lang.String">
SELECT DISTINCT ref_id SELECT DISTINCT ref_id
FROM api_definition FROM api_definition

View File

@ -90,6 +90,8 @@ public interface ExtApiScenarioMapper {
void addLatestVersion(String refId); void addLatestVersion(String refId);
void updateVersionModule(@Param("refId") String refId, @Param("versionId") String versionId, @Param("moduleId") String moduleId, @Param("modulePath") String modulePath);
List<String> selectRefIdsForVersionChange(@Param("versionId") String versionId, @Param("projectId") String projectId); List<String> selectRefIdsForVersionChange(@Param("versionId") String versionId, @Param("projectId") String projectId);
List<ApiScenarioWithBLOBs> selectByStatusIsNotTrash(); List<ApiScenarioWithBLOBs> selectByStatusIsNotTrash();

View File

@ -856,6 +856,14 @@
WHERE ref_id = #{refId,jdbcType=VARCHAR} WHERE ref_id = #{refId,jdbcType=VARCHAR}
</update> </update>
<update id="updateVersionModule">
UPDATE api_scenario
SET api_scenario_module_id = #{moduleId},
module_path = #{modulePath}
WHERE ref_id = #{refId}
AND version_id != #{versionId}
</update>
<select id="selectRefIdsForVersionChange" resultType="java.lang.String"> <select id="selectRefIdsForVersionChange" resultType="java.lang.String">
SELECT DISTINCT ref_id SELECT DISTINCT ref_id
FROM api_scenario FROM api_scenario

View File

@ -787,7 +787,8 @@ public class ApiDefinitionService {
if (StringUtils.equalsIgnoreCase(request.getVersionId(), defaultVersion)) { if (StringUtils.equalsIgnoreCase(request.getVersionId(), defaultVersion)) {
checkAndSetLatestVersion(result.getRefId()); checkAndSetLatestVersion(result.getRefId());
} }
//同步修改所有版本的模块路径
updateOtherVersionModule(result);
// 存储附件关系 // 存储附件关系
extFileAssociationService.saveApi(test.getId(), request.getRequest(), FileAssociationTypeEnums.API.name()); extFileAssociationService.saveApi(test.getId(), request.getRequest(), FileAssociationTypeEnums.API.name());
//保存自定义字段 //保存自定义字段
@ -796,6 +797,10 @@ public class ApiDefinitionService {
return result; return result;
} }
private void updateOtherVersionModule(ApiDefinitionWithBLOBs result) {
extApiDefinitionMapper.updateVersionModule(result.getRefId(), result.getVersionId(), result.getModuleId(), result.getModulePath());
}
private void saveExtendInfo(SaveApiDefinitionRequest request, ApiDefinitionWithBLOBs test, ApiDefinitionWithBLOBs oldApi) { private void saveExtendInfo(SaveApiDefinitionRequest request, ApiDefinitionWithBLOBs test, ApiDefinitionWithBLOBs oldApi) {
// 创建新版是否关联备注 // 创建新版是否关联备注
if (!request.isNewVersionRemark()) { if (!request.isNewVersionRemark()) {

View File

@ -829,6 +829,6 @@ public class TestPlanApiCaseService {
ApiTestCaseExample example = new ApiTestCaseExample(); ApiTestCaseExample example = new ApiTestCaseExample();
example.createCriteria().andIdIn(apiCaseIds); example.createCriteria().andIdIn(apiCaseIds);
List<ApiTestCase> apiTestCases = apiTestCaseMapper.selectByExample(example); List<ApiTestCase> apiTestCases = apiTestCaseMapper.selectByExample(example);
return apiTestCases.stream().map(ApiTestCase::getProjectId).collect(Collectors.toList()); return apiTestCases.stream().map(ApiTestCase::getProjectId).distinct().collect(Collectors.toList());
} }
} }

View File

@ -1257,6 +1257,6 @@ public class TestPlanScenarioCaseService {
ApiScenarioExample example = new ApiScenarioExample(); ApiScenarioExample example = new ApiScenarioExample();
example.createCriteria().andIdIn(scenarioIds); example.createCriteria().andIdIn(scenarioIds);
List<ApiScenario> apiScenarios = apiScenarioMapper.selectByExample(example); List<ApiScenario> apiScenarios = apiScenarioMapper.selectByExample(example);
return apiScenarios.stream().map(ApiScenario::getProjectId).collect(Collectors.toList()); return apiScenarios.stream().map(ApiScenario::getProjectId).distinct().collect(Collectors.toList());
} }
} }

View File

@ -413,11 +413,17 @@ public class ApiScenarioService {
if (StringUtils.equalsIgnoreCase(request.getVersionId(), defaultVersion)) { if (StringUtils.equalsIgnoreCase(request.getVersionId(), defaultVersion)) {
checkAndSetLatestVersion(beforeScenario.getRefId()); checkAndSetLatestVersion(beforeScenario.getRefId());
} }
//同步修改所有版本的模块路径
updateOtherVersionModule(beforeScenario.getRefId(), scenario);
// 存储附件关系 // 存储附件关系
extFileAssociationService.saveScenario(scenario.getId(), request.getScenarioDefinition()); extFileAssociationService.saveScenario(scenario.getId(), request.getScenarioDefinition());
return scenario; return scenario;
} }
private void updateOtherVersionModule(String refId, ApiScenarioWithBLOBs scenario) {
extApiScenarioMapper.updateVersionModule(refId, scenario.getVersionId(), scenario.getApiScenarioModuleId(), scenario.getModulePath());
}
private void checkReferenceCase(ApiScenarioWithBLOBs scenario, ApiScenarioParamDTO apiScenarioParamDto) { private void checkReferenceCase(ApiScenarioWithBLOBs scenario, ApiScenarioParamDTO apiScenarioParamDto) {
if (scenario == null || StringUtils.isEmpty(scenario.getScenarioDefinition())) { if (scenario == null || StringUtils.isEmpty(scenario.getScenarioDefinition())) {
return; return;

View File

@ -150,6 +150,9 @@ public interface ExtTestCaseMapper {
int addLatestVersion(@Param("refId") String refId); int addLatestVersion(@Param("refId") String refId);
void updateVersionModule(@Param("refId") String refId, @Param("versionId") String versionId, @Param("moduleId") String moduleId, @Param("modulePath") String modulePath);
List<TestCase> getMaintainerMap(@Param("request") QueryTestCaseRequest request); List<TestCase> getMaintainerMap(@Param("request") QueryTestCaseRequest request);
List<TestCaseDTO> getForNodeEdit(@Param("ids") List<String> ids); List<TestCaseDTO> getForNodeEdit(@Param("ids") List<String> ids);

View File

@ -1266,6 +1266,14 @@
WHERE ref_id = #{refId,jdbcType=VARCHAR} WHERE ref_id = #{refId,jdbcType=VARCHAR}
</update> </update>
<update id="updateVersionModule">
UPDATE test_case
SET node_id = #{moduleId},
node_path = #{modulePath}
WHERE ref_id = #{refId}
AND version_id != #{versionId}
</update>
<update id="bathUpdateByCondition"> <update id="bathUpdateByCondition">
update test_case update test_case
<set> <set>

View File

@ -467,9 +467,15 @@ public class TestCaseService {
if (StringUtils.equalsIgnoreCase(testCase.getVersionId(), defaultVersion)) { if (StringUtils.equalsIgnoreCase(testCase.getVersionId(), defaultVersion)) {
checkAndSetLatestVersion(testCase.getRefId()); checkAndSetLatestVersion(testCase.getRefId());
} }
//同步修改所有版本的模块路径
updateOtherVersionModule(testCase);
} }
private void updateOtherVersionModule(EditTestCaseRequest testCase) {
extTestCaseMapper.updateVersionModule(testCase.getRefId(), testCase.getVersionId(), testCase.getNodeId(), testCase.getNodePath());
}
/** /**
* 处理其他信息的复制问题 * 处理其他信息的复制问题
* *