diff --git a/backend/src/main/java/io/metersphere/base/domain/CustomField.java b/backend/src/main/java/io/metersphere/base/domain/CustomField.java index 5240b1f91d..0562b02faf 100644 --- a/backend/src/main/java/io/metersphere/base/domain/CustomField.java +++ b/backend/src/main/java/io/metersphere/base/domain/CustomField.java @@ -1,8 +1,7 @@ package io.metersphere.base.domain; -import lombok.Data; - import java.io.Serializable; +import lombok.Data; @Data public class CustomField implements Serializable { @@ -28,7 +27,9 @@ public class CustomField implements Serializable { private String projectId; + private Boolean thirdPart; + private String options; private static final long serialVersionUID = 1L; -} \ No newline at end of file +} diff --git a/backend/src/main/java/io/metersphere/base/domain/CustomFieldExample.java b/backend/src/main/java/io/metersphere/base/domain/CustomFieldExample.java index eca35a316e..4b30538a32 100644 --- a/backend/src/main/java/io/metersphere/base/domain/CustomFieldExample.java +++ b/backend/src/main/java/io/metersphere/base/domain/CustomFieldExample.java @@ -833,6 +833,66 @@ public class CustomFieldExample { addCriterion("project_id not between", value1, value2, "projectId"); return (Criteria) this; } + + public Criteria andThirdPartIsNull() { + addCriterion("third_part is null"); + return (Criteria) this; + } + + public Criteria andThirdPartIsNotNull() { + addCriterion("third_part is not null"); + return (Criteria) this; + } + + public Criteria andThirdPartEqualTo(Boolean value) { + addCriterion("third_part =", value, "thirdPart"); + return (Criteria) this; + } + + public Criteria andThirdPartNotEqualTo(Boolean value) { + addCriterion("third_part <>", value, "thirdPart"); + return (Criteria) this; + } + + public Criteria andThirdPartGreaterThan(Boolean value) { + addCriterion("third_part >", value, "thirdPart"); + return (Criteria) this; + } + + public Criteria andThirdPartGreaterThanOrEqualTo(Boolean value) { + addCriterion("third_part >=", value, "thirdPart"); + return (Criteria) this; + } + + public Criteria andThirdPartLessThan(Boolean value) { + addCriterion("third_part <", value, "thirdPart"); + return (Criteria) this; + } + + public Criteria andThirdPartLessThanOrEqualTo(Boolean value) { + addCriterion("third_part <=", value, "thirdPart"); + return (Criteria) this; + } + + public Criteria andThirdPartIn(List values) { + addCriterion("third_part in", values, "thirdPart"); + return (Criteria) this; + } + + public Criteria andThirdPartNotIn(List values) { + addCriterion("third_part not in", values, "thirdPart"); + return (Criteria) this; + } + + public Criteria andThirdPartBetween(Boolean value1, Boolean value2) { + addCriterion("third_part between", value1, value2, "thirdPart"); + return (Criteria) this; + } + + public Criteria andThirdPartNotBetween(Boolean value1, Boolean value2) { + addCriterion("third_part not between", value1, value2, "thirdPart"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { @@ -927,4 +987,4 @@ public class CustomFieldExample { this(condition, value, secondValue, null); } } -} \ No newline at end of file +} diff --git a/backend/src/main/java/io/metersphere/base/domain/CustomFieldIssues.java b/backend/src/main/java/io/metersphere/base/domain/CustomFieldIssues.java new file mode 100644 index 0000000000..5a9cf8f2fa --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/domain/CustomFieldIssues.java @@ -0,0 +1,17 @@ +package io.metersphere.base.domain; + +import java.io.Serializable; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class CustomFieldIssues extends CustomFieldIssuesKey implements Serializable { + private String value; + + private String textValue; + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/CustomFieldIssuesExample.java b/backend/src/main/java/io/metersphere/base/domain/CustomFieldIssuesExample.java new file mode 100644 index 0000000000..2656726ed0 --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/domain/CustomFieldIssuesExample.java @@ -0,0 +1,410 @@ +package io.metersphere.base.domain; + +import java.util.ArrayList; +import java.util.List; + +public class CustomFieldIssuesExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + public CustomFieldIssuesExample() { + oredCriteria = new ArrayList(); + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public boolean isDistinct() { + return distinct; + } + + public List getOredCriteria() { + return oredCriteria; + } + + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andResourceIdIsNull() { + addCriterion("resource_id is null"); + return (Criteria) this; + } + + public Criteria andResourceIdIsNotNull() { + addCriterion("resource_id is not null"); + return (Criteria) this; + } + + public Criteria andResourceIdEqualTo(String value) { + addCriterion("resource_id =", value, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdNotEqualTo(String value) { + addCriterion("resource_id <>", value, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdGreaterThan(String value) { + addCriterion("resource_id >", value, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdGreaterThanOrEqualTo(String value) { + addCriterion("resource_id >=", value, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdLessThan(String value) { + addCriterion("resource_id <", value, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdLessThanOrEqualTo(String value) { + addCriterion("resource_id <=", value, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdLike(String value) { + addCriterion("resource_id like", value, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdNotLike(String value) { + addCriterion("resource_id not like", value, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdIn(List values) { + addCriterion("resource_id in", values, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdNotIn(List values) { + addCriterion("resource_id not in", values, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdBetween(String value1, String value2) { + addCriterion("resource_id between", value1, value2, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdNotBetween(String value1, String value2) { + addCriterion("resource_id not between", value1, value2, "resourceId"); + return (Criteria) this; + } + + public Criteria andFieldIdIsNull() { + addCriterion("field_id is null"); + return (Criteria) this; + } + + public Criteria andFieldIdIsNotNull() { + addCriterion("field_id is not null"); + return (Criteria) this; + } + + public Criteria andFieldIdEqualTo(String value) { + addCriterion("field_id =", value, "fieldId"); + return (Criteria) this; + } + + public Criteria andFieldIdNotEqualTo(String value) { + addCriterion("field_id <>", value, "fieldId"); + return (Criteria) this; + } + + public Criteria andFieldIdGreaterThan(String value) { + addCriterion("field_id >", value, "fieldId"); + return (Criteria) this; + } + + public Criteria andFieldIdGreaterThanOrEqualTo(String value) { + addCriterion("field_id >=", value, "fieldId"); + return (Criteria) this; + } + + public Criteria andFieldIdLessThan(String value) { + addCriterion("field_id <", value, "fieldId"); + return (Criteria) this; + } + + public Criteria andFieldIdLessThanOrEqualTo(String value) { + addCriterion("field_id <=", value, "fieldId"); + return (Criteria) this; + } + + public Criteria andFieldIdLike(String value) { + addCriterion("field_id like", value, "fieldId"); + return (Criteria) this; + } + + public Criteria andFieldIdNotLike(String value) { + addCriterion("field_id not like", value, "fieldId"); + return (Criteria) this; + } + + public Criteria andFieldIdIn(List values) { + addCriterion("field_id in", values, "fieldId"); + return (Criteria) this; + } + + public Criteria andFieldIdNotIn(List values) { + addCriterion("field_id not in", values, "fieldId"); + return (Criteria) this; + } + + public Criteria andFieldIdBetween(String value1, String value2) { + addCriterion("field_id between", value1, value2, "fieldId"); + return (Criteria) this; + } + + public Criteria andFieldIdNotBetween(String value1, String value2) { + addCriterion("field_id not between", value1, value2, "fieldId"); + return (Criteria) this; + } + + public Criteria andValueIsNull() { + addCriterion("`value` is null"); + return (Criteria) this; + } + + public Criteria andValueIsNotNull() { + addCriterion("`value` is not null"); + return (Criteria) this; + } + + public Criteria andValueEqualTo(String value) { + addCriterion("`value` =", value, "value"); + return (Criteria) this; + } + + public Criteria andValueNotEqualTo(String value) { + addCriterion("`value` <>", value, "value"); + return (Criteria) this; + } + + public Criteria andValueGreaterThan(String value) { + addCriterion("`value` >", value, "value"); + return (Criteria) this; + } + + public Criteria andValueGreaterThanOrEqualTo(String value) { + addCriterion("`value` >=", value, "value"); + return (Criteria) this; + } + + public Criteria andValueLessThan(String value) { + addCriterion("`value` <", value, "value"); + return (Criteria) this; + } + + public Criteria andValueLessThanOrEqualTo(String value) { + addCriterion("`value` <=", value, "value"); + return (Criteria) this; + } + + public Criteria andValueLike(String value) { + addCriterion("`value` like", value, "value"); + return (Criteria) this; + } + + public Criteria andValueNotLike(String value) { + addCriterion("`value` not like", value, "value"); + return (Criteria) this; + } + + public Criteria andValueIn(List values) { + addCriterion("`value` in", values, "value"); + return (Criteria) this; + } + + public Criteria andValueNotIn(List values) { + addCriterion("`value` not in", values, "value"); + return (Criteria) this; + } + + public Criteria andValueBetween(String value1, String value2) { + addCriterion("`value` between", value1, value2, "value"); + return (Criteria) this; + } + + public Criteria andValueNotBetween(String value1, String value2) { + addCriterion("`value` not between", value1, value2, "value"); + return (Criteria) this; + } + } + + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/CustomFieldIssuesKey.java b/backend/src/main/java/io/metersphere/base/domain/CustomFieldIssuesKey.java new file mode 100644 index 0000000000..f8ab471fe0 --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/domain/CustomFieldIssuesKey.java @@ -0,0 +1,13 @@ +package io.metersphere.base.domain; + +import java.io.Serializable; +import lombok.Data; + +@Data +public class CustomFieldIssuesKey implements Serializable { + private String resourceId; + + private String fieldId; + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/CustomFieldTestCase.java b/backend/src/main/java/io/metersphere/base/domain/CustomFieldTestCase.java new file mode 100644 index 0000000000..f9df30799e --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/domain/CustomFieldTestCase.java @@ -0,0 +1,17 @@ +package io.metersphere.base.domain; + +import java.io.Serializable; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class CustomFieldTestCase extends CustomFieldTestCaseKey implements Serializable { + private String value; + + private String textValue; + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/CustomFieldTestCaseExample.java b/backend/src/main/java/io/metersphere/base/domain/CustomFieldTestCaseExample.java new file mode 100644 index 0000000000..4998425a9f --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/domain/CustomFieldTestCaseExample.java @@ -0,0 +1,410 @@ +package io.metersphere.base.domain; + +import java.util.ArrayList; +import java.util.List; + +public class CustomFieldTestCaseExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + public CustomFieldTestCaseExample() { + oredCriteria = new ArrayList(); + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public boolean isDistinct() { + return distinct; + } + + public List getOredCriteria() { + return oredCriteria; + } + + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andResourceIdIsNull() { + addCriterion("resource_id is null"); + return (Criteria) this; + } + + public Criteria andResourceIdIsNotNull() { + addCriterion("resource_id is not null"); + return (Criteria) this; + } + + public Criteria andResourceIdEqualTo(String value) { + addCriterion("resource_id =", value, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdNotEqualTo(String value) { + addCriterion("resource_id <>", value, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdGreaterThan(String value) { + addCriterion("resource_id >", value, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdGreaterThanOrEqualTo(String value) { + addCriterion("resource_id >=", value, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdLessThan(String value) { + addCriterion("resource_id <", value, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdLessThanOrEqualTo(String value) { + addCriterion("resource_id <=", value, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdLike(String value) { + addCriterion("resource_id like", value, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdNotLike(String value) { + addCriterion("resource_id not like", value, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdIn(List values) { + addCriterion("resource_id in", values, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdNotIn(List values) { + addCriterion("resource_id not in", values, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdBetween(String value1, String value2) { + addCriterion("resource_id between", value1, value2, "resourceId"); + return (Criteria) this; + } + + public Criteria andResourceIdNotBetween(String value1, String value2) { + addCriterion("resource_id not between", value1, value2, "resourceId"); + return (Criteria) this; + } + + public Criteria andFieldIdIsNull() { + addCriterion("field_id is null"); + return (Criteria) this; + } + + public Criteria andFieldIdIsNotNull() { + addCriterion("field_id is not null"); + return (Criteria) this; + } + + public Criteria andFieldIdEqualTo(String value) { + addCriterion("field_id =", value, "fieldId"); + return (Criteria) this; + } + + public Criteria andFieldIdNotEqualTo(String value) { + addCriterion("field_id <>", value, "fieldId"); + return (Criteria) this; + } + + public Criteria andFieldIdGreaterThan(String value) { + addCriterion("field_id >", value, "fieldId"); + return (Criteria) this; + } + + public Criteria andFieldIdGreaterThanOrEqualTo(String value) { + addCriterion("field_id >=", value, "fieldId"); + return (Criteria) this; + } + + public Criteria andFieldIdLessThan(String value) { + addCriterion("field_id <", value, "fieldId"); + return (Criteria) this; + } + + public Criteria andFieldIdLessThanOrEqualTo(String value) { + addCriterion("field_id <=", value, "fieldId"); + return (Criteria) this; + } + + public Criteria andFieldIdLike(String value) { + addCriterion("field_id like", value, "fieldId"); + return (Criteria) this; + } + + public Criteria andFieldIdNotLike(String value) { + addCriterion("field_id not like", value, "fieldId"); + return (Criteria) this; + } + + public Criteria andFieldIdIn(List values) { + addCriterion("field_id in", values, "fieldId"); + return (Criteria) this; + } + + public Criteria andFieldIdNotIn(List values) { + addCriterion("field_id not in", values, "fieldId"); + return (Criteria) this; + } + + public Criteria andFieldIdBetween(String value1, String value2) { + addCriterion("field_id between", value1, value2, "fieldId"); + return (Criteria) this; + } + + public Criteria andFieldIdNotBetween(String value1, String value2) { + addCriterion("field_id not between", value1, value2, "fieldId"); + return (Criteria) this; + } + + public Criteria andValueIsNull() { + addCriterion("`value` is null"); + return (Criteria) this; + } + + public Criteria andValueIsNotNull() { + addCriterion("`value` is not null"); + return (Criteria) this; + } + + public Criteria andValueEqualTo(String value) { + addCriterion("`value` =", value, "value"); + return (Criteria) this; + } + + public Criteria andValueNotEqualTo(String value) { + addCriterion("`value` <>", value, "value"); + return (Criteria) this; + } + + public Criteria andValueGreaterThan(String value) { + addCriterion("`value` >", value, "value"); + return (Criteria) this; + } + + public Criteria andValueGreaterThanOrEqualTo(String value) { + addCriterion("`value` >=", value, "value"); + return (Criteria) this; + } + + public Criteria andValueLessThan(String value) { + addCriterion("`value` <", value, "value"); + return (Criteria) this; + } + + public Criteria andValueLessThanOrEqualTo(String value) { + addCriterion("`value` <=", value, "value"); + return (Criteria) this; + } + + public Criteria andValueLike(String value) { + addCriterion("`value` like", value, "value"); + return (Criteria) this; + } + + public Criteria andValueNotLike(String value) { + addCriterion("`value` not like", value, "value"); + return (Criteria) this; + } + + public Criteria andValueIn(List values) { + addCriterion("`value` in", values, "value"); + return (Criteria) this; + } + + public Criteria andValueNotIn(List values) { + addCriterion("`value` not in", values, "value"); + return (Criteria) this; + } + + public Criteria andValueBetween(String value1, String value2) { + addCriterion("`value` between", value1, value2, "value"); + return (Criteria) this; + } + + public Criteria andValueNotBetween(String value1, String value2) { + addCriterion("`value` not between", value1, value2, "value"); + return (Criteria) this; + } + } + + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/CustomFieldTestCaseKey.java b/backend/src/main/java/io/metersphere/base/domain/CustomFieldTestCaseKey.java new file mode 100644 index 0000000000..d1b58b125a --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/domain/CustomFieldTestCaseKey.java @@ -0,0 +1,13 @@ +package io.metersphere.base.domain; + +import java.io.Serializable; +import lombok.Data; + +@Data +public class CustomFieldTestCaseKey implements Serializable { + private String resourceId; + + private String fieldId; + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/IssuesDao.java b/backend/src/main/java/io/metersphere/base/domain/IssuesDao.java index eaebc22304..40128d77ce 100644 --- a/backend/src/main/java/io/metersphere/base/domain/IssuesDao.java +++ b/backend/src/main/java/io/metersphere/base/domain/IssuesDao.java @@ -1,5 +1,6 @@ package io.metersphere.base.domain; +import io.metersphere.dto.CustomFieldDao; import lombok.Getter; import lombok.Setter; @@ -21,4 +22,5 @@ public class IssuesDao extends IssuesWithBLOBs { private String zentaoAssigned; private String refType; private String refId; + private List fields; } diff --git a/backend/src/main/java/io/metersphere/base/domain/ext/CustomFieldResource.java b/backend/src/main/java/io/metersphere/base/domain/ext/CustomFieldResource.java new file mode 100644 index 0000000000..efd2be49c5 --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/domain/ext/CustomFieldResource.java @@ -0,0 +1,20 @@ +package io.metersphere.base.domain.ext; + +import io.metersphere.base.domain.CustomFieldTestCase; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import java.io.Serializable; + +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +/** + * 自定义字段关联表的统一操作类 + * 字段跟 CustomFieldIssues, CustomFieldTestCase 一样 + * 考虑到表中数据量较大,按类型拆分成多个表 + */ +public class CustomFieldResource extends CustomFieldTestCase implements Serializable { + private static final long serialVersionUID = 1L; +} diff --git a/backend/src/main/java/io/metersphere/base/domain/ext/CustomFieldResourceKey.java b/backend/src/main/java/io/metersphere/base/domain/ext/CustomFieldResourceKey.java new file mode 100644 index 0000000000..a5b6c23a0d --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/domain/ext/CustomFieldResourceKey.java @@ -0,0 +1,11 @@ +package io.metersphere.base.domain.ext; + +import io.metersphere.base.domain.CustomFieldTestCaseKey; +import lombok.Data; + +import java.io.Serializable; + +@Data +public class CustomFieldResourceKey extends CustomFieldTestCaseKey implements Serializable { + private static final long serialVersionUID = 1L; +} diff --git a/backend/src/main/java/io/metersphere/base/mapper/CustomFieldIssuesMapper.java b/backend/src/main/java/io/metersphere/base/mapper/CustomFieldIssuesMapper.java new file mode 100644 index 0000000000..e4b5e5d06c --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/mapper/CustomFieldIssuesMapper.java @@ -0,0 +1,37 @@ +package io.metersphere.base.mapper; + +import io.metersphere.base.domain.CustomFieldIssues; +import io.metersphere.base.domain.CustomFieldIssuesExample; +import io.metersphere.base.domain.CustomFieldIssuesKey; +import java.util.List; +import org.apache.ibatis.annotations.Param; + +public interface CustomFieldIssuesMapper { + long countByExample(CustomFieldIssuesExample example); + + int deleteByExample(CustomFieldIssuesExample example); + + int deleteByPrimaryKey(CustomFieldIssuesKey key); + + int insert(CustomFieldIssues record); + + int insertSelective(CustomFieldIssues record); + + List selectByExampleWithBLOBs(CustomFieldIssuesExample example); + + List selectByExample(CustomFieldIssuesExample example); + + CustomFieldIssues selectByPrimaryKey(CustomFieldIssuesKey key); + + int updateByExampleSelective(@Param("record") CustomFieldIssues record, @Param("example") CustomFieldIssuesExample example); + + int updateByExampleWithBLOBs(@Param("record") CustomFieldIssues record, @Param("example") CustomFieldIssuesExample example); + + int updateByExample(@Param("record") CustomFieldIssues record, @Param("example") CustomFieldIssuesExample example); + + int updateByPrimaryKeySelective(CustomFieldIssues record); + + int updateByPrimaryKeyWithBLOBs(CustomFieldIssues record); + + int updateByPrimaryKey(CustomFieldIssues record); +} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/CustomFieldIssuesMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/CustomFieldIssuesMapper.xml new file mode 100644 index 0000000000..37014d662b --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/mapper/CustomFieldIssuesMapper.xml @@ -0,0 +1,234 @@ + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + resource_id, field_id, `value` + + + text_value + + + + + + delete from custom_field_issues + where resource_id = #{resourceId,jdbcType=VARCHAR} + and field_id = #{fieldId,jdbcType=VARCHAR} + + + delete from custom_field_issues + + + + + + insert into custom_field_issues (resource_id, field_id, `value`, + text_value) + values (#{resourceId,jdbcType=VARCHAR}, #{fieldId,jdbcType=VARCHAR}, #{value,jdbcType=VARCHAR}, + #{textValue,jdbcType=LONGVARCHAR}) + + + insert into custom_field_issues + + + resource_id, + + + field_id, + + + `value`, + + + text_value, + + + + + #{resourceId,jdbcType=VARCHAR}, + + + #{fieldId,jdbcType=VARCHAR}, + + + #{value,jdbcType=VARCHAR}, + + + #{textValue,jdbcType=LONGVARCHAR}, + + + + + + update custom_field_issues + + + resource_id = #{record.resourceId,jdbcType=VARCHAR}, + + + field_id = #{record.fieldId,jdbcType=VARCHAR}, + + + `value` = #{record.value,jdbcType=VARCHAR}, + + + text_value = #{record.textValue,jdbcType=LONGVARCHAR}, + + + + + + + + update custom_field_issues + set resource_id = #{record.resourceId,jdbcType=VARCHAR}, + field_id = #{record.fieldId,jdbcType=VARCHAR}, + `value` = #{record.value,jdbcType=VARCHAR}, + text_value = #{record.textValue,jdbcType=LONGVARCHAR} + + + + + + update custom_field_issues + set resource_id = #{record.resourceId,jdbcType=VARCHAR}, + field_id = #{record.fieldId,jdbcType=VARCHAR}, + `value` = #{record.value,jdbcType=VARCHAR} + + + + + + update custom_field_issues + + + `value` = #{value,jdbcType=VARCHAR}, + + + text_value = #{textValue,jdbcType=LONGVARCHAR}, + + + where resource_id = #{resourceId,jdbcType=VARCHAR} + and field_id = #{fieldId,jdbcType=VARCHAR} + + + update custom_field_issues + set `value` = #{value,jdbcType=VARCHAR}, + text_value = #{textValue,jdbcType=LONGVARCHAR} + where resource_id = #{resourceId,jdbcType=VARCHAR} + and field_id = #{fieldId,jdbcType=VARCHAR} + + + update custom_field_issues + set `value` = #{value,jdbcType=VARCHAR} + where resource_id = #{resourceId,jdbcType=VARCHAR} + and field_id = #{fieldId,jdbcType=VARCHAR} + + \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/CustomFieldMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/CustomFieldMapper.xml index 46cd910c9e..7dde51a323 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/CustomFieldMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/CustomFieldMapper.xml @@ -13,6 +13,7 @@ + @@ -76,8 +77,8 @@ - id, `name`, scene, `type`, remark, `system`, `global`, create_time, update_time, - create_user, project_id + id, `name`, scene, `type`, remark, `system`, `global`, create_time, update_time, + create_user, project_id, third_part `options` @@ -113,7 +114,7 @@ + select + + distinct + + + , + + from custom_field_test_case + + + + + order by ${orderByClause} + + + + + + delete from custom_field_test_case + where resource_id = #{resourceId,jdbcType=VARCHAR} + and field_id = #{fieldId,jdbcType=VARCHAR} + + + delete from custom_field_test_case + + + + + + insert into custom_field_test_case (resource_id, field_id, `value`, + text_value) + values (#{resourceId,jdbcType=VARCHAR}, #{fieldId,jdbcType=VARCHAR}, #{value,jdbcType=VARCHAR}, + #{textValue,jdbcType=LONGVARCHAR}) + + + insert into custom_field_test_case + + + resource_id, + + + field_id, + + + `value`, + + + text_value, + + + + + #{resourceId,jdbcType=VARCHAR}, + + + #{fieldId,jdbcType=VARCHAR}, + + + #{value,jdbcType=VARCHAR}, + + + #{textValue,jdbcType=LONGVARCHAR}, + + + + + + update custom_field_test_case + + + resource_id = #{record.resourceId,jdbcType=VARCHAR}, + + + field_id = #{record.fieldId,jdbcType=VARCHAR}, + + + `value` = #{record.value,jdbcType=VARCHAR}, + + + text_value = #{record.textValue,jdbcType=LONGVARCHAR}, + + + + + + + + update custom_field_test_case + set resource_id = #{record.resourceId,jdbcType=VARCHAR}, + field_id = #{record.fieldId,jdbcType=VARCHAR}, + `value` = #{record.value,jdbcType=VARCHAR}, + text_value = #{record.textValue,jdbcType=LONGVARCHAR} + + + + + + update custom_field_test_case + set resource_id = #{record.resourceId,jdbcType=VARCHAR}, + field_id = #{record.fieldId,jdbcType=VARCHAR}, + `value` = #{record.value,jdbcType=VARCHAR} + + + + + + update custom_field_test_case + + + `value` = #{value,jdbcType=VARCHAR}, + + + text_value = #{textValue,jdbcType=LONGVARCHAR}, + + + where resource_id = #{resourceId,jdbcType=VARCHAR} + and field_id = #{fieldId,jdbcType=VARCHAR} + + + update custom_field_test_case + set `value` = #{value,jdbcType=VARCHAR}, + text_value = #{textValue,jdbcType=LONGVARCHAR} + where resource_id = #{resourceId,jdbcType=VARCHAR} + and field_id = #{fieldId,jdbcType=VARCHAR} + + + update custom_field_test_case + set `value` = #{value,jdbcType=VARCHAR} + where resource_id = #{resourceId,jdbcType=VARCHAR} + and field_id = #{fieldId,jdbcType=VARCHAR} + + \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtCustomFieldResourceMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtCustomFieldResourceMapper.java new file mode 100644 index 0000000000..9d2b075dee --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtCustomFieldResourceMapper.java @@ -0,0 +1,23 @@ +package io.metersphere.base.mapper.ext; + +import io.metersphere.base.domain.ext.CustomFieldResource; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface ExtCustomFieldResourceMapper { + + int insert(@Param("tableName") String tableName, @Param("record") CustomFieldResource record); + + int updateByPrimaryKeySelective(@Param("tableName") String tableName, @Param("record") CustomFieldResource record); + + void deleteByResourceId(@Param("tableName") String tableName, @Param("resourceId") String resourceId); + + void deleteByResourceIds(@Param("tableName") String tableName, @Param("resourceIds") List resourceIds); + + List getByResourceId(@Param("tableName") String tableName, @Param("resourceId") String resourceId); + + List getByResourceIds(@Param("tableName") String tableName, @Param("resourceIds") List resourceIds); + + long countFieldResource(@Param("tableName") String tableName, @Param("resourceId") String resourceId, @Param("fieldId") String field_id); +} diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtCustomFieldResourceMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtCustomFieldResourceMapper.xml new file mode 100644 index 0000000000..b75de2e16c --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtCustomFieldResourceMapper.xml @@ -0,0 +1,57 @@ + + + + + + insert into ${tableName} (resource_id, field_id, `value`, + text_value) + values (#{record.resourceId,jdbcType=VARCHAR}, #{record.fieldId,jdbcType=VARCHAR}, #{record.value,jdbcType=VARCHAR}, + #{record.textValue,jdbcType=LONGVARCHAR}) + + + update ${tableName} + + + `value` = #{record.value,jdbcType=VARCHAR}, + + + text_value = #{record.textValue,jdbcType=LONGVARCHAR}, + + + where resource_id = #{record.resourceId,jdbcType=VARCHAR} + and field_id = #{record.fieldId,jdbcType=VARCHAR} + + + delete from ${tableName} + where resource_id = #{resourceId} + + + delete from ${tableName} + where resource_id in + + #{resourceId} + + + + + + diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.java index 1f1a4b1d2c..cc349702e8 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.java @@ -2,6 +2,7 @@ package io.metersphere.base.mapper.ext; import io.metersphere.base.domain.Issues; import io.metersphere.base.domain.IssuesDao; +import io.metersphere.track.dto.CustomFieldResourceCompatibleDTO; import io.metersphere.track.dto.PlanReportIssueDTO; import io.metersphere.track.request.testcase.IssuesRequest; import org.apache.ibatis.annotations.Param; @@ -32,5 +33,7 @@ public interface ExtIssuesMapper { int deleteIssues(@Param("issuesId") String issuesId, @Param("resourceId") String resourceId); + List getForCompatibleCustomField(String projectId, int offset, int pageSize); + IssuesDao selectByPrimaryKey(String id); } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.xml index 8b6c32a7dd..39676d1e5a 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtIssuesMapper.xml @@ -112,6 +112,12 @@ #{value} + + select id, platform, third_part_template from project where workspace_id = #{workspaceId} + diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java index a3584780d1..e72e77e7da 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java @@ -4,6 +4,7 @@ import io.metersphere.base.domain.TestCase; import io.metersphere.base.domain.TestCaseWithBLOBs; import io.metersphere.controller.request.BaseQueryRequest; import io.metersphere.dto.RelationshipGraphData; +import io.metersphere.track.dto.CustomFieldResourceCompatibleDTO; import io.metersphere.track.dto.TestCaseDTO; import io.metersphere.track.request.testcase.QueryTestCaseRequest; import io.metersphere.track.request.testcase.TestCaseBatchRequest; @@ -150,5 +151,7 @@ public interface ExtTestCaseMapper { List getForNodeEdit(@Param("ids") List ids); + List getForCompatibleCustomField(String projectId, int offset, int pageSize); + List> moduleExtraNodeCount(@Param("nodeIds") List nodeIds); } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml index ea07d6419f..38d03e2ed6 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml @@ -78,6 +78,16 @@ + + + and test_case.id in ( + select resource_id from custom_field_test_case where field_id = #{custom.id} + and trim(both '"' from value) + + + ) + + update test_case set custom_num = num where (custom_num is null or custom_num = '') and project_id = #{projectId} @@ -196,7 +206,7 @@ test_case.other_test_name, test_case.review_status, test_case.tags, test_case.demand_id, test_case.demand_name, test_case.`status`, test_case.custom_num, test_case.step_model, test_case.create_user, - test_case.custom_fields, test_case.ref_id + test_case.ref_id from test_case left join project_version on project_version.id = test_case.version_id @@ -971,6 +981,13 @@ + + UPDATE test_case INNER JOIN (( diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtWorkspaceMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtWorkspaceMapper.java index 071cb39193..a81c0a666d 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtWorkspaceMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtWorkspaceMapper.java @@ -12,4 +12,6 @@ public interface ExtWorkspaceMapper { List getWorkspaces(@Param("request") WorkspaceRequest request); List getWorkspaceByUserId(@Param("userId")String userId); + + List getWorkspaceIds(); } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtWorkspaceMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtWorkspaceMapper.xml index 6d741a1065..445297760c 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtWorkspaceMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtWorkspaceMapper.xml @@ -16,4 +16,7 @@ - \ No newline at end of file + + diff --git a/backend/src/main/java/io/metersphere/controller/CustomFieldController.java b/backend/src/main/java/io/metersphere/controller/CustomFieldController.java index 6b088657c2..4ebd9400ba 100644 --- a/backend/src/main/java/io/metersphere/controller/CustomFieldController.java +++ b/backend/src/main/java/io/metersphere/controller/CustomFieldController.java @@ -46,6 +46,11 @@ public class CustomFieldController { customFieldService.delete(id); } + @GetMapping("/get/{id}") + public CustomField get(@PathVariable(value = "id") String id) { + return customFieldService.get(id); + } + @PostMapping("/update") @MsAuditLog(module = OperLogModule.WORKSPACE_TEMPLATE_SETTINGS_FIELD, type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#customField.id)", content = "#msClass.getLogDetails(#customField.id)", msClass = CustomFieldService.class) public void update(@RequestBody CustomField customField) { diff --git a/backend/src/main/java/io/metersphere/controller/request/customfield/CustomFieldResourceRequest.java b/backend/src/main/java/io/metersphere/controller/request/customfield/CustomFieldResourceRequest.java new file mode 100644 index 0000000000..a5e05aad47 --- /dev/null +++ b/backend/src/main/java/io/metersphere/controller/request/customfield/CustomFieldResourceRequest.java @@ -0,0 +1,25 @@ +package io.metersphere.controller.request.customfield; + +import io.metersphere.base.domain.CustomField; +import io.metersphere.base.mapper.CustomFieldMapper; +import io.metersphere.base.mapper.ext.ExtCustomFieldResourceMapper; +import lombok.Getter; +import lombok.Setter; +import org.apache.ibatis.session.SqlSession; + +import java.util.Map; + +@Getter +@Setter +public class CustomFieldResourceRequest { + private String workspaceId; + private String projectId; + private Map wdFieldMap; + private Map globalFieldMap; + private Map jiraSyncFieldMap; + private String resourceType; + private SqlSession sqlSession; + private ExtCustomFieldResourceMapper batchMapper; + private CustomFieldMapper customFieldBatchMapper; + private boolean enableJiraSync; +} diff --git a/backend/src/main/java/io/metersphere/dto/CustomFieldDao.java b/backend/src/main/java/io/metersphere/dto/CustomFieldDao.java index 05125a76ee..bdab1f71dd 100644 --- a/backend/src/main/java/io/metersphere/dto/CustomFieldDao.java +++ b/backend/src/main/java/io/metersphere/dto/CustomFieldDao.java @@ -11,6 +11,10 @@ public class CustomFieldDao extends CustomField { private String defaultValue; + private String textValue; + + private String value; + private String customData; private String key; diff --git a/backend/src/main/java/io/metersphere/dto/CustomFieldResourceDTO.java b/backend/src/main/java/io/metersphere/dto/CustomFieldResourceDTO.java new file mode 100644 index 0000000000..4c7da93d93 --- /dev/null +++ b/backend/src/main/java/io/metersphere/dto/CustomFieldResourceDTO.java @@ -0,0 +1,16 @@ +package io.metersphere.dto; + +import io.metersphere.base.domain.ext.CustomFieldResource; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import java.io.Serializable; + +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class CustomFieldResourceDTO extends CustomFieldResource implements Serializable { + private String name; + private static final long serialVersionUID = 1L; +} diff --git a/backend/src/main/java/io/metersphere/excel/listener/TestCaseNoModelDataListener.java b/backend/src/main/java/io/metersphere/excel/listener/TestCaseNoModelDataListener.java index 7470f4773e..0c9ba97148 100644 --- a/backend/src/main/java/io/metersphere/excel/listener/TestCaseNoModelDataListener.java +++ b/backend/src/main/java/io/metersphere/excel/listener/TestCaseNoModelDataListener.java @@ -418,8 +418,9 @@ public class TestCaseNoModelDataListener extends AnalysisEventListener addFields) { + super.addFields(TABLE_NAME, resourceId, addFields); + } + + public void editFields(String resourceId, List editFields) { + super.editFields(TABLE_NAME, resourceId, editFields); + } + + public void batchEditFields(String resourceId, List fields) { + super.batchEditFields(TABLE_NAME, resourceId, fields); + } + + public int updateByPrimaryKeySelective(CustomFieldResource field) { + return super.updateByPrimaryKeySelective(TABLE_NAME, field); + } + + public int insert(CustomFieldResource field) { + return super.insert(TABLE_NAME, field); + } + + public void deleteByResourceId(String resourceId) { + super.deleteByResourceId(TABLE_NAME, resourceId); + } + + public void deleteByResourceIds(List resourceIds) { + super.deleteByResourceIds(TABLE_NAME, resourceIds); + } + + public Map> getMapByResourceIds(List resourceIds) { + return super.getMapByResourceIds(TABLE_NAME, resourceIds); + } + + public List getByResourceId(String resourceId) { + return super.getByResourceId(TABLE_NAME, resourceId); + } +} diff --git a/backend/src/main/java/io/metersphere/service/CustomFieldResourceService.java b/backend/src/main/java/io/metersphere/service/CustomFieldResourceService.java new file mode 100644 index 0000000000..aee74c0b99 --- /dev/null +++ b/backend/src/main/java/io/metersphere/service/CustomFieldResourceService.java @@ -0,0 +1,350 @@ +package io.metersphere.service; + +import com.alibaba.fastjson.JSONObject; +import io.metersphere.base.domain.CustomField; +import io.metersphere.base.domain.Project; +import io.metersphere.base.domain.ext.CustomFieldResource; +import io.metersphere.base.mapper.CustomFieldMapper; +import io.metersphere.base.mapper.ext.ExtBaseMapper; +import io.metersphere.base.mapper.ext.ExtCustomFieldResourceMapper; +import io.metersphere.base.mapper.ext.ExtIssuesMapper; +import io.metersphere.base.mapper.ext.ExtTestCaseMapper; +import io.metersphere.commons.constants.CustomFieldType; +import io.metersphere.commons.constants.IssuesManagePlatform; +import io.metersphere.commons.constants.TemplateConstants; +import io.metersphere.commons.exception.MSException; +import io.metersphere.commons.utils.LogUtil; +import io.metersphere.commons.utils.ServiceUtils; +import io.metersphere.controller.request.customfield.CustomFieldResourceRequest; +import io.metersphere.dto.CustomFieldDao; +import io.metersphere.dto.CustomFieldItemDTO; +import io.metersphere.track.dto.CustomFieldResourceCompatibleDTO; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.ibatis.session.ExecutorType; +import org.apache.ibatis.session.SqlSession; +import org.apache.ibatis.session.SqlSessionFactory; +import org.mybatis.spring.SqlSessionUtils; +import org.springframework.context.annotation.Lazy; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.*; + +@Service +@Transactional(rollbackFor = Exception.class) +public class CustomFieldResourceService { + + @Resource + private SqlSessionFactory sqlSessionFactory; + + @Lazy + @Resource + ProjectService projectService; + + @Lazy + @Resource + WorkspaceService workspaceService; + + @Resource + ExtTestCaseMapper extTestCaseMapper; + + @Resource + ExtIssuesMapper extIssuesMapper; + + @Resource + CustomFieldService customFieldService; + + @Resource + ExtBaseMapper extBaseMapper; + + @Resource + ExtCustomFieldResourceMapper extCustomFieldResourceMapper; + + @Lazy + @Resource + SystemParameterService systemParameterService; + + private int initCount = 0; + + protected void addFields(String tableName, String resourceId, List addFields) { + if (CollectionUtils.isNotEmpty(addFields)) { + this.checkInit(); + addFields.forEach(field -> { + createOrUpdateFields(tableName, resourceId, field); + }); + } + } + + protected void editFields(String tableName, String resourceId, List editFields) { + if (CollectionUtils.isNotEmpty(editFields)) { + this.checkInit(); + editFields.forEach(field -> { + createOrUpdateFields(tableName, resourceId, field); + }); + } + } + + protected void batchEditFields(String tableName, String resourceId, List fields) { + if (CollectionUtils.isNotEmpty(fields)) { + this.checkInit(); + SqlSession sqlSession = ServiceUtils.getBatchSqlSession(); + ExtCustomFieldResourceMapper batchMapper = sqlSession.getMapper(ExtCustomFieldResourceMapper.class); + for (CustomFieldResource field : fields) { + long count = extCustomFieldResourceMapper.countFieldResource(tableName, resourceId, field.getFieldId()); + if (count > 0) { + batchMapper.updateByPrimaryKeySelective(tableName, field); + } else { + batchMapper.insert(tableName, field); + } + } + sqlSession.flushStatements(); + if (sqlSession != null && sqlSessionFactory != null) { + SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory); + } + } + } + + private void createOrUpdateFields(String tableName, String resourceId, CustomFieldResource field) { + long count = extCustomFieldResourceMapper.countFieldResource(tableName, resourceId, field.getFieldId()); + field.setResourceId(resourceId); + if (count > 0) { + extCustomFieldResourceMapper.updateByPrimaryKeySelective(tableName, field); + } else { + extCustomFieldResourceMapper.insert(tableName, field); + } + } + + protected int updateByPrimaryKeySelective(String tableName, CustomFieldResource field) { + return extCustomFieldResourceMapper.updateByPrimaryKeySelective(tableName, field); + } + + protected int insert(String tableName, CustomFieldResource field) { + return extCustomFieldResourceMapper.insert(tableName, field); + } + + protected List getByResourceId(String tableName, String resourceId) { + return extCustomFieldResourceMapper.getByResourceId(tableName, resourceId); + } + + protected List getByResourceIds(String tableName, List resourceIds) { + if (CollectionUtils.isEmpty(resourceIds)) { + return new ArrayList<>(); + } + return extCustomFieldResourceMapper.getByResourceIds(tableName, resourceIds); + } + + protected Map> getMapByResourceIds(String tableName, List resourceIds) { + if (CollectionUtils.isEmpty(resourceIds)) { + return new HashMap<>(); + } + List customFieldResources = getByResourceIds(tableName, resourceIds); + Map> fieldMap = new HashMap<>(); + customFieldResources.forEach(i -> { + List fields = fieldMap.get(i.getResourceId()); + if (fields == null) { + fields = new ArrayList<>(); + } + CustomFieldDao customFieldDao = new CustomFieldDao(); + customFieldDao.setId(i.getFieldId()); + customFieldDao.setValue(i.getValue()); + customFieldDao.setTextValue(i.getTextValue()); + fields.add(customFieldDao); + fieldMap.put(i.getResourceId(), fields); + }); + return fieldMap; + } + + protected void deleteByResourceId(String tableName, String resourceId) { + extCustomFieldResourceMapper.deleteByResourceId(tableName, resourceId); + } + + protected void deleteByResourceIds(String tableName, List resourceIds) { + extCustomFieldResourceMapper.deleteByResourceIds(tableName, resourceIds); + } + + protected void checkInit() { + String value = systemParameterService.getValue("init.custom.field.resource"); + if (StringUtils.isNotBlank(value) && value.equals("over")) { + return; + } + MSException.throwException("数据升级处理中,请稍后重试!"); + } + + /** + * 初始化数据 + * 兼容旧数据 + */ + public void compatibleData() { + LogUtil.info("init CustomFieldResourceService compatibleData start ==================="); + List projectIds = projectService.getProjectIds(); + Map globalFieldMap = customFieldService.getGlobalNameMapByProjectId(); + SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH); + ExtCustomFieldResourceMapper batchMapper = sqlSession.getMapper(ExtCustomFieldResourceMapper.class); + CustomFieldMapper customFieldBatchMapper = sqlSession.getMapper(CustomFieldMapper.class); + + try { + CustomFieldResourceRequest param = new CustomFieldResourceRequest(); + param.setGlobalFieldMap(globalFieldMap); + param.setSqlSession(sqlSession); + param.setBatchMapper(batchMapper); + param.setCustomFieldBatchMapper(customFieldBatchMapper); + projectIds.forEach(projectId -> { + param.setWdFieldMap(customFieldService.getNameMapByProjectId(projectId)); + param.setJiraSyncFieldMap(new HashMap<>()); + param.setProjectId(projectId); + compatibleTestCase(param); + Project project = projectService.getProjectById(projectId); + compatibleIssue(param, project); + }); + sqlSession.flushStatements(); + sqlSession.commit(); + } catch (Exception e) { + LogUtil.error(e); + } finally { + SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory); + } + LogUtil.info("init CustomFieldResourceService compatibleData end ==================="); + } + + public void compatibleTestCase(CustomFieldResourceRequest param) { + param.setEnableJiraSync(false); + param.setResourceType(TemplateConstants.FieldTemplateScene.TEST_CASE.name()); + this.compatibleCommon(param); + } + + public void compatibleIssue( CustomFieldResourceRequest param, Project project) { + // 是否勾选了自动获取模板 + boolean enableJiraSync = project.getPlatform().equals(IssuesManagePlatform.Jira.toString()) && + (project.getThirdPartTemplate() == null ? false : project.getThirdPartTemplate() ); + param.setEnableJiraSync(enableJiraSync); + param.setResourceType(TemplateConstants.FieldTemplateScene.ISSUE.name()); + this.compatibleCommon(param); + } + + /** + * 对旧数据做数据初始化 + * 自定义字段不再存储在对应表的 customFields 字段 + * 改为添加中间表 + */ + protected void compatibleCommon(CustomFieldResourceRequest param) { + int pageNum = 1; + int pageSize = 1000; + List list; + do { + if (param.getResourceType().equals(TemplateConstants.FieldTemplateScene.ISSUE.name())) { + list = extIssuesMapper.getForCompatibleCustomField(param.getProjectId(), (pageNum - 1) * pageSize, pageSize); + } else { + list = extTestCaseMapper.getForCompatibleCustomField(param.getProjectId(), (pageNum - 1) * pageSize, pageSize); + } + pageNum++; + if (CollectionUtils.isNotEmpty(list)) { + list.forEach(resource -> { + // 获取对应资源的自定义字段,存入 CustomFieldResource + String customFields = resource.getCustomFields(); + if (StringUtils.isNotBlank(customFields)) { + try { + List fields = CustomFieldService.getCustomFields(customFields); + Set fieldSet = new HashSet<>(); + fields.forEach(field -> { + try { + CustomField customField; + if (StringUtils.isBlank(field.getName())) { return; } + if (param.isEnableJiraSync()) { + if (StringUtils.isBlank(field.getId()) || field.getId().length() == 36) { + // 自定义字段中id为空,或者是uuid的,就不处理了 + return; + } + Map jiraSyncFieldMap = param.getJiraSyncFieldMap(); + if (jiraSyncFieldMap.containsKey(field.getId())) { + customField = jiraSyncFieldMap.get(field.getId()); + } else { + customField = createCustomField(param.getProjectId(), field, param); + param.getJiraSyncFieldMap().put(field.getId(), customField); + } + } else { + customField = Optional.ofNullable(param.getWdFieldMap().get(field.getName() + param.getResourceType())) + .orElse(param.getGlobalFieldMap().get(field.getName() + param.getResourceType())); + + } + createCustomFieldResource(customField, fieldSet, resource, field, param); + } catch (Exception e) { + LogUtil.error(e); + } + }); + } catch (Exception e) { + LogUtil.error(e); + } + } + }); + } + } while (list.size() == pageSize); + } + + /** + * 如果是jira勾选了自动获取模板 + * 则创建对应的自定义字段,并标记成 thirdPart 为 true + * @param projectId + * @param field + * @param param + * @return + */ + private CustomField createCustomField(String projectId, CustomFieldItemDTO field, CustomFieldResourceRequest param) { + CustomField customField = new CustomField(); + customField.setId(UUID.randomUUID().toString()); + customField.setUpdateTime(System.currentTimeMillis()); + customField.setCreateTime(System.currentTimeMillis()); + customField.setGlobal(false); + customField.setSystem(false); + customField.setName(field.getId()); + customField.setScene(TemplateConstants.FieldTemplateScene.ISSUE.name()); + customField.setThirdPart(true); + customField.setType(field.getType()); + customField.setProjectId(projectId); + CustomFieldMapper customFieldBatchMapper = param.getCustomFieldBatchMapper(); + customFieldBatchMapper.insert(customField); + initCount++; + if (initCount > 1000) { + param.getSqlSession().flushStatements(); + param.getSqlSession().commit(); + initCount = 0; + } + return customField; + } + + private void createCustomFieldResource(CustomField customField, Set fieldSet, CustomFieldResourceCompatibleDTO resource, + CustomFieldItemDTO field, CustomFieldResourceRequest param) { + if (customField != null && field.getValue() != null) { + if (fieldSet.contains(customField.getId())) { + return; + } + String tableName; + if (param.getResourceType().equals(TemplateConstants.FieldTemplateScene.ISSUE.name())) { + tableName = "custom_field_issues"; + } else { + tableName = "custom_field_test_case"; + } + CustomFieldResource customFieldResource = new CustomFieldResource(); + customFieldResource.setResourceId(resource.getId()); + customFieldResource.setFieldId(customField.getId()); + if (StringUtils.isNotBlank(customField.getType()) + && StringUtils.equalsAny(CustomFieldType.RICH_TEXT.getValue(), CustomFieldType.TEXTAREA.getValue())) { + customFieldResource.setTextValue(field.getValue().toString()); + param.getBatchMapper().insert(tableName, customFieldResource); + } else { + if (field.getValue().toString().length() < 490) { + customFieldResource.setValue(JSONObject.toJSONString(field.getValue())); + param.getBatchMapper().insert(tableName, customFieldResource); + } + } + fieldSet.add(customField.getId()); + initCount++; + if (initCount > 1000) { + param.getSqlSession().flushStatements(); + param.getSqlSession().commit(); + initCount = 0; + } + } + } +} diff --git a/backend/src/main/java/io/metersphere/service/CustomFieldService.java b/backend/src/main/java/io/metersphere/service/CustomFieldService.java index e784bf1c13..ed0b8d00ab 100644 --- a/backend/src/main/java/io/metersphere/service/CustomFieldService.java +++ b/backend/src/main/java/io/metersphere/service/CustomFieldService.java @@ -8,8 +8,11 @@ import com.github.pagehelper.PageHelper; import io.metersphere.base.domain.CustomField; import io.metersphere.base.domain.CustomFieldExample; import io.metersphere.base.domain.CustomFieldTemplate; +import io.metersphere.base.domain.ext.CustomFieldResource; import io.metersphere.base.mapper.CustomFieldMapper; +import io.metersphere.base.mapper.CustomFieldTemplateMapper; import io.metersphere.base.mapper.ext.ExtCustomFieldMapper; +import io.metersphere.commons.constants.CustomFieldType; import io.metersphere.commons.constants.TemplateConstants; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.*; @@ -52,6 +55,8 @@ public class CustomFieldService { @Lazy @Resource CustomFieldTemplateService customFieldTemplateService; + @Resource + private CustomFieldTemplateMapper customFieldTemplateMapper; public String add(CustomField customField) { checkExist(customField); @@ -59,6 +64,7 @@ public class CustomFieldService { customField.setCreateTime(System.currentTimeMillis()); customField.setUpdateTime(System.currentTimeMillis()); customField.setGlobal(false); + customField.setThirdPart(false); customField.setCreateUser(SessionUtils.getUserId()); customFieldMapper.insert(customField); return customField.getId(); @@ -91,6 +97,10 @@ public class CustomFieldService { customFieldTemplateService.deleteByFieldId(id); } + public CustomField get(String id) { + return customFieldMapper.selectByPrimaryKey(id); + } + public void update(CustomField customField) { if (customField.getGlobal() != null && customField.getGlobal()) { // 如果是全局字段,则创建对应工作空间字段 @@ -132,6 +142,7 @@ public class CustomFieldService { CustomField customField = fieldMap.get(item.getFieldId()); BeanUtils.copyBean(customFieldDao, customField); BeanUtils.copyBean(customFieldDao, item); + customFieldDao.setId(item.getFieldId()); result.add(customFieldDao); }); } @@ -218,4 +229,98 @@ public class CustomFieldService { } return new ArrayList<>(); } + + public List getCustomFieldResource(String customFieldsStr) { + 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); + } + return list; + } + } + 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; + } + } + return new ArrayList<>(); + } + + public List getByProjectId(String projectId) { + CustomFieldExample example = new CustomFieldExample(); + example.createCriteria().andProjectIdEqualTo(projectId); + return customFieldMapper.selectByExample(example); + } + + public Map getNameMapByProjectId(String projectId) { + return this.getByProjectId(projectId) + .stream() + .collect(Collectors.toMap(i -> i.getName() + i.getScene(), i -> i, (val1, val2) -> val1)); + } + + public Map getGlobalNameMapByProjectId() { + CustomFieldExample example = new CustomFieldExample(); + example.createCriteria().andGlobalEqualTo(true); + return customFieldMapper.selectByExample(example) + .stream() + .collect(Collectors.toMap(i -> i.getName() + i.getScene(), i -> i)); + } } diff --git a/backend/src/main/java/io/metersphere/service/CustomFieldTestCaseService.java b/backend/src/main/java/io/metersphere/service/CustomFieldTestCaseService.java new file mode 100644 index 0000000000..c69b5246db --- /dev/null +++ b/backend/src/main/java/io/metersphere/service/CustomFieldTestCaseService.java @@ -0,0 +1,48 @@ +package io.metersphere.service; + +import io.metersphere.base.domain.ext.CustomFieldResource; +import io.metersphere.dto.CustomFieldDao; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +import java.util.Map; + +@Service +@Transactional(rollbackFor = Exception.class) +public class CustomFieldTestCaseService extends CustomFieldResourceService { + + private static final String TABLE_NAME = "custom_field_test_case"; + + public void addFields(String resourceId, List addFields) { + super.addFields(TABLE_NAME, resourceId, addFields); + } + + public void editFields(String resourceId, List editFields) { + super.editFields(TABLE_NAME, resourceId, editFields); + } + + public int updateByPrimaryKeySelective(CustomFieldResource field) { + return super.updateByPrimaryKeySelective(TABLE_NAME, field); + } + + public int insert(CustomFieldResource field) { + return super.insert(TABLE_NAME, field); + } + + public void deleteByResourceId(String resourceId) { + super.deleteByResourceId(TABLE_NAME, resourceId); + } + + public void deleteByResourceIds(List resourceIds) { + super.deleteByResourceIds(TABLE_NAME, resourceIds); + } + + public Map> getMapByResourceIds(List resourceIds) { + return super.getMapByResourceIds(TABLE_NAME, resourceIds); + } + + public List getByResourceId(String resourceId) { + return super.getByResourceId(TABLE_NAME, resourceId); + } +} diff --git a/backend/src/main/java/io/metersphere/service/ProjectService.java b/backend/src/main/java/io/metersphere/service/ProjectService.java index eabb9da3e4..ea20ca8293 100644 --- a/backend/src/main/java/io/metersphere/service/ProjectService.java +++ b/backend/src/main/java/io/metersphere/service/ProjectService.java @@ -759,6 +759,10 @@ public class ProjectService { return extProjectMapper.getProjectIds(); } + public List getProjectForCustomField(String workspaceId) { + return extProjectMapper.getProjectForCustomField(workspaceId); + } + public Map queryNameByIds(List ids) { return extProjectMapper.queryNameByIds(ids); } diff --git a/backend/src/main/java/io/metersphere/service/WorkspaceService.java b/backend/src/main/java/io/metersphere/service/WorkspaceService.java index 2740daa361..dfb6832934 100644 --- a/backend/src/main/java/io/metersphere/service/WorkspaceService.java +++ b/backend/src/main/java/io/metersphere/service/WorkspaceService.java @@ -329,4 +329,8 @@ public class WorkspaceService { return resource; } + + public List getWorkspaceIds() { + return extWorkspaceMapper.getWorkspaceIds(); + } } diff --git a/backend/src/main/java/io/metersphere/track/controller/TestCaseController.java b/backend/src/main/java/io/metersphere/track/controller/TestCaseController.java index 09d4a4370b..603cadf0f0 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestCaseController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestCaseController.java @@ -122,7 +122,6 @@ public class TestCaseController { @PostMapping("/relate/{goPage}/{pageSize}") public Pager> getTestCaseRelateList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestCaseRequest request) { -// Page page = PageHelper.startPage(goPage, pageSize, true); return testCaseService.getTestCaseRelateList(request, goPage, pageSize); } @@ -177,7 +176,7 @@ public class TestCaseController { } @GetMapping("/get/{testCaseId}") - public TestCaseWithBLOBs getTestCase(@PathVariable String testCaseId) { + public TestCaseDTO getTestCase(@PathVariable String testCaseId) { return testCaseService.getTestCase(testCaseId); } diff --git a/backend/src/main/java/io/metersphere/track/dto/CustomFieldResourceCompatibleDTO.java b/backend/src/main/java/io/metersphere/track/dto/CustomFieldResourceCompatibleDTO.java new file mode 100644 index 0000000000..77989cadb1 --- /dev/null +++ b/backend/src/main/java/io/metersphere/track/dto/CustomFieldResourceCompatibleDTO.java @@ -0,0 +1,9 @@ +package io.metersphere.track.dto; + +import lombok.Data; + +@Data +public class CustomFieldResourceCompatibleDTO { + private String id; + private String customFields; +} diff --git a/backend/src/main/java/io/metersphere/track/dto/TestCaseDTO.java b/backend/src/main/java/io/metersphere/track/dto/TestCaseDTO.java index 9650f02910..61b41dc1d3 100644 --- a/backend/src/main/java/io/metersphere/track/dto/TestCaseDTO.java +++ b/backend/src/main/java/io/metersphere/track/dto/TestCaseDTO.java @@ -2,6 +2,7 @@ package io.metersphere.track.dto; import io.metersphere.base.domain.IssuesDao; import io.metersphere.base.domain.TestCaseWithBLOBs; +import io.metersphere.dto.CustomFieldDao; import lombok.Getter; import lombok.Setter; @@ -20,7 +21,7 @@ public class TestCaseDTO extends TestCaseWithBLOBs { private String createName; private String lastExecuteResult; private String versionName; - + private List fields; private List caseTags = new ArrayList<>(); private List issueList = new ArrayList<>(); } 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 4ecb8d51e5..5fc2a77e27 100644 --- a/backend/src/main/java/io/metersphere/track/issue/AbstractIssuePlatform.java +++ b/backend/src/main/java/io/metersphere/track/issue/AbstractIssuePlatform.java @@ -70,7 +70,8 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform { protected String userId; protected String defaultCustomFields; protected boolean isThirdPartTemplate; - + protected CustomFieldIssuesService customFieldIssuesService; + protected CustomFieldService customFieldService; public String getKey() { return key; @@ -114,6 +115,8 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform { this.extIssuesMapper = CommonBeanFactory.getBean(ExtIssuesMapper.class); this.resourceService = CommonBeanFactory.getBean(ResourceService.class); this.testCaseIssueService = CommonBeanFactory.getBean(TestCaseIssueService.class); + this.customFieldIssuesService = CommonBeanFactory.getBean(CustomFieldIssuesService.class); + this.customFieldService = CommonBeanFactory.getBean(CustomFieldService.class); this.restTemplateIgnoreSSL = restTemplate; } 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 052fe6e3cd..0bd212e8f0 100644 --- a/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java +++ b/backend/src/main/java/io/metersphere/track/issue/JiraPlatform.java @@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject; import io.metersphere.base.domain.IssuesDao; import io.metersphere.base.domain.IssuesWithBLOBs; import io.metersphere.base.domain.Project; +import io.metersphere.base.domain.ext.CustomFieldResource; import io.metersphere.commons.constants.CustomFieldType; import io.metersphere.commons.constants.IssuesManagePlatform; import io.metersphere.commons.constants.IssuesStatus; @@ -484,6 +485,10 @@ public class JiraPlatform extends AbstractIssuePlatform { issues.forEach(item -> { try { getUpdateIssue(item, jiraClientV2.getIssues(item.getPlatformId())); + String customFields = item.getCustomFields(); + // 把自定义字段存入新表 + List customFieldResource = customFieldService.getJiraCustomFieldResource(customFields, project.getId()); + customFieldIssuesService.addFields(item.getId(), customFieldResource); issuesMapper.updateByPrimaryKeySelective(item); } catch (HttpClientErrorException e) { if (e.getRawStatusCode() == 404) { diff --git a/backend/src/main/java/io/metersphere/track/issue/TapdPlatform.java b/backend/src/main/java/io/metersphere/track/issue/TapdPlatform.java index 969a79997e..973fdce6da 100644 --- a/backend/src/main/java/io/metersphere/track/issue/TapdPlatform.java +++ b/backend/src/main/java/io/metersphere/track/issue/TapdPlatform.java @@ -213,6 +213,7 @@ public class TapdPlatform extends AbstractIssuePlatform { IssuesWithBLOBs updateIssue = getUpdateIssue(issuesMapper.selectByPrimaryKey(id), bug, statusMap); updateIssue.setId(id); updateIssue.setCustomFields(syncIssueCustomField(updateIssue.getCustomFields(), bug)); + customFieldIssuesService.addFields(id, customFieldService.getCustomFieldResource(updateIssue.getCustomFields())); issuesMapper.updateByPrimaryKeySelective(updateIssue); ids.remove(platformId); }); diff --git a/backend/src/main/java/io/metersphere/track/issue/ZentaoPlatform.java b/backend/src/main/java/io/metersphere/track/issue/ZentaoPlatform.java index 6a49c6d47e..7da6702cc8 100644 --- a/backend/src/main/java/io/metersphere/track/issue/ZentaoPlatform.java +++ b/backend/src/main/java/io/metersphere/track/issue/ZentaoPlatform.java @@ -4,13 +4,15 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; -import io.metersphere.base.domain.*; +import io.metersphere.base.domain.IssuesDao; +import io.metersphere.base.domain.IssuesExample; +import io.metersphere.base.domain.IssuesWithBLOBs; +import io.metersphere.base.domain.Project; import io.metersphere.commons.constants.IssuesManagePlatform; import io.metersphere.commons.constants.IssuesStatus; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.LogUtil; import io.metersphere.dto.UserDTO; -import io.metersphere.i18n.Translator; import io.metersphere.track.dto.DemandDTO; import io.metersphere.track.issue.client.ZentaoClient; import io.metersphere.track.issue.domain.PlatformUser; @@ -340,6 +342,7 @@ public class ZentaoPlatform extends AbstractIssuePlatform { IssuesWithBLOBs issue = issuesMapper.selectByPrimaryKey(item.getId()); JSONObject bug = zentaoClient.getBugById(item.getPlatformId()); issue = getUpdateIssues(issue, bug); + customFieldIssuesService.addFields(item.getId(), customFieldService.getCustomFieldResource(issue.getCustomFields())); issue.setId(item.getId()); issuesMapper.updateByPrimaryKeySelective(issue); }); diff --git a/backend/src/main/java/io/metersphere/track/request/testcase/EditTestCaseRequest.java b/backend/src/main/java/io/metersphere/track/request/testcase/EditTestCaseRequest.java index f8cba8d58d..661cb0cbb7 100644 --- a/backend/src/main/java/io/metersphere/track/request/testcase/EditTestCaseRequest.java +++ b/backend/src/main/java/io/metersphere/track/request/testcase/EditTestCaseRequest.java @@ -1,7 +1,7 @@ package io.metersphere.track.request.testcase; - import io.metersphere.base.domain.FileMetadata; import io.metersphere.base.domain.TestCaseWithBLOBs; +import io.metersphere.base.domain.ext.CustomFieldResource; import lombok.Getter; import lombok.Setter; @@ -15,6 +15,8 @@ public class EditTestCaseRequest extends TestCaseWithBLOBs { private List follows; private OtherInfoConfig otherInfoConfig; private String oldDataId; + private List addFields; + private List editFields; /** * 复制测试用例后,要进行复制的文件Id list */ diff --git a/backend/src/main/java/io/metersphere/track/request/testcase/IssuesUpdateRequest.java b/backend/src/main/java/io/metersphere/track/request/testcase/IssuesUpdateRequest.java index 02b54bf38b..1e00107b33 100644 --- a/backend/src/main/java/io/metersphere/track/request/testcase/IssuesUpdateRequest.java +++ b/backend/src/main/java/io/metersphere/track/request/testcase/IssuesUpdateRequest.java @@ -1,6 +1,7 @@ package io.metersphere.track.request.testcase; import io.metersphere.base.domain.IssuesWithBLOBs; +import io.metersphere.base.domain.ext.CustomFieldResource; import lombok.Getter; import lombok.Setter; @@ -13,6 +14,8 @@ public class IssuesUpdateRequest extends IssuesWithBLOBs { private String workspaceId; private List tapdUsers; + private List addFields; + private List editFields; /** * zentao bug 处理人 */ diff --git a/backend/src/main/java/io/metersphere/track/request/testcase/TestCaseBatchRequest.java b/backend/src/main/java/io/metersphere/track/request/testcase/TestCaseBatchRequest.java index fccf7caa43..0e2e591e32 100644 --- a/backend/src/main/java/io/metersphere/track/request/testcase/TestCaseBatchRequest.java +++ b/backend/src/main/java/io/metersphere/track/request/testcase/TestCaseBatchRequest.java @@ -2,6 +2,7 @@ package io.metersphere.track.request.testcase; import io.metersphere.base.domain.TestCaseWithBLOBs; import io.metersphere.controller.request.OrderRequest; +import io.metersphere.dto.CustomFieldResourceDTO; import lombok.Getter; import lombok.Setter; @@ -13,7 +14,7 @@ public class TestCaseBatchRequest extends TestCaseWithBLOBs { private List ids; private List orders; private String projectId; - private CustomFiledRequest customField; + private CustomFieldResourceDTO customField; private QueryTestCaseRequest condition; private String customTemplateFieldId; 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 0375abc3fc..645080f35c 100644 --- a/backend/src/main/java/io/metersphere/track/service/IssuesService.java +++ b/backend/src/main/java/io/metersphere/track/service/IssuesService.java @@ -21,10 +21,7 @@ import io.metersphere.log.utils.ReflexObjectUtil; import io.metersphere.log.vo.DetailColumn; import io.metersphere.log.vo.OperatingLogDetails; import io.metersphere.log.vo.track.TestPlanReference; -import io.metersphere.service.CustomFieldTemplateService; -import io.metersphere.service.IntegrationService; -import io.metersphere.service.IssueTemplateService; -import io.metersphere.service.ProjectService; +import io.metersphere.service.*; import io.metersphere.track.dto.*; import io.metersphere.track.issue.*; import io.metersphere.track.issue.domain.PlatformUser; @@ -78,6 +75,10 @@ public class IssuesService { private IssueFollowMapper issueFollowMapper; @Resource private TestPlanTestCaseMapper testPlanTestCaseMapper; + @Resource + private CustomFieldIssuesService customFieldIssuesService; + @Resource + private CustomFieldIssuesMapper customFieldIssuesMapper; public void testAuth(String workspaceId, String platform) { IssuesRequest issuesRequest = new IssuesRequest(); @@ -99,6 +100,7 @@ public class IssuesService { }); } saveFollows(issuesRequest.getId(), issuesRequest.getFollows()); + customFieldIssuesService.addFields(issuesRequest.getId(), issuesRequest.getAddFields()); return issues; } @@ -109,6 +111,8 @@ public class IssuesService { platformList.forEach(platform -> { platform.updateIssue(issuesRequest); }); + customFieldIssuesService.editFields(issuesRequest.getId(), issuesRequest.getEditFields()); + customFieldIssuesService.addFields(issuesRequest.getId(), issuesRequest.getAddFields()); // todo 缺陷更新事件? } @@ -178,15 +182,10 @@ public class IssuesService { ZentaoPlatform zentaoPlatform = (ZentaoPlatform) IssueFactory.createPlatform(IssuesManagePlatform.Zentao.name(), issuesRequest); zentaoPlatform.getZentaoAssignedAndBuilds(issuesWithBLOBs); } + buildCustomField(issuesWithBLOBs); return issuesWithBLOBs; } - public String getPlatformsByCaseId(String caseId) { - TestCaseWithBLOBs testCase = testCaseService.getTestCase(caseId); - Project project = projectService.getProjectById(testCase.getProjectId()); - return getPlatform(project.getId()); - } - public String getPlatform(String projectId) { Project project = projectService.getProjectById(projectId); return project.getPlatform(); @@ -224,32 +223,6 @@ public class IssuesService { return platforms; } - private Project getProjectByCaseId(String testCaseId) { - TestCaseWithBLOBs testCase = testCaseService.getTestCase(testCaseId); - // testCase 不存在 - if (testCase == null) { - return null; - } - return projectService.getProjectById(testCase.getProjectId()); - } - - private String getTapdProjectId(String testCaseId) { - TestCaseWithBLOBs testCase = testCaseService.getTestCase(testCaseId); - Project project = projectService.getProjectById(testCase.getProjectId()); - return project.getTapdId(); - } - - private String getJiraProjectKey(String testCaseId) { - TestCaseWithBLOBs testCase = testCaseService.getTestCase(testCaseId); - Project project = projectService.getProjectById(testCase.getProjectId()); - return project.getJiraKey(); - } - - private String getZentaoProjectId(String testCaseId) { - TestCaseWithBLOBs testCase = testCaseService.getTestCase(testCaseId); - Project project = projectService.getProjectById(testCase.getProjectId()); - return project.getZentaoId(); - } /** * 是否关联平台 @@ -289,6 +262,7 @@ public class IssuesService { testCaseIssueService.updateIssuesCount(i.getResourceId()); } }); + customFieldIssuesService.deleteByResourceId(id); testCaseIssuesMapper.deleteByExample(example); } @@ -374,9 +348,34 @@ public class IssuesService { item.setCaseIds(new ArrayList<>(caseIdSet)); item.setCaseCount(caseIdSet.size()); }); + buildCustomField(issues); return issues; } + private void buildCustomField(List data) { + if (CollectionUtils.isEmpty(data)) { + return; + } + Map> fieldMap = + customFieldIssuesService.getMapByResourceIds(data.stream().map(IssuesDao::getId).collect(Collectors.toList())); + data.forEach(i -> i.setFields(fieldMap.get(i.getId()))); + } + + private void buildCustomField(IssuesDao data) { + CustomFieldIssuesExample example = new CustomFieldIssuesExample(); + example.createCriteria().andResourceIdEqualTo(data.getId()); + List customFieldTestCases = customFieldIssuesMapper.selectByExample(example); + List fields = new ArrayList<>(); + customFieldTestCases.forEach(i -> { + CustomFieldDao customFieldDao = new CustomFieldDao(); + customFieldDao.setId(i.getFieldId()); + customFieldDao.setValue(i.getValue()); + customFieldDao.setTextValue(i.getTextValue()); + fields.add(customFieldDao); + }); + data.setFields(fields); + } + private Map getPlanMap(List issues) { List resourceIds = issues.stream().map(IssuesDao::getResourceId) .filter(Objects::nonNull) diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java index f4f7c11cc5..5fa224cef9 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java @@ -15,6 +15,7 @@ import io.metersphere.api.dto.definition.ApiTestCaseRequest; import io.metersphere.api.service.ApiAutomationService; import io.metersphere.api.service.ApiTestCaseService; import io.metersphere.base.domain.*; +import io.metersphere.base.domain.ext.CustomFieldResource; import io.metersphere.base.mapper.*; import io.metersphere.base.mapper.ext.ExtIssuesMapper; import io.metersphere.base.mapper.ext.ExtProjectVersionMapper; @@ -161,6 +162,10 @@ public class TestCaseService { @Lazy @Resource private ProjectApplicationService projectApplicationService; + @Resource + private CustomFieldTestCaseMapper customFieldTestCaseMapper; + @Resource + private CustomFieldTestCaseService customFieldTestCaseService; private ThreadLocal importCreateNum = new ThreadLocal<>(); private ThreadLocal beforeImportCreateNum = new ThreadLocal<>(); @@ -212,6 +217,7 @@ public class TestCaseService { testCaseMapper.insert(request); saveFollows(request.getId(), request.getFollows()); + customFieldTestCaseService.addFields(request.getId(), request.getAddFields()); return request; } @@ -298,14 +304,12 @@ public class TestCaseService { } } - public List getTestCaseByNodeId(List nodeIds) { - TestCaseExample testCaseExample = new TestCaseExample(); - testCaseExample.createCriteria().andNodeIdIn(nodeIds); - return testCaseMapper.selectByExample(testCaseExample); - } - - public TestCaseWithBLOBs getTestCase(String testCaseId) { - return testCaseMapper.selectByPrimaryKey(testCaseId); + public TestCaseDTO getTestCase(String testCaseId) { + TestCaseWithBLOBs testCaseWithBLOBs = testCaseMapper.selectByPrimaryKey(testCaseId); + TestCaseDTO testCaseDTO = new TestCaseDTO(); + BeanUtils.copyBean(testCaseDTO, testCaseWithBLOBs); + buildCustomField(testCaseDTO); + return testCaseDTO; } public TestCaseWithBLOBs editTestCase(EditTestCaseRequest testCase) { @@ -340,6 +344,9 @@ public class TestCaseService { } } + customFieldTestCaseService.editFields(testCase.getId(), testCase.getEditFields()); + customFieldTestCaseService.addFields(testCase.getId(), testCase.getAddFields()); + testCase.setLatest(null); testCaseMapper.updateByPrimaryKeySelective(testCase); @@ -559,6 +566,7 @@ public class TestCaseService { relateDelete(testCaseId); relationshipEdgeService.delete(testCaseId); // 删除关系图 deleteFollows(testCaseId); + customFieldTestCaseService.deleteByResourceId(testCaseId); // 删除自定义字段关联关系 return testCaseMapper.deleteByPrimaryKey(testCaseId); } @@ -616,10 +624,35 @@ public class TestCaseService { } else { buildProjectInfoWidthoutProject(list); } + buildCustomField(list); list = this.parseStatus(list); return list; } + private void buildCustomField(List data) { + if (CollectionUtils.isEmpty(data)) { + return; + } + Map> fieldMap = + customFieldTestCaseService.getMapByResourceIds(data.stream().map(TestCaseDTO::getId).collect(Collectors.toList())); + data.forEach(i -> i.setFields(fieldMap.get(i.getId()))); + } + + private void buildCustomField(TestCaseDTO data) { + CustomFieldTestCaseExample example = new CustomFieldTestCaseExample(); + example.createCriteria().andResourceIdEqualTo(data.getId()); + List customFieldTestCases = customFieldTestCaseMapper.selectByExample(example); + List fields = new ArrayList<>(); + customFieldTestCases.forEach(i -> { + CustomFieldDao customFieldDao = new CustomFieldDao(); + customFieldDao.setId(i.getFieldId()); + customFieldDao.setValue(i.getValue()); + customFieldDao.setTextValue(i.getTextValue()); + fields.add(customFieldDao); + }); + data.setFields(fields); + } + private void buildProjectInfoWidthoutProject(List resList) { resList.forEach(i -> { Project project = projectMapper.selectByPrimaryKey(i.getProjectId()); @@ -1428,10 +1461,11 @@ public class TestCaseService { StringBuilder result = new StringBuilder(""); Map> customSelectValueMap = new HashMap<>(); + Map customNameMap = new HashMap<>(); TestCaseTemplateService testCaseTemplateService = CommonBeanFactory.getBean(TestCaseTemplateService.class); TestCaseTemplateDao testCaseTemplate = testCaseTemplateService.getTemplate(request.getProjectId()); - List customFieldList = null; + List customFieldList; if (testCaseTemplate == null) { customFieldList = new ArrayList<>(); } else { @@ -1462,7 +1496,8 @@ public class TestCaseService { } catch (Exception e) { } } - customSelectValueMap.put(dto.getName(), map); + customSelectValueMap.put(dto.getId(), map); + customNameMap.put(dto.getId(), dto.getName()); } @@ -1548,23 +1583,20 @@ public class TestCaseService { } data.setMaintainer(t.getMaintainer()); data.setStatus(t.getStatus()); - String customFields = t.getCustomFields(); try { - JSONArray customFieldsArr = JSONArray.parseArray(customFields); + List fields = customFieldTestCaseService.getByResourceId(t.getId()); Map map = new HashMap<>(); - for (int index = 0; index < customFieldsArr.size(); index++) { - JSONObject obj = customFieldsArr.getJSONObject(index); - if (obj.containsKey("name") && obj.containsKey("value")) { - //进行key value对换 - String name = obj.getString("name"); - String value = obj.getString("value"); - if (customSelectValueMap.containsKey(name)) { - if (customSelectValueMap.get(name).containsKey(value)) { - value = customSelectValueMap.get(name).get(value); - } + for (int index = 0; index < fields.size(); index++) { + CustomFieldResource field = fields.get(index); + //进行key value对换 + String id = field.getFieldId(); + String value = JSONObject.parse(field.getValue()).toString(); + if (customSelectValueMap.containsKey(id)) { + if (customSelectValueMap.get(id).containsKey(value)) { + value = customSelectValueMap.get(id).get(value); } - map.put(name, value); } + map.put(customNameMap.get(id), value); } data.setCustomDatas(map); } catch (Exception e) { @@ -1589,33 +1621,20 @@ public class TestCaseService { if (request.getCustomField() != null) { List testCases = extTestCaseMapper.getCustomFieldsByIds(ids); testCases.forEach((testCase) -> { - String customFields = testCase.getCustomFields(); - List fields; - if (StringUtils.isBlank(customFields)) { - fields = new ArrayList<>(); + CustomFieldResourceDTO customField = request.getCustomField(); + if (StringUtils.equals(customField.getName(), "用例等级")) { + testCase.setPriority(JSONObject.parse(customField.getValue()).toString()); + } else if (StringUtils.equals(request.getCustomField().getName(), "用例状态")) { + testCase.setStatus(JSONObject.parse(customField.getValue()).toString()); + } else if (StringUtils.equals(customField.getName(), "责任人")) { + testCase.setMaintainer(JSONObject.parse(customField.getValue()).toString()); } else { - fields = JSONObject.parseArray(customFields, TestCaseBatchRequest.CustomFiledRequest.class); - } - - boolean hasField = false; - for (TestCaseBatchRequest.CustomFiledRequest field : fields) { - if (StringUtils.equals(request.getCustomField().getName(), field.getName())) { - field.setValue(request.getCustomField().getValue()); - hasField = true; - break; + customField.setResourceId(testCase.getId()); + int row = customFieldTestCaseService.updateByPrimaryKeySelective(customField); + if (row < 1) { + customFieldTestCaseService.insert(customField); } } - if (!hasField) { - TestCaseBatchRequest.CustomFiledRequest customField = request.getCustomField(); - customField.setId(request.getCustomTemplateFieldId()); - customField.setName(request.getCustomField().getName()); - customField.setValue(request.getCustomField().getValue()); - fields.add(request.getCustomField()); - } - if (StringUtils.equals(request.getCustomField().getName(), "用例等级")) { - testCase.setPriority((String) request.getCustomField().getValue()); - } - testCase.setCustomFields(JSONObject.toJSONString(fields)); testCase.setUpdateTime(System.currentTimeMillis()); TestCaseExample example = new TestCaseExample(); example.createCriteria().andIdEqualTo(testCase.getId()); @@ -1697,6 +1716,7 @@ public class TestCaseService { deleteTestPlanTestCaseBath(request.getIds()); relationshipEdgeService.delete(request.getIds()); // 删除关系图 + customFieldTestCaseService.deleteByResourceIds(request.getIds()); // 删除自定义字段 request.getIds().forEach(testCaseId -> { // todo 优化下效率 testCaseIssueService.delTestCaseIssues(testCaseId); @@ -1897,17 +1917,6 @@ public class TestCaseService { List data = request.getData(); if (CollectionUtils.isNotEmpty(data)) { - List editIds = data.stream() - .filter(TestCaseMinderEditRequest.TestCaseMinderEditItem::getIsEdit) - .map(TestCaseWithBLOBs::getId).collect(Collectors.toList()); - - Map testCaseMap = new HashMap<>(); - if (CollectionUtils.isNotEmpty(editIds)) { - TestCaseExample example = new TestCaseExample(); - example.createCriteria().andIdIn(editIds); - List testCaseWithBLOBs = testCaseMapper.selectByExampleWithBLOBs(example); - testCaseMap = testCaseWithBLOBs.stream().collect(Collectors.toMap(TestCaseWithBLOBs::getId, t -> t)); - } for (TestCaseMinderEditRequest.TestCaseMinderEditItem item : data) { if (StringUtils.isBlank(item.getNodeId()) || item.getNodeId().equals("root")) { @@ -1915,12 +1924,9 @@ public class TestCaseService { } item.setProjectId(request.getProjectId()); if (item.getIsEdit()) { - TestCaseWithBLOBs dbCase = testCaseMap.get(item.getId()); - if (editCustomFieldsPriority(dbCase, item.getPriority())) { - item.setCustomFields(dbCase.getCustomFields()); - } EditTestCaseRequest editRequest = new EditTestCaseRequest(); BeanUtils.copyBean(editRequest, item); + editRequest.setCustomFields(null); editTestCase(editRequest); changeOrder(item, request.getProjectId()); } else { @@ -1949,29 +1955,6 @@ public class TestCaseService { } } - /** - * 脑图编辑之后修改用例等级,同时修改自定义字段的用例等级 - * - * @param dbCase - * @param priority - * @return - */ - private boolean editCustomFieldsPriority(TestCaseWithBLOBs dbCase, String priority) { - String customFields = dbCase.getCustomFields(); - if (StringUtils.isNotBlank(customFields)) { - JSONArray fields = JSONObject.parseArray(customFields); - for (int i = 0; i < fields.size(); i++) { - JSONObject field = fields.getJSONObject(i); - if (field.getString("name").equals("用例等级")) { - field.put("value", priority); - dbCase.setCustomFields(JSONObject.toJSONString(fields)); - return true; - } - } - } - return false; - } - public List getTestCaseByProjectId(String projectId) { TestCaseExample example = new TestCaseExample(); example.createCriteria().andProjectIdEqualTo(projectId).andStatusNotEqualTo("Trash").andLatestEqualTo(true); diff --git a/backend/src/main/resources/db/migration/V115__1.20__release.sql b/backend/src/main/resources/db/migration/V115__1.20__release.sql index 0587041fc7..f813ad1eae 100644 --- a/backend/src/main/resources/db/migration/V115__1.20__release.sql +++ b/backend/src/main/resources/db/migration/V115__1.20__release.sql @@ -302,3 +302,7 @@ ALTER TABLE `api_scenario` ADD INDEX index_project_id ( `project_id`); ALTER TABLE share_info ADD lang varchar(10) NULL; UPDATE system_parameter SET param_value = 'http://local-selenium-grid:4444' WHERE param_key = 'base.selenium.docker.url'; + + + + diff --git a/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue b/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue index aea52611cc..ed0af1e283 100644 --- a/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue +++ b/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue @@ -3,9 +3,11 @@ - - + + 0 ? requireComponent("./graph/RelationshipGraphDrawer.vue") : {}; @@ -343,6 +346,7 @@ export default { MsTable, MsTableColumn, HeaderLabelOperate, + MsSearch, "relationshipGraphDrawer": relationshipGraphDrawer.default, HeaderCustom: () => import("@/business/components/common/head/HeaderCustom"), BatchMove: () => import("../../../track/case/components/BatchMove"), diff --git a/frontend/src/business/components/api/automation/scenario/api/RelevanceCaseList.vue b/frontend/src/business/components/api/automation/scenario/api/RelevanceCaseList.vue index c1b8f4cd7e..c1eb6122ce 100644 --- a/frontend/src/business/components/api/automation/scenario/api/RelevanceCaseList.vue +++ b/frontend/src/business/components/api/automation/scenario/api/RelevanceCaseList.vue @@ -10,12 +10,10 @@ - - - + +
- - + + @@ -95,6 +95,7 @@ import {ENV_TYPE} from "@/common/js/constants"; import {getCurrentProjectID, hasLicense} from "@/common/js/utils"; import MsTable from "@/business/components/common/components/table/MsTable"; import MsTag from "@/business/components/common/components/MsTag"; +import MsSearch from "@/business/components/common/components/search/MsSearch"; const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/); const VersionSelect = requireComponent.keys().length > 0 ? requireComponent("./version/VersionSelect.vue") : {}; @@ -111,6 +112,7 @@ export default { MsTag, MsApiReportDetail, MsTableAdvSearchBar, + MsSearch, 'VersionSelect': VersionSelect.default, }, props: { diff --git a/frontend/src/business/components/api/definition/components/complete/ApiTableList.vue b/frontend/src/business/components/api/definition/components/complete/ApiTableList.vue index 9bc12bcc44..6d87d9a51b 100644 --- a/frontend/src/business/components/api/definition/components/complete/ApiTableList.vue +++ b/frontend/src/business/components/api/definition/components/complete/ApiTableList.vue @@ -1,11 +1,10 @@