From 378426795e580914d6693568e4ea213d0df7964f Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Mon, 13 Dec 2021 20:57:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=85=8D=E7=BD=AEjira=E7=AC=AC=E4=B8=89?= =?UTF-8?q?=E6=96=B9=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/IssueTemplateService.java | 28 ++++++++++++++++ .../io/metersphere/service/UserService.java | 2 +- .../metersphere/track/issue/JiraPlatform.java | 22 +++++++------ .../track/service/IssuesService.java | 26 +++------------ backend/src/main/java/io/metersphere/xpack | 2 +- .../settings/components/PersonRouter.vue | 2 +- .../track/issue/IssueEditDetail.vue | 32 +++++++++---------- 7 files changed, 64 insertions(+), 50 deletions(-) diff --git a/backend/src/main/java/io/metersphere/service/IssueTemplateService.java b/backend/src/main/java/io/metersphere/service/IssueTemplateService.java index cc55a8d0d6..9a9731ff43 100644 --- a/backend/src/main/java/io/metersphere/service/IssueTemplateService.java +++ b/backend/src/main/java/io/metersphere/service/IssueTemplateService.java @@ -225,6 +225,34 @@ public class IssueTemplateService extends TemplateBaseService { } else { issueTemplate = getDefaultTemplate(project.getWorkspaceId()); } + if (!project.getPlatform().equals(issueTemplate.getPlatform())) { + MSException.throwException("请在项目中配置缺陷模板"); + } + BeanUtils.copyBean(issueTemplateDao, issueTemplate); + List result = customFieldService.getCustomFieldByTemplateId(issueTemplate.getId()); + issueTemplateDao.setCustomFields(result); + return issueTemplateDao; + } + + public IssueTemplateDao getTemplate(String projectId, boolean thirdPartTemplate) { + Project project = projectService.getProjectById(projectId); + if (thirdPartTemplate) { + + } + String issueTemplateId = project.getIssueTemplateId(); + IssueTemplate issueTemplate; + IssueTemplateDao issueTemplateDao = new IssueTemplateDao(); + if (StringUtils.isNotBlank(issueTemplateId)) { + issueTemplate = issueTemplateMapper.selectByPrimaryKey(issueTemplateId); + if (issueTemplate == null) { + issueTemplate = getDefaultTemplate(project.getWorkspaceId()); + } + } else { + issueTemplate = getDefaultTemplate(project.getWorkspaceId()); + } + if (!project.getPlatform().equals(issueTemplate.getPlatform())) { + MSException.throwException("请在项目中配置缺陷模板"); + } BeanUtils.copyBean(issueTemplateDao, issueTemplate); List result = customFieldService.getCustomFieldByTemplateId(issueTemplate.getId()); issueTemplateDao.setCustomFields(result); diff --git a/backend/src/main/java/io/metersphere/service/UserService.java b/backend/src/main/java/io/metersphere/service/UserService.java index c02fe22255..950d0b1595 100644 --- a/backend/src/main/java/io/metersphere/service/UserService.java +++ b/backend/src/main/java/io/metersphere/service/UserService.java @@ -1255,7 +1255,7 @@ public class UserService { public UserDTO.PlatformInfo getCurrentPlatformInfo(String workspaceId) { User user = userMapper.selectByPrimaryKey(SessionUtils.getUserId()); String platformInfoStr = user.getPlatformInfo(); - if (StringUtils.isBlank(workspaceId) || StringUtils.isBlank(platformInfoStr)) { + if (StringUtils.isBlank(workspaceId) || StringUtils.isBlank(platformInfoStr) || platformInfoStr.equals("null")) { return null; } JSONObject platformInfos = JSONObject.parseObject(platformInfoStr); diff --git a/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java b/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java index 239eab5eeb..c7cb031edb 100644 --- a/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java +++ b/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java @@ -233,17 +233,21 @@ public class JiraPlatform extends AbstractIssuePlatform { fields.put(fieldName, attrs); } else if (StringUtils.equalsAny(item.getType(), "cascadingSelect")) { if (item.getValue() != null) { - JSONArray values = (JSONArray)item.getValue(); JSONObject attr = new JSONObject(); - if (CollectionUtils.isNotEmpty(values)) { - if (values.size() > 0) { - attr.put("id", values.get(0)); - } - if (values.size() > 1) { - JSONObject param = new JSONObject(); - param.put("id", values.get(1)); - attr.put("child", param); + if (item.getValue() instanceof JSONArray) { + JSONArray values = (JSONArray) item.getValue(); + if (CollectionUtils.isNotEmpty(values)) { + if (values.size() > 0) { + attr.put("id", values.get(0)); + } + if (values.size() > 1) { + JSONObject param = new JSONObject(); + param.put("id", values.get(1)); + attr.put("child", param); + } } + } else { + attr.put("id", item.getValue()); } fields.put(fieldName, attr); } diff --git a/backend/src/main/java/io/metersphere/track/service/IssuesService.java b/backend/src/main/java/io/metersphere/track/service/IssuesService.java index 83240c91d1..bc96fee8e8 100644 --- a/backend/src/main/java/io/metersphere/track/service/IssuesService.java +++ b/backend/src/main/java/io/metersphere/track/service/IssuesService.java @@ -128,12 +128,10 @@ public class IssuesService { List platforms = new ArrayList<>(); if (StringUtils.isNotBlank(updateRequest.getTestCaseId())) { // 测试计划关联 - String p = getPlatformsByCaseId(updateRequest.getTestCaseId()); - platforms.add(p); + platforms.add(getPlatformsByCaseId(updateRequest.getTestCaseId())); } else { // 缺陷管理关联 - String t = getIssueTemplate(updateRequest.getProjectId()); - platforms.add(t); + platforms.add(getPlatform(updateRequest.getProjectId())); } if (CollectionUtils.isEmpty(platforms)) { @@ -193,26 +191,12 @@ public class IssuesService { public String getPlatformsByCaseId(String caseId) { TestCaseWithBLOBs testCase = testCaseService.getTestCase(caseId); Project project = projectService.getProjectById(testCase.getProjectId()); - return getIssueTemplate(project.getId()); + return getPlatform(project.getId()); } - public String getIssueTemplate(String projectId) { + public String getPlatform(String projectId) { Project project = projectService.getProjectById(projectId); - IssueTemplate issueTemplate; - String id = project.getIssueTemplateId(); - if (StringUtils.isBlank(id)) { - issueTemplate = issueTemplateService.getDefaultTemplate(project.getWorkspaceId()); - } else { - issueTemplate = issueTemplateMapper.selectByPrimaryKey(id); - } - if (issueTemplate == null) { - MSException.throwException("project issue template id is null."); - } - String platform = issueTemplate.getPlatform(); - if (StringUtils.equals(platform, "metersphere")) { - return IssuesManagePlatform.Local.name(); - } - return platform; + return project.getPlatform(); } public List getPlatforms(Project project) { diff --git a/backend/src/main/java/io/metersphere/xpack b/backend/src/main/java/io/metersphere/xpack index 8bd3730267..cf8337c9a6 160000 --- a/backend/src/main/java/io/metersphere/xpack +++ b/backend/src/main/java/io/metersphere/xpack @@ -1 +1 @@ -Subproject commit 8bd3730267a6c1b383a781b3c4ef8526e5414d82 +Subproject commit cf8337c9a6341d8c9eb7f5c9bef897083b0d2951 diff --git a/frontend/src/business/components/settings/components/PersonRouter.vue b/frontend/src/business/components/settings/components/PersonRouter.vue index 744e898a32..43e1de7215 100644 --- a/frontend/src/business/components/settings/components/PersonRouter.vue +++ b/frontend/src/business/components/settings/components/PersonRouter.vue @@ -120,7 +120,7 @@ }, getPlatformInfo(row) { let orgId = getCurrentWorkspaceId(); - if (row.platformInfo) { + if (row.platformInfo && row.platformInfo !== 'null') { this.form = row; if (!row.platformInfo[orgId]) { this.form.platformInfo = JSON.parse(row.platformInfo); diff --git a/frontend/src/business/components/track/issue/IssueEditDetail.vue b/frontend/src/business/components/track/issue/IssueEditDetail.vue index 3637da0e8a..168b826721 100644 --- a/frontend/src/business/components/track/issue/IssueEditDetail.vue +++ b/frontend/src/business/components/track/issue/IssueEditDetail.vue @@ -182,23 +182,21 @@ export default { let initAddFuc = this.initEdit; getCurrentProject((responseData) => { this.currentProject = responseData; - this.$nextTick(() => { - if (this.enableThirdPartTemplate) { - getIssueThirdPartTemplate() - .then((template) => { - this.issueTemplate = template; - this.getThirdPartyInfo(); - initAddFuc(data); - }); - } else { - getIssueTemplate() - .then((template) => { - this.issueTemplate = template; - this.getThirdPartyInfo(); - initAddFuc(data); - }); - } - }); + if (hasLicense() && this.currentProject && this.currentProject.thirdPartTemplate && this.currentProject.platform === JIRA) { + getIssueThirdPartTemplate() + .then((template) => { + this.issueTemplate = template; + this.getThirdPartyInfo(); + initAddFuc(data); + }); + } else { + getIssueTemplate() + .then((template) => { + this.issueTemplate = template; + this.getThirdPartyInfo(); + initAddFuc(data); + }); + } }); if(data&&data.id){