diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtCustomFieldTemplateMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtCustomFieldTemplateMapper.xml
index 92b4aeb05e..742abe654d 100644
--- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtCustomFieldTemplateMapper.xml
+++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtCustomFieldTemplateMapper.xml
@@ -22,7 +22,7 @@
+
diff --git a/backend/src/main/java/io/metersphere/dto/CustomFieldResourceDTO.java b/backend/src/main/java/io/metersphere/dto/CustomFieldResourceDTO.java
index 4c7da93d93..99a85c343e 100644
--- a/backend/src/main/java/io/metersphere/dto/CustomFieldResourceDTO.java
+++ b/backend/src/main/java/io/metersphere/dto/CustomFieldResourceDTO.java
@@ -12,5 +12,6 @@ import java.io.Serializable;
@ToString(callSuper = true)
public class CustomFieldResourceDTO extends CustomFieldResource implements Serializable {
private String name;
+ private String type;
private static final long serialVersionUID = 1L;
}
diff --git a/backend/src/main/java/io/metersphere/service/CustomFieldService.java b/backend/src/main/java/io/metersphere/service/CustomFieldService.java
index b72966c8c8..2f57890656 100644
--- a/backend/src/main/java/io/metersphere/service/CustomFieldService.java
+++ b/backend/src/main/java/io/metersphere/service/CustomFieldService.java
@@ -237,23 +237,9 @@ public class CustomFieldService {
List list = new ArrayList<>();
if (StringUtils.isNotBlank(customFieldsStr)) {
if (JSONObject.parse(customFieldsStr) instanceof JSONArray) {
- List fieldItems = JSONArray.parseArray(customFieldsStr, CustomFieldItemDTO.class);
- for (CustomFieldItemDTO dto : fieldItems) {
- // customFieldItemDTO里的id是模版ID
- CustomFieldResource resource = new CustomFieldResource();
- CustomFieldTemplate customFieldTemplate = customFieldTemplateMapper.selectByPrimaryKey(dto.getId());
- if (customFieldTemplate == null) {
- continue;
- } else {
- resource.setFieldId(customFieldTemplate.getFieldId());
- }
- if (StringUtils.isNotBlank(dto.getType())
- && StringUtils.equalsAny(CustomFieldType.RICH_TEXT.getValue(), CustomFieldType.TEXTAREA.getValue())) {
- resource.setTextValue(dto.getValue().toString());
- } else {
- resource.setValue(JSONObject.toJSONString(dto.getValue()));
- }
- list.add(resource);
+ List items = JSONArray.parseArray(customFieldsStr, CustomFieldItemDTO.class);
+ for (CustomFieldItemDTO item : items) {
+ list.add(constructorCustomFieldResource(item));
}
return list;
}
@@ -261,50 +247,15 @@ public class CustomFieldService {
return new ArrayList<>();
}
- public List getJiraCustomFieldResource(String customFieldsStr, String projectId) {
- List list = new ArrayList<>();
- if (StringUtils.isNotBlank(customFieldsStr)) {
- if (JSONObject.parse(customFieldsStr) instanceof JSONArray) {
- List fieldItems = JSONArray.parseArray(customFieldsStr, CustomFieldItemDTO.class);
- for (CustomFieldItemDTO dto : fieldItems) {
- CustomFieldResource resource = new CustomFieldResource();
- // customFieldItemDTO里的id是模版ID
- CustomFieldTemplate customFieldTemplate = customFieldTemplateMapper.selectByPrimaryKey(dto.getId());
- if (customFieldTemplate == null) {
- CustomField customField = customFieldMapper.selectByPrimaryKey(dto.getId());
- if (customField == null) {
- CustomField field = new CustomField();
- field.setId(dto.getId());
- field.setUpdateTime(System.currentTimeMillis());
- field.setCreateTime(System.currentTimeMillis());
- field.setGlobal(false);
- field.setSystem(false);
- field.setName(dto.getName());
- field.setScene(TemplateConstants.FieldTemplateScene.ISSUE.name());
- field.setThirdPart(true);
- field.setType(dto.getType());
- field.setProjectId(projectId);
- if (StringUtils.isNotBlank(SessionUtils.getUserId())) {
- field.setCreateUser(SessionUtils.getUserId());
- }
- customFieldMapper.insert(field);
- }
- resource.setFieldId(dto.getId());
- } else {
- resource.setFieldId(customFieldTemplate.getFieldId());
- }
- if (StringUtils.isNotBlank(dto.getType())
- && StringUtils.equalsAny(CustomFieldType.RICH_TEXT.getValue(), CustomFieldType.TEXTAREA.getValue())) {
- resource.setTextValue(dto.getValue().toString());
- } else {
- resource.setValue(JSONObject.toJSONString(dto.getValue()));
- }
- list.add(resource);
- }
- return list;
- }
+ private CustomFieldResource constructorCustomFieldResource(CustomFieldItemDTO dto) {
+ CustomFieldResource resource = new CustomFieldResource();
+ resource.setFieldId(dto.getId());
+ if (StringUtils.isNotBlank(dto.getType()) && StringUtils.equalsAny(CustomFieldType.RICH_TEXT.getValue(), CustomFieldType.TEXTAREA.getValue())) {
+ resource.setTextValue(dto.getValue().toString());
+ } else {
+ resource.setValue(JSONObject.toJSONString(dto.getValue()));
}
- return new ArrayList<>();
+ return resource;
}
public List getByProjectId(String projectId) {
diff --git a/backend/src/main/java/io/metersphere/track/issue/AbstractIssuePlatform.java b/backend/src/main/java/io/metersphere/track/issue/AbstractIssuePlatform.java
index f91ad94f1d..ff3f091e83 100644
--- a/backend/src/main/java/io/metersphere/track/issue/AbstractIssuePlatform.java
+++ b/backend/src/main/java/io/metersphere/track/issue/AbstractIssuePlatform.java
@@ -1,5 +1,6 @@
package io.metersphere.track.issue;
+import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import io.metersphere.base.domain.*;
@@ -372,7 +373,7 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform {
}
protected void addCustomFields(IssuesUpdateRequest issuesRequest, MultiValueMap paramMap) {
- List customFields = CustomFieldService.getCustomFields(issuesRequest.getCustomFields());
+ List customFields = issuesRequest.getRequestFields();
customFields.forEach(item -> {
if (StringUtils.isNotBlank(item.getCustomData())) {
if (item.getValue() instanceof String) {
@@ -417,18 +418,28 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform {
String fieldName = item.getCustomData();
Object value = issue.get(fieldName);
if (value != null) {
- if (value instanceof JSONObject) {
- item.setValue(getSyncJsonParamValue(value));
+ if (value instanceof JSONObject) {
+ item.setValue(getSyncJsonParamValue(value));
} else if (value instanceof JSONArray) {
- List