From d2d6d2b89a552c6e367a55f2491949b287903775 Mon Sep 17 00:00:00 2001 From: song-cc-rock Date: Thu, 17 Nov 2022 14:20:05 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E9=A1=B9=E7=9B=AE=E8=AE=BE=E7=BD=AE):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BC=BA=E9=99=B7=E6=A8=A1=E6=9D=BF=E5=A4=8D?= =?UTF-8?q?=E5=88=B6=E6=97=B6=E5=85=A8=E5=B1=80=E6=A8=A1=E6=9D=BF=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E5=85=B3=E8=81=94=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/IssueTemplateService.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/project-management/backend/src/main/java/io/metersphere/service/IssueTemplateService.java b/project-management/backend/src/main/java/io/metersphere/service/IssueTemplateService.java index 7e9cadb9e7..aecb838bca 100644 --- a/project-management/backend/src/main/java/io/metersphere/service/IssueTemplateService.java +++ b/project-management/backend/src/main/java/io/metersphere/service/IssueTemplateService.java @@ -370,7 +370,8 @@ public class IssueTemplateService extends TemplateBaseService { .filter(item -> StringUtils.equals(item.getId(), sourceCustomFieldTemplate.getFieldId())) .collect(Collectors.toList()).get(0); CustomFieldExample example = new CustomFieldExample(); - example.createCriteria().andNameEqualTo(sourceCustomField.getName()).andSystemEqualTo(sourceCustomField.getSystem()) + example.createCriteria().andNameEqualTo(sourceCustomField.getName()) + .andSceneEqualTo(sourceCustomField.getScene()).andSystemEqualTo(sourceCustomField.getSystem()) .andProjectIdEqualTo(targetProjectId); List targetCustomFields = customFieldMapper.selectByExample(example); if (CollectionUtils.isEmpty(targetCustomFields)) { @@ -383,6 +384,22 @@ public class IssueTemplateService extends TemplateBaseService { tarCustomField.setCreateUser(SessionUtils.getUserId()); tarCustomField.setProjectId(targetProjectId); customFieldRecords.add(tarCustomField); + if (sourceCustomField.getSystem()) { + // 系统字段未查到, 则为全局模板Gloal字段 + CustomFieldExample customFieldExample = new CustomFieldExample(); + customFieldExample.createCriteria().andNameEqualTo(sourceCustomField.getName()) + .andSceneEqualTo(sourceCustomField.getScene()).andSystemEqualTo(sourceCustomField.getSystem()) + .andProjectIdEqualTo("global"); + List customFields = customFieldMapper.selectByExample(customFieldExample); + + CustomFieldDao customFieldDao = new CustomFieldDao(); + BeanUtils.copyBean(customFieldDao, tarCustomField); + if (CollectionUtils.isNotEmpty(customFields)) { + customFieldDao.setOriginGlobalId(customFields.get(0).getId()); + } + // 新增系统字段, 需处理默认模板 + handleSystemFieldCreate(customFieldDao); + } } else { // 否则按照复制模式进行设置 BeanUtils.copyBean(tarCustomField, targetCustomFields.get(0));