This commit is contained in:
liqiang-fit2cloud 2022-12-21 10:22:27 +08:00
commit a9594c857a
23 changed files with 87 additions and 36 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

@ -532,6 +532,7 @@ public class ApiDefinitionImportUtilService {
updateApiList.add(definitionWithBLOBs); updateApiList.add(definitionWithBLOBs);
} }
} }
apiDefinitionWithBLOBs.setRefId(latestApi.getRefId());
apiDefinitionWithBLOBs.setVersionId("trash"); apiDefinitionWithBLOBs.setVersionId("trash");
} else { } else {
addNewVersionApi(apiDefinitionWithBLOBs, latestApi, "update"); addNewVersionApi(apiDefinitionWithBLOBs, latestApi, "update");

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

@ -471,7 +471,7 @@ export default {
zentao_bug_build: "Zentao Impact version", zentao_bug_build: "Zentao Impact version",
zentao_bug_assigned: "Zentao handler", zentao_bug_assigned: "Zentao handler",
third_party_integrated: "Third-party Platform", third_party_integrated: "Third-party Platform",
use_third_party: "Enable Jira Issue Template", use_third_party: "Enable {0} Issue Template",
update_third_party_bugs: "Update the defects of third-party platforms", update_third_party_bugs: "Update the defects of third-party platforms",
sync_bugs: "Synchronization Issue", sync_bugs: "Synchronization Issue",
sync_complete: "Synchronization complete", sync_complete: "Synchronization complete",

View File

@ -474,7 +474,7 @@ export default {
zentao_bug_build: "禅道 影响版本", zentao_bug_build: "禅道 影响版本",
zentao_bug_assigned: "禅道 处理人", zentao_bug_assigned: "禅道 处理人",
third_party_integrated: "集成第三方平台", third_party_integrated: "集成第三方平台",
use_third_party: "使用 Jira 缺陷模板", use_third_party: "使用 {0} 缺陷模板",
update_third_party_bugs: "更新第三方平台的缺陷", update_third_party_bugs: "更新第三方平台的缺陷",
sync_bugs: "同步缺陷", sync_bugs: "同步缺陷",
sync_complete: "同步完成", sync_complete: "同步完成",

View File

@ -474,7 +474,7 @@ export default {
zentao_bug_build: "禪道 影響版本", zentao_bug_build: "禪道 影響版本",
zentao_bug_assigned: "禪道 處理人", zentao_bug_assigned: "禪道 處理人",
third_party_integrated: "集成第三方平臺", third_party_integrated: "集成第三方平臺",
use_third_party: "使用 Jira 缺陷模闆", use_third_party: "使用 {0} 缺陷模闆",
update_third_party_bugs: "更新第三方平臺的缺陷", update_third_party_bugs: "更新第三方平臺的缺陷",
sync_bugs: "同步缺陷", sync_bugs: "同步缺陷",
sync_complete: "同步完成", sync_complete: "同步完成",

View File

@ -185,7 +185,8 @@ public abstract class JSR223TestElement extends ScriptingTestElement
File scriptFile = new File(getFilename()); File scriptFile = new File(getFilename());
// Hack: bsh-2.0b5.jar BshScriptEngine implements Compilable but throws // Hack: bsh-2.0b5.jar BshScriptEngine implements Compilable but throws
// "java.lang.Error: unimplemented" // "java.lang.Error: unimplemented"
boolean supportsCompilable = false; boolean supportsCompilable = scriptEngine instanceof Compilable
&& !"bsh.engine.BshScriptEngine".equals(scriptEngine.getClass().getName()); // NOSONAR // $NON-NLS-1$
try { try {
if (!StringUtils.isEmpty(getFilename())) { if (!StringUtils.isEmpty(getFilename())) {
if (scriptFile.exists() && scriptFile.canRead()) { if (scriptFile.exists() && scriptFile.canRead()) {

View File

@ -31,7 +31,7 @@
<el-checkbox @change="thirdPartTemplateChange" v-if="thirdPartTemplateSupport" <el-checkbox @change="thirdPartTemplateChange" v-if="thirdPartTemplateSupport"
v-model="form.thirdPartTemplate" style="margin-left: 10px"> v-model="form.thirdPartTemplate" style="margin-left: 10px">
{{ $t('test_track.issue.use_third_party') }} {{ $t('test_track.issue.use_third_party', [form.platform]) }}
</el-checkbox> </el-checkbox>
</el-form-item> </el-form-item>

View File

@ -90,7 +90,8 @@ export default {
getPlatformProjectInfo(this.platformKey) getPlatformProjectInfo(this.platformKey)
.then(r => { .then(r => {
if (r.data) { if (r.data) {
Object.assign(this.form, this.projectConfig); let form = {};
Object.assign(form, this.projectConfig);
this.handleProjectConfigCompatible(); this.handleProjectConfigCompatible();
r.data.formItems.forEach(item => { r.data.formItems.forEach(item => {
@ -98,18 +99,19 @@ export default {
item.options = []; item.options = [];
} }
// //
if (this.form[item.name]) { if (form[item.name]) {
this.$set(item, 'defaultValue', this.form[item.name]); this.$set(item, 'defaultValue', form[item.name]);
} }
// //
if (item.cascade && this.form[item.name]) { if (item.cascade && form[item.cascade]) {
this.getCascadeOptions(item, () => { this.getCascadeOptions(item, () => {
// //
if (this.form[item.name]) { if (form[item.name]) {
this.$set(item, 'defaultValue', this.form[item.name]); this.$set(item, 'defaultValue', form[item.name]);
} }
}); });
} }
this.form = form;
}); });
this.config = r.data; this.config = r.data;
this.rules = getPlatformFormRules(this.config); this.rules = getPlatformFormRules(this.config);

View File

@ -31,7 +31,7 @@
<el-checkbox @change="thirdPartTemplateChange" v-if="thirdPartTemplateSupport" <el-checkbox @change="thirdPartTemplateChange" v-if="thirdPartTemplateSupport"
v-model="form.thirdPartTemplate" style="margin-left: 10px"> v-model="form.thirdPartTemplate" style="margin-left: 10px">
{{ $t('test_track.issue.use_third_party') }} {{ $t('test_track.issue.use_third_party', [form.platform]) }}
</el-checkbox> </el-checkbox>
</el-form-item> </el-form-item>

View File

@ -89,7 +89,8 @@ export default {
getPlatformProjectInfo(this.platformKey) getPlatformProjectInfo(this.platformKey)
.then(r => { .then(r => {
if (r.data) { if (r.data) {
Object.assign(this.form, this.projectConfig); let form = {};
Object.assign(form, this.projectConfig);
this.handleProjectConfigCompatible(); this.handleProjectConfigCompatible();
r.data.formItems.forEach(item => { r.data.formItems.forEach(item => {
@ -97,18 +98,19 @@ export default {
item.options = []; item.options = [];
} }
// //
if (this.form[item.name]) { if (form[item.name]) {
this.$set(item, 'defaultValue', this.form[item.name]); this.$set(item, 'defaultValue', form[item.name]);
} }
// //
if (item.cascade && this.form[item.name]) { if (item.cascade && form[item.cascade]) {
this.getCascadeOptions(item, () => { this.getCascadeOptions(item, () => {
// //
if (this.form[item.name]) { if (form[item.name]) {
this.$set(item, 'defaultValue', this.form[item.name]); this.$set(item, 'defaultValue', form[item.name]);
} }
}); });
} }
this.form = form;
}); });
this.config = r.data; this.config = r.data;
this.rules = getPlatformFormRules(this.config); this.rules = getPlatformFormRules(this.config);

View File

@ -112,7 +112,7 @@
group by issues.id group by issues.id
</select> </select>
<select id="getIssueForSync" resultType="io.metersphere.xpack.track.dto.IssuesDao"> <select id="getIssueForSync" resultType="io.metersphere.xpack.track.dto.IssuesDao">
select id, platform, platform_id, create_time select id, platform, platform_id, create_time, update_time
from issues from issues
where project_id = #{projectId} and platform = #{platform} and (platform_status != 'delete' or platform_status is null); where project_id = #{projectId} and platform = #{platform} and (platform_status != 'delete' or platform_status is null);
</select> </select>

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

@ -292,7 +292,9 @@ public class IssuesService {
issues.setId(UUID.randomUUID().toString()); issues.setId(UUID.randomUUID().toString());
} }
issues.setCreateTime(System.currentTimeMillis()); issues.setCreateTime(System.currentTimeMillis());
issues.setUpdateTime(System.currentTimeMillis()); if (issues.getUpdateTime() == null) {
issues.setUpdateTime(System.currentTimeMillis());
}
issues.setNum(getNextNum(issues.getProjectId())); issues.setNum(getNextNum(issues.getProjectId()));
issues.setCreator(SessionUtils.getUserId()); issues.setCreator(SessionUtils.getUserId());
issuesMapper.insert(issues); issuesMapper.insert(issues);
@ -703,18 +705,7 @@ public class IssuesService {
Map<String, List<CustomFieldDao>> fieldMap = Map<String, List<CustomFieldDao>> fieldMap =
customFieldIssuesService.getMapByResourceIds(data.stream().map(IssuesDao::getId).collect(Collectors.toList())); customFieldIssuesService.getMapByResourceIds(data.stream().map(IssuesDao::getId).collect(Collectors.toList()));
try { try {
Map<String, CustomField> fieldMaps = new HashMap<>(); Map<String, CustomField> fieldMaps = customFields.stream().collect(Collectors.toMap(CustomFieldDao::getId, field -> (CustomField) field));
if (isThirdTemplate) {
fieldMaps = customFields.stream().collect(Collectors.toMap(CustomFieldDao::getId, field -> (CustomField) field));
} else {
List<CustomFieldDao> customfields = fieldMap.get(data.get(0).getId());
if (CollectionUtils.isNotEmpty(customfields) && customfields.size() > 0) {
List<String> ids = customfields.stream().map(CustomFieldDao::getId).collect(Collectors.toList());
List<CustomField> issueFields = baseCustomFieldService.getFieldByIds(ids);
fieldMaps = issueFields.stream().collect(Collectors.toMap(CustomField::getId, field -> field));
}
}
for (Map.Entry<String, List<CustomFieldDao>> entry : fieldMap.entrySet()) { for (Map.Entry<String, List<CustomFieldDao>> entry : fieldMap.entrySet()) {
for (CustomFieldDao fieldDao : entry.getValue()) { for (CustomFieldDao fieldDao : entry.getValue()) {
CustomField customField = fieldMaps.get(fieldDao.getId()); CustomField customField = fieldMaps.get(fieldDao.getId());
@ -1531,9 +1522,12 @@ public class IssuesService {
MSException.throwException(Translator.get("upload_fail")); MSException.throwException(Translator.get("upload_fail"));
} }
Map<String, String> userMap = baseUserService.getProjectMemberOption(request.getProjectId()).stream().collect(Collectors.toMap(User::getId, User::getName)); Map<String, String> userMap = baseUserService.getProjectMemberOption(request.getProjectId()).stream().collect(Collectors.toMap(User::getId, User::getName));
// 获取第三方平台自定义字段
List<CustomFieldDao> pluginCustomFields = getPluginCustomFields(request.getProjectId());
// 获取缺陷模板及自定义字段 // 获取缺陷模板及自定义字段
IssueTemplateDao issueTemplate = getIssueTemplateByProjectId(request.getProjectId()); IssueTemplateDao issueTemplate = getIssueTemplateByProjectId(request.getProjectId());
List<CustomFieldDao> customFields = Optional.ofNullable(issueTemplate.getCustomFields()).orElse(new ArrayList<>()); List<CustomFieldDao> customFields = Optional.ofNullable(issueTemplate.getCustomFields()).orElse(new ArrayList<>());
customFields.addAll(pluginCustomFields);
// 获取本地EXCEL数据对象 // 获取本地EXCEL数据对象
Class clazz = new IssueExcelDataFactory().getExcelDataByLocal(); Class clazz = new IssueExcelDataFactory().getExcelDataByLocal();
// IssueExcelListener读取file内容 // IssueExcelListener读取file内容
@ -1559,9 +1553,12 @@ public class IssuesService {
public void issueExport(IssueExportRequest request, HttpServletResponse response) { public void issueExport(IssueExportRequest request, HttpServletResponse response) {
EasyExcelExporter.resetCellMaxTextLength(); EasyExcelExporter.resetCellMaxTextLength();
Map<String, String> userMap = baseUserService.getProjectMemberOption(request.getProjectId()).stream().collect(Collectors.toMap(User::getId, User::getName)); Map<String, String> userMap = baseUserService.getProjectMemberOption(request.getProjectId()).stream().collect(Collectors.toMap(User::getId, User::getName));
// 第三方平台的自定义字段
List<CustomFieldDao> pluginCustomFields = getPluginCustomFields(request.getProjectId());
// 获取缺陷模板及自定义字段 // 获取缺陷模板及自定义字段
IssueTemplateDao issueTemplate = getIssueTemplateByProjectId(request.getProjectId()); IssueTemplateDao issueTemplate = getIssueTemplateByProjectId(request.getProjectId());
List<CustomFieldDao> customFields = Optional.ofNullable(issueTemplate.getCustomFields()).orElse(new ArrayList<>()); List<CustomFieldDao> customFields = Optional.ofNullable(issueTemplate.getCustomFields()).orElse(new ArrayList<>());
customFields.addAll(pluginCustomFields);
// 根据自定义字段获取表头内容 // 根据自定义字段获取表头内容
List<List<String>> heads = new IssueExcelDataFactory().getIssueExcelDataLocal().getHead(issueTemplate.getIsThirdTemplate(), customFields, request); List<List<String>> heads = new IssueExcelDataFactory().getIssueExcelDataLocal().getHead(issueTemplate.getIsThirdTemplate(), customFields, request);
// 获取导出缺陷列表 // 获取导出缺陷列表

View File

@ -77,7 +77,7 @@ public class PlatformPluginService {
} }
PluginMetaInfo pluginMetaInfo = pluginManager.getPluginMetaInfoByKey(platform); PluginMetaInfo pluginMetaInfo = pluginManager.getPluginMetaInfoByKey(platform);
if (PlatformPluginService.isPluginPlatform(platform) && pluginMetaInfo == null) { if (PlatformPluginService.isPluginPlatform(platform) && pluginMetaInfo == null) {
MSException.throwException(Translator.get("platform_plugin_not_exit") + PlatformPluginService.PLUGIN_DOWNLOAD_URL); return false;
} }
return pluginMetaInfo == null ? false : pluginMetaInfo.isThirdPartTemplateSupport(); return pluginMetaInfo == null ? false : pluginMetaInfo.isThirdPartTemplateSupport();
} }

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());
}
/** /**
* 处理其他信息的复制问题 * 处理其他信息的复制问题
* *