diff --git a/backend/framework/domain/src/main/java/io/metersphere/system/domain/UserView.java b/backend/framework/domain/src/main/java/io/metersphere/system/domain/UserView.java new file mode 100644 index 0000000000..e786d40578 --- /dev/null +++ b/backend/framework/domain/src/main/java/io/metersphere/system/domain/UserView.java @@ -0,0 +1,133 @@ +package io.metersphere.system.domain; + +import io.metersphere.validation.groups.*; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.*; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Arrays; +import lombok.Data; + +@Data +public class UserView implements Serializable { + @Schema(description = "视图ID", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{user_view.id.not_blank}", groups = {Updated.class}) + @Size(min = 1, max = 50, message = "{user_view.id.length_range}", groups = {Created.class, Updated.class}) + private String id; + + @Schema(description = "用户ID", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{user_view.user_id.not_blank}", groups = {Created.class}) + @Size(min = 1, max = 50, message = "{user_view.user_id.length_range}", groups = {Created.class, Updated.class}) + private String userId; + + @Schema(description = "视图名称", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{user_view.name.not_blank}", groups = {Created.class}) + @Size(min = 1, max = 255, message = "{user_view.name.length_range}", groups = {Created.class, Updated.class}) + private String name; + + @Schema(description = "视图类型,例如功能用例视图", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{user_view.view_type.not_blank}", groups = {Created.class}) + @Size(min = 1, max = 50, message = "{user_view.view_type.length_range}", groups = {Created.class, Updated.class}) + private String viewType; + + @Schema(description = "视图的应用范围,一般为项目ID", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{user_view.scope_id.not_blank}", groups = {Created.class}) + @Size(min = 1, max = 50, message = "{user_view.scope_id.length_range}", groups = {Created.class, Updated.class}) + private String scopeId; + + @Schema(description = "自定义排序", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "{user_view.pos.not_blank}", groups = {Created.class}) + private Long pos; + + @Schema(description = "匹配模式:AND/OR", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{user_view.search_mode.not_blank}", groups = {Created.class}) + @Size(min = 1, max = 10, message = "{user_view.search_mode.length_range}", groups = {Created.class, Updated.class}) + private String searchMode; + + @Schema(description = "创建时间") + private Long createTime; + + @Schema(description = "更新时间") + private Long updateTime; + + private static final long serialVersionUID = 1L; + + public enum Column { + id("id", "id", "VARCHAR", false), + userId("user_id", "userId", "VARCHAR", false), + name("name", "name", "VARCHAR", true), + viewType("view_type", "viewType", "VARCHAR", false), + scopeId("scope_id", "scopeId", "VARCHAR", false), + pos("pos", "pos", "BIGINT", false), + searchMode("search_mode", "searchMode", "VARCHAR", false), + createTime("create_time", "createTime", "BIGINT", false), + updateTime("update_time", "updateTime", "BIGINT", false); + + private static final String BEGINNING_DELIMITER = "`"; + + private static final String ENDING_DELIMITER = "`"; + + private final String column; + + private final boolean isColumnNameDelimited; + + private final String javaProperty; + + private final String jdbcType; + + public String value() { + return this.column; + } + + public String getValue() { + return this.column; + } + + public String getJavaProperty() { + return this.javaProperty; + } + + public String getJdbcType() { + return this.jdbcType; + } + + Column(String column, String javaProperty, String jdbcType, boolean isColumnNameDelimited) { + this.column = column; + this.javaProperty = javaProperty; + this.jdbcType = jdbcType; + this.isColumnNameDelimited = isColumnNameDelimited; + } + + public String desc() { + return this.getEscapedColumnName() + " DESC"; + } + + public String asc() { + return this.getEscapedColumnName() + " ASC"; + } + + public static Column[] excludes(Column ... excludes) { + ArrayList columns = new ArrayList<>(Arrays.asList(Column.values())); + if (excludes != null && excludes.length > 0) { + columns.removeAll(new ArrayList<>(Arrays.asList(excludes))); + } + return columns.toArray(new Column[]{}); + } + + public static Column[] all() { + return Column.values(); + } + + public String getEscapedColumnName() { + if (this.isColumnNameDelimited) { + return new StringBuilder().append(BEGINNING_DELIMITER).append(this.column).append(ENDING_DELIMITER).toString(); + } else { + return this.column; + } + } + + public String getAliasedEscapedColumnName() { + return this.getEscapedColumnName(); + } + } +} \ No newline at end of file diff --git a/backend/framework/domain/src/main/java/io/metersphere/system/domain/UserViewCondition.java b/backend/framework/domain/src/main/java/io/metersphere/system/domain/UserViewCondition.java new file mode 100644 index 0000000000..b6ba1274e5 --- /dev/null +++ b/backend/framework/domain/src/main/java/io/metersphere/system/domain/UserViewCondition.java @@ -0,0 +1,119 @@ +package io.metersphere.system.domain; + +import io.metersphere.validation.groups.*; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.*; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Arrays; +import lombok.Data; + +@Data +public class UserViewCondition implements Serializable { + @Schema(description = "条件ID", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{user_view_condition.id.not_blank}", groups = {Updated.class}) + @Size(min = 1, max = 50, message = "{user_view_condition.id.length_range}", groups = {Created.class, Updated.class}) + private String id; + + @Schema(description = "视图ID", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{user_view_condition.user_view_id.not_blank}", groups = {Created.class}) + @Size(min = 1, max = 50, message = "{user_view_condition.user_view_id.length_range}", groups = {Created.class, Updated.class}) + private String userViewId; + + @Schema(description = "参数名称", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{user_view_condition.name.not_blank}", groups = {Created.class}) + @Size(min = 1, max = 255, message = "{user_view_condition.name.length_range}", groups = {Created.class, Updated.class}) + private String name; + + @Schema(description = "查询的期望值") + private String value; + + @Schema(description = "期望值的数据类型:STRING,INT,FLOAT,ARRAY") + private String valueType; + + @Schema(description = "是否为自定义字段", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "{user_view_condition.custom_field.not_blank}", groups = {Created.class}) + private Boolean customField; + + @Schema(description = "操作符:等于、大于、小于、等") + private String operator; + + private static final long serialVersionUID = 1L; + + public enum Column { + id("id", "id", "VARCHAR", false), + userViewId("user_view_id", "userViewId", "VARCHAR", false), + name("name", "name", "VARCHAR", true), + value("value", "value", "VARCHAR", true), + valueType("value_type", "valueType", "VARCHAR", false), + customField("custom_field", "customField", "BIT", false), + operator("operator", "operator", "VARCHAR", true); + + private static final String BEGINNING_DELIMITER = "`"; + + private static final String ENDING_DELIMITER = "`"; + + private final String column; + + private final boolean isColumnNameDelimited; + + private final String javaProperty; + + private final String jdbcType; + + public String value() { + return this.column; + } + + public String getValue() { + return this.column; + } + + public String getJavaProperty() { + return this.javaProperty; + } + + public String getJdbcType() { + return this.jdbcType; + } + + Column(String column, String javaProperty, String jdbcType, boolean isColumnNameDelimited) { + this.column = column; + this.javaProperty = javaProperty; + this.jdbcType = jdbcType; + this.isColumnNameDelimited = isColumnNameDelimited; + } + + public String desc() { + return this.getEscapedColumnName() + " DESC"; + } + + public String asc() { + return this.getEscapedColumnName() + " ASC"; + } + + public static Column[] excludes(Column ... excludes) { + ArrayList columns = new ArrayList<>(Arrays.asList(Column.values())); + if (excludes != null && excludes.length > 0) { + columns.removeAll(new ArrayList<>(Arrays.asList(excludes))); + } + return columns.toArray(new Column[]{}); + } + + public static Column[] all() { + return Column.values(); + } + + public String getEscapedColumnName() { + if (this.isColumnNameDelimited) { + return new StringBuilder().append(BEGINNING_DELIMITER).append(this.column).append(ENDING_DELIMITER).toString(); + } else { + return this.column; + } + } + + public String getAliasedEscapedColumnName() { + return this.getEscapedColumnName(); + } + } +} \ No newline at end of file diff --git a/backend/framework/domain/src/main/java/io/metersphere/system/domain/UserViewConditionExample.java b/backend/framework/domain/src/main/java/io/metersphere/system/domain/UserViewConditionExample.java new file mode 100644 index 0000000000..117f0af23c --- /dev/null +++ b/backend/framework/domain/src/main/java/io/metersphere/system/domain/UserViewConditionExample.java @@ -0,0 +1,680 @@ +package io.metersphere.system.domain; + +import java.util.ArrayList; +import java.util.List; + +public class UserViewConditionExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + public UserViewConditionExample() { + 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 andIdIsNull() { + addCriterion("id is null"); + return (Criteria) this; + } + + public Criteria andIdIsNotNull() { + addCriterion("id is not null"); + return (Criteria) this; + } + + public Criteria andIdEqualTo(String value) { + addCriterion("id =", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotEqualTo(String value) { + addCriterion("id <>", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThan(String value) { + addCriterion("id >", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThanOrEqualTo(String value) { + addCriterion("id >=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThan(String value) { + addCriterion("id <", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThanOrEqualTo(String value) { + addCriterion("id <=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLike(String value) { + addCriterion("id like", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotLike(String value) { + addCriterion("id not like", value, "id"); + return (Criteria) this; + } + + public Criteria andIdIn(List values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List values) { + addCriterion("id not in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdBetween(String value1, String value2) { + addCriterion("id between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdNotBetween(String value1, String value2) { + addCriterion("id not between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andUserViewIdIsNull() { + addCriterion("user_view_id is null"); + return (Criteria) this; + } + + public Criteria andUserViewIdIsNotNull() { + addCriterion("user_view_id is not null"); + return (Criteria) this; + } + + public Criteria andUserViewIdEqualTo(String value) { + addCriterion("user_view_id =", value, "userViewId"); + return (Criteria) this; + } + + public Criteria andUserViewIdNotEqualTo(String value) { + addCriterion("user_view_id <>", value, "userViewId"); + return (Criteria) this; + } + + public Criteria andUserViewIdGreaterThan(String value) { + addCriterion("user_view_id >", value, "userViewId"); + return (Criteria) this; + } + + public Criteria andUserViewIdGreaterThanOrEqualTo(String value) { + addCriterion("user_view_id >=", value, "userViewId"); + return (Criteria) this; + } + + public Criteria andUserViewIdLessThan(String value) { + addCriterion("user_view_id <", value, "userViewId"); + return (Criteria) this; + } + + public Criteria andUserViewIdLessThanOrEqualTo(String value) { + addCriterion("user_view_id <=", value, "userViewId"); + return (Criteria) this; + } + + public Criteria andUserViewIdLike(String value) { + addCriterion("user_view_id like", value, "userViewId"); + return (Criteria) this; + } + + public Criteria andUserViewIdNotLike(String value) { + addCriterion("user_view_id not like", value, "userViewId"); + return (Criteria) this; + } + + public Criteria andUserViewIdIn(List values) { + addCriterion("user_view_id in", values, "userViewId"); + return (Criteria) this; + } + + public Criteria andUserViewIdNotIn(List values) { + addCriterion("user_view_id not in", values, "userViewId"); + return (Criteria) this; + } + + public Criteria andUserViewIdBetween(String value1, String value2) { + addCriterion("user_view_id between", value1, value2, "userViewId"); + return (Criteria) this; + } + + public Criteria andUserViewIdNotBetween(String value1, String value2) { + addCriterion("user_view_id not between", value1, value2, "userViewId"); + return (Criteria) this; + } + + public Criteria andNameIsNull() { + addCriterion("`name` is null"); + return (Criteria) this; + } + + public Criteria andNameIsNotNull() { + addCriterion("`name` is not null"); + return (Criteria) this; + } + + public Criteria andNameEqualTo(String value) { + addCriterion("`name` =", value, "name"); + return (Criteria) this; + } + + public Criteria andNameNotEqualTo(String value) { + addCriterion("`name` <>", value, "name"); + return (Criteria) this; + } + + public Criteria andNameGreaterThan(String value) { + addCriterion("`name` >", value, "name"); + return (Criteria) this; + } + + public Criteria andNameGreaterThanOrEqualTo(String value) { + addCriterion("`name` >=", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLessThan(String value) { + addCriterion("`name` <", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLessThanOrEqualTo(String value) { + addCriterion("`name` <=", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLike(String value) { + addCriterion("`name` like", value, "name"); + return (Criteria) this; + } + + public Criteria andNameNotLike(String value) { + addCriterion("`name` not like", value, "name"); + return (Criteria) this; + } + + public Criteria andNameIn(List values) { + addCriterion("`name` in", values, "name"); + return (Criteria) this; + } + + public Criteria andNameNotIn(List values) { + addCriterion("`name` not in", values, "name"); + return (Criteria) this; + } + + public Criteria andNameBetween(String value1, String value2) { + addCriterion("`name` between", value1, value2, "name"); + return (Criteria) this; + } + + public Criteria andNameNotBetween(String value1, String value2) { + addCriterion("`name` not between", value1, value2, "name"); + 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 Criteria andValueTypeIsNull() { + addCriterion("value_type is null"); + return (Criteria) this; + } + + public Criteria andValueTypeIsNotNull() { + addCriterion("value_type is not null"); + return (Criteria) this; + } + + public Criteria andValueTypeEqualTo(String value) { + addCriterion("value_type =", value, "valueType"); + return (Criteria) this; + } + + public Criteria andValueTypeNotEqualTo(String value) { + addCriterion("value_type <>", value, "valueType"); + return (Criteria) this; + } + + public Criteria andValueTypeGreaterThan(String value) { + addCriterion("value_type >", value, "valueType"); + return (Criteria) this; + } + + public Criteria andValueTypeGreaterThanOrEqualTo(String value) { + addCriterion("value_type >=", value, "valueType"); + return (Criteria) this; + } + + public Criteria andValueTypeLessThan(String value) { + addCriterion("value_type <", value, "valueType"); + return (Criteria) this; + } + + public Criteria andValueTypeLessThanOrEqualTo(String value) { + addCriterion("value_type <=", value, "valueType"); + return (Criteria) this; + } + + public Criteria andValueTypeLike(String value) { + addCriterion("value_type like", value, "valueType"); + return (Criteria) this; + } + + public Criteria andValueTypeNotLike(String value) { + addCriterion("value_type not like", value, "valueType"); + return (Criteria) this; + } + + public Criteria andValueTypeIn(List values) { + addCriterion("value_type in", values, "valueType"); + return (Criteria) this; + } + + public Criteria andValueTypeNotIn(List values) { + addCriterion("value_type not in", values, "valueType"); + return (Criteria) this; + } + + public Criteria andValueTypeBetween(String value1, String value2) { + addCriterion("value_type between", value1, value2, "valueType"); + return (Criteria) this; + } + + public Criteria andValueTypeNotBetween(String value1, String value2) { + addCriterion("value_type not between", value1, value2, "valueType"); + return (Criteria) this; + } + + public Criteria andCustomFieldIsNull() { + addCriterion("custom_field is null"); + return (Criteria) this; + } + + public Criteria andCustomFieldIsNotNull() { + addCriterion("custom_field is not null"); + return (Criteria) this; + } + + public Criteria andCustomFieldEqualTo(Boolean value) { + addCriterion("custom_field =", value, "customField"); + return (Criteria) this; + } + + public Criteria andCustomFieldNotEqualTo(Boolean value) { + addCriterion("custom_field <>", value, "customField"); + return (Criteria) this; + } + + public Criteria andCustomFieldGreaterThan(Boolean value) { + addCriterion("custom_field >", value, "customField"); + return (Criteria) this; + } + + public Criteria andCustomFieldGreaterThanOrEqualTo(Boolean value) { + addCriterion("custom_field >=", value, "customField"); + return (Criteria) this; + } + + public Criteria andCustomFieldLessThan(Boolean value) { + addCriterion("custom_field <", value, "customField"); + return (Criteria) this; + } + + public Criteria andCustomFieldLessThanOrEqualTo(Boolean value) { + addCriterion("custom_field <=", value, "customField"); + return (Criteria) this; + } + + public Criteria andCustomFieldIn(List values) { + addCriterion("custom_field in", values, "customField"); + return (Criteria) this; + } + + public Criteria andCustomFieldNotIn(List values) { + addCriterion("custom_field not in", values, "customField"); + return (Criteria) this; + } + + public Criteria andCustomFieldBetween(Boolean value1, Boolean value2) { + addCriterion("custom_field between", value1, value2, "customField"); + return (Criteria) this; + } + + public Criteria andCustomFieldNotBetween(Boolean value1, Boolean value2) { + addCriterion("custom_field not between", value1, value2, "customField"); + return (Criteria) this; + } + + public Criteria andOperatorIsNull() { + addCriterion("`operator` is null"); + return (Criteria) this; + } + + public Criteria andOperatorIsNotNull() { + addCriterion("`operator` is not null"); + return (Criteria) this; + } + + public Criteria andOperatorEqualTo(String value) { + addCriterion("`operator` =", value, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorNotEqualTo(String value) { + addCriterion("`operator` <>", value, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorGreaterThan(String value) { + addCriterion("`operator` >", value, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorGreaterThanOrEqualTo(String value) { + addCriterion("`operator` >=", value, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorLessThan(String value) { + addCriterion("`operator` <", value, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorLessThanOrEqualTo(String value) { + addCriterion("`operator` <=", value, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorLike(String value) { + addCriterion("`operator` like", value, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorNotLike(String value) { + addCriterion("`operator` not like", value, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorIn(List values) { + addCriterion("`operator` in", values, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorNotIn(List values) { + addCriterion("`operator` not in", values, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorBetween(String value1, String value2) { + addCriterion("`operator` between", value1, value2, "operator"); + return (Criteria) this; + } + + public Criteria andOperatorNotBetween(String value1, String value2) { + addCriterion("`operator` not between", value1, value2, "operator"); + 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/framework/domain/src/main/java/io/metersphere/system/domain/UserViewExample.java b/backend/framework/domain/src/main/java/io/metersphere/system/domain/UserViewExample.java new file mode 100644 index 0000000000..3d1b64a4d4 --- /dev/null +++ b/backend/framework/domain/src/main/java/io/metersphere/system/domain/UserViewExample.java @@ -0,0 +1,800 @@ +package io.metersphere.system.domain; + +import java.util.ArrayList; +import java.util.List; + +public class UserViewExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + public UserViewExample() { + 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 andIdIsNull() { + addCriterion("id is null"); + return (Criteria) this; + } + + public Criteria andIdIsNotNull() { + addCriterion("id is not null"); + return (Criteria) this; + } + + public Criteria andIdEqualTo(String value) { + addCriterion("id =", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotEqualTo(String value) { + addCriterion("id <>", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThan(String value) { + addCriterion("id >", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThanOrEqualTo(String value) { + addCriterion("id >=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThan(String value) { + addCriterion("id <", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThanOrEqualTo(String value) { + addCriterion("id <=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLike(String value) { + addCriterion("id like", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotLike(String value) { + addCriterion("id not like", value, "id"); + return (Criteria) this; + } + + public Criteria andIdIn(List values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List values) { + addCriterion("id not in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdBetween(String value1, String value2) { + addCriterion("id between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdNotBetween(String value1, String value2) { + addCriterion("id not between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andUserIdIsNull() { + addCriterion("user_id is null"); + return (Criteria) this; + } + + public Criteria andUserIdIsNotNull() { + addCriterion("user_id is not null"); + return (Criteria) this; + } + + public Criteria andUserIdEqualTo(String value) { + addCriterion("user_id =", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotEqualTo(String value) { + addCriterion("user_id <>", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdGreaterThan(String value) { + addCriterion("user_id >", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdGreaterThanOrEqualTo(String value) { + addCriterion("user_id >=", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdLessThan(String value) { + addCriterion("user_id <", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdLessThanOrEqualTo(String value) { + addCriterion("user_id <=", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdLike(String value) { + addCriterion("user_id like", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotLike(String value) { + addCriterion("user_id not like", value, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdIn(List values) { + addCriterion("user_id in", values, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotIn(List values) { + addCriterion("user_id not in", values, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdBetween(String value1, String value2) { + addCriterion("user_id between", value1, value2, "userId"); + return (Criteria) this; + } + + public Criteria andUserIdNotBetween(String value1, String value2) { + addCriterion("user_id not between", value1, value2, "userId"); + return (Criteria) this; + } + + public Criteria andNameIsNull() { + addCriterion("`name` is null"); + return (Criteria) this; + } + + public Criteria andNameIsNotNull() { + addCriterion("`name` is not null"); + return (Criteria) this; + } + + public Criteria andNameEqualTo(String value) { + addCriterion("`name` =", value, "name"); + return (Criteria) this; + } + + public Criteria andNameNotEqualTo(String value) { + addCriterion("`name` <>", value, "name"); + return (Criteria) this; + } + + public Criteria andNameGreaterThan(String value) { + addCriterion("`name` >", value, "name"); + return (Criteria) this; + } + + public Criteria andNameGreaterThanOrEqualTo(String value) { + addCriterion("`name` >=", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLessThan(String value) { + addCriterion("`name` <", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLessThanOrEqualTo(String value) { + addCriterion("`name` <=", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLike(String value) { + addCriterion("`name` like", value, "name"); + return (Criteria) this; + } + + public Criteria andNameNotLike(String value) { + addCriterion("`name` not like", value, "name"); + return (Criteria) this; + } + + public Criteria andNameIn(List values) { + addCriterion("`name` in", values, "name"); + return (Criteria) this; + } + + public Criteria andNameNotIn(List values) { + addCriterion("`name` not in", values, "name"); + return (Criteria) this; + } + + public Criteria andNameBetween(String value1, String value2) { + addCriterion("`name` between", value1, value2, "name"); + return (Criteria) this; + } + + public Criteria andNameNotBetween(String value1, String value2) { + addCriterion("`name` not between", value1, value2, "name"); + return (Criteria) this; + } + + public Criteria andViewTypeIsNull() { + addCriterion("view_type is null"); + return (Criteria) this; + } + + public Criteria andViewTypeIsNotNull() { + addCriterion("view_type is not null"); + return (Criteria) this; + } + + public Criteria andViewTypeEqualTo(String value) { + addCriterion("view_type =", value, "viewType"); + return (Criteria) this; + } + + public Criteria andViewTypeNotEqualTo(String value) { + addCriterion("view_type <>", value, "viewType"); + return (Criteria) this; + } + + public Criteria andViewTypeGreaterThan(String value) { + addCriterion("view_type >", value, "viewType"); + return (Criteria) this; + } + + public Criteria andViewTypeGreaterThanOrEqualTo(String value) { + addCriterion("view_type >=", value, "viewType"); + return (Criteria) this; + } + + public Criteria andViewTypeLessThan(String value) { + addCriterion("view_type <", value, "viewType"); + return (Criteria) this; + } + + public Criteria andViewTypeLessThanOrEqualTo(String value) { + addCriterion("view_type <=", value, "viewType"); + return (Criteria) this; + } + + public Criteria andViewTypeLike(String value) { + addCriterion("view_type like", value, "viewType"); + return (Criteria) this; + } + + public Criteria andViewTypeNotLike(String value) { + addCriterion("view_type not like", value, "viewType"); + return (Criteria) this; + } + + public Criteria andViewTypeIn(List values) { + addCriterion("view_type in", values, "viewType"); + return (Criteria) this; + } + + public Criteria andViewTypeNotIn(List values) { + addCriterion("view_type not in", values, "viewType"); + return (Criteria) this; + } + + public Criteria andViewTypeBetween(String value1, String value2) { + addCriterion("view_type between", value1, value2, "viewType"); + return (Criteria) this; + } + + public Criteria andViewTypeNotBetween(String value1, String value2) { + addCriterion("view_type not between", value1, value2, "viewType"); + return (Criteria) this; + } + + public Criteria andScopeIdIsNull() { + addCriterion("scope_id is null"); + return (Criteria) this; + } + + public Criteria andScopeIdIsNotNull() { + addCriterion("scope_id is not null"); + return (Criteria) this; + } + + public Criteria andScopeIdEqualTo(String value) { + addCriterion("scope_id =", value, "scopeId"); + return (Criteria) this; + } + + public Criteria andScopeIdNotEqualTo(String value) { + addCriterion("scope_id <>", value, "scopeId"); + return (Criteria) this; + } + + public Criteria andScopeIdGreaterThan(String value) { + addCriterion("scope_id >", value, "scopeId"); + return (Criteria) this; + } + + public Criteria andScopeIdGreaterThanOrEqualTo(String value) { + addCriterion("scope_id >=", value, "scopeId"); + return (Criteria) this; + } + + public Criteria andScopeIdLessThan(String value) { + addCriterion("scope_id <", value, "scopeId"); + return (Criteria) this; + } + + public Criteria andScopeIdLessThanOrEqualTo(String value) { + addCriterion("scope_id <=", value, "scopeId"); + return (Criteria) this; + } + + public Criteria andScopeIdLike(String value) { + addCriterion("scope_id like", value, "scopeId"); + return (Criteria) this; + } + + public Criteria andScopeIdNotLike(String value) { + addCriterion("scope_id not like", value, "scopeId"); + return (Criteria) this; + } + + public Criteria andScopeIdIn(List values) { + addCriterion("scope_id in", values, "scopeId"); + return (Criteria) this; + } + + public Criteria andScopeIdNotIn(List values) { + addCriterion("scope_id not in", values, "scopeId"); + return (Criteria) this; + } + + public Criteria andScopeIdBetween(String value1, String value2) { + addCriterion("scope_id between", value1, value2, "scopeId"); + return (Criteria) this; + } + + public Criteria andScopeIdNotBetween(String value1, String value2) { + addCriterion("scope_id not between", value1, value2, "scopeId"); + return (Criteria) this; + } + + public Criteria andPosIsNull() { + addCriterion("pos is null"); + return (Criteria) this; + } + + public Criteria andPosIsNotNull() { + addCriterion("pos is not null"); + return (Criteria) this; + } + + public Criteria andPosEqualTo(Long value) { + addCriterion("pos =", value, "pos"); + return (Criteria) this; + } + + public Criteria andPosNotEqualTo(Long value) { + addCriterion("pos <>", value, "pos"); + return (Criteria) this; + } + + public Criteria andPosGreaterThan(Long value) { + addCriterion("pos >", value, "pos"); + return (Criteria) this; + } + + public Criteria andPosGreaterThanOrEqualTo(Long value) { + addCriterion("pos >=", value, "pos"); + return (Criteria) this; + } + + public Criteria andPosLessThan(Long value) { + addCriterion("pos <", value, "pos"); + return (Criteria) this; + } + + public Criteria andPosLessThanOrEqualTo(Long value) { + addCriterion("pos <=", value, "pos"); + return (Criteria) this; + } + + public Criteria andPosIn(List values) { + addCriterion("pos in", values, "pos"); + return (Criteria) this; + } + + public Criteria andPosNotIn(List values) { + addCriterion("pos not in", values, "pos"); + return (Criteria) this; + } + + public Criteria andPosBetween(Long value1, Long value2) { + addCriterion("pos between", value1, value2, "pos"); + return (Criteria) this; + } + + public Criteria andPosNotBetween(Long value1, Long value2) { + addCriterion("pos not between", value1, value2, "pos"); + return (Criteria) this; + } + + public Criteria andSearchModeIsNull() { + addCriterion("search_mode is null"); + return (Criteria) this; + } + + public Criteria andSearchModeIsNotNull() { + addCriterion("search_mode is not null"); + return (Criteria) this; + } + + public Criteria andSearchModeEqualTo(String value) { + addCriterion("search_mode =", value, "searchMode"); + return (Criteria) this; + } + + public Criteria andSearchModeNotEqualTo(String value) { + addCriterion("search_mode <>", value, "searchMode"); + return (Criteria) this; + } + + public Criteria andSearchModeGreaterThan(String value) { + addCriterion("search_mode >", value, "searchMode"); + return (Criteria) this; + } + + public Criteria andSearchModeGreaterThanOrEqualTo(String value) { + addCriterion("search_mode >=", value, "searchMode"); + return (Criteria) this; + } + + public Criteria andSearchModeLessThan(String value) { + addCriterion("search_mode <", value, "searchMode"); + return (Criteria) this; + } + + public Criteria andSearchModeLessThanOrEqualTo(String value) { + addCriterion("search_mode <=", value, "searchMode"); + return (Criteria) this; + } + + public Criteria andSearchModeLike(String value) { + addCriterion("search_mode like", value, "searchMode"); + return (Criteria) this; + } + + public Criteria andSearchModeNotLike(String value) { + addCriterion("search_mode not like", value, "searchMode"); + return (Criteria) this; + } + + public Criteria andSearchModeIn(List values) { + addCriterion("search_mode in", values, "searchMode"); + return (Criteria) this; + } + + public Criteria andSearchModeNotIn(List values) { + addCriterion("search_mode not in", values, "searchMode"); + return (Criteria) this; + } + + public Criteria andSearchModeBetween(String value1, String value2) { + addCriterion("search_mode between", value1, value2, "searchMode"); + return (Criteria) this; + } + + public Criteria andSearchModeNotBetween(String value1, String value2) { + addCriterion("search_mode not between", value1, value2, "searchMode"); + return (Criteria) this; + } + + public Criteria andCreateTimeIsNull() { + addCriterion("create_time is null"); + return (Criteria) this; + } + + public Criteria andCreateTimeIsNotNull() { + addCriterion("create_time is not null"); + return (Criteria) this; + } + + public Criteria andCreateTimeEqualTo(Long value) { + addCriterion("create_time =", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotEqualTo(Long value) { + addCriterion("create_time <>", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeGreaterThan(Long value) { + addCriterion("create_time >", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeGreaterThanOrEqualTo(Long value) { + addCriterion("create_time >=", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeLessThan(Long value) { + addCriterion("create_time <", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeLessThanOrEqualTo(Long value) { + addCriterion("create_time <=", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeIn(List values) { + addCriterion("create_time in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotIn(List values) { + addCriterion("create_time not in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeBetween(Long value1, Long value2) { + addCriterion("create_time between", value1, value2, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotBetween(Long value1, Long value2) { + addCriterion("create_time not between", value1, value2, "createTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeIsNull() { + addCriterion("update_time is null"); + return (Criteria) this; + } + + public Criteria andUpdateTimeIsNotNull() { + addCriterion("update_time is not null"); + return (Criteria) this; + } + + public Criteria andUpdateTimeEqualTo(Long value) { + addCriterion("update_time =", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeNotEqualTo(Long value) { + addCriterion("update_time <>", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeGreaterThan(Long value) { + addCriterion("update_time >", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeGreaterThanOrEqualTo(Long value) { + addCriterion("update_time >=", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeLessThan(Long value) { + addCriterion("update_time <", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeLessThanOrEqualTo(Long value) { + addCriterion("update_time <=", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeIn(List values) { + addCriterion("update_time in", values, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeNotIn(List values) { + addCriterion("update_time not in", values, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeBetween(Long value1, Long value2) { + addCriterion("update_time between", value1, value2, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeNotBetween(Long value1, Long value2) { + addCriterion("update_time not between", value1, value2, "updateTime"); + 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/framework/domain/src/main/java/io/metersphere/system/mapper/UserViewConditionMapper.java b/backend/framework/domain/src/main/java/io/metersphere/system/mapper/UserViewConditionMapper.java new file mode 100644 index 0000000000..777c56c5b1 --- /dev/null +++ b/backend/framework/domain/src/main/java/io/metersphere/system/mapper/UserViewConditionMapper.java @@ -0,0 +1,34 @@ +package io.metersphere.system.mapper; + +import io.metersphere.system.domain.UserViewCondition; +import io.metersphere.system.domain.UserViewConditionExample; +import java.util.List; +import org.apache.ibatis.annotations.Param; + +public interface UserViewConditionMapper { + long countByExample(UserViewConditionExample example); + + int deleteByExample(UserViewConditionExample example); + + int deleteByPrimaryKey(String id); + + int insert(UserViewCondition record); + + int insertSelective(UserViewCondition record); + + List selectByExample(UserViewConditionExample example); + + UserViewCondition selectByPrimaryKey(String id); + + int updateByExampleSelective(@Param("record") UserViewCondition record, @Param("example") UserViewConditionExample example); + + int updateByExample(@Param("record") UserViewCondition record, @Param("example") UserViewConditionExample example); + + int updateByPrimaryKeySelective(UserViewCondition record); + + int updateByPrimaryKey(UserViewCondition record); + + int batchInsert(@Param("list") List list); + + int batchInsertSelective(@Param("list") List list, @Param("selective") UserViewCondition.Column ... selective); +} \ No newline at end of file diff --git a/backend/framework/domain/src/main/java/io/metersphere/system/mapper/UserViewConditionMapper.xml b/backend/framework/domain/src/main/java/io/metersphere/system/mapper/UserViewConditionMapper.xml new file mode 100644 index 0000000000..4962077b39 --- /dev/null +++ b/backend/framework/domain/src/main/java/io/metersphere/system/mapper/UserViewConditionMapper.xml @@ -0,0 +1,288 @@ + + + + + + + + + + + + + + + + + + + + + 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} + + + + + + + + + + + id, user_view_id, `name`, `value`, value_type, custom_field, `operator` + + + + + delete from user_view_condition + where id = #{id,jdbcType=VARCHAR} + + + delete from user_view_condition + + + + + + insert into user_view_condition (id, user_view_id, `name`, + `value`, value_type, custom_field, + `operator`) + values (#{id,jdbcType=VARCHAR}, #{userViewId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, + #{value,jdbcType=VARCHAR}, #{valueType,jdbcType=VARCHAR}, #{customField,jdbcType=BIT}, + #{operator,jdbcType=VARCHAR}) + + + insert into user_view_condition + + + id, + + + user_view_id, + + + `name`, + + + `value`, + + + value_type, + + + custom_field, + + + `operator`, + + + + + #{id,jdbcType=VARCHAR}, + + + #{userViewId,jdbcType=VARCHAR}, + + + #{name,jdbcType=VARCHAR}, + + + #{value,jdbcType=VARCHAR}, + + + #{valueType,jdbcType=VARCHAR}, + + + #{customField,jdbcType=BIT}, + + + #{operator,jdbcType=VARCHAR}, + + + + + + update user_view_condition + + + id = #{record.id,jdbcType=VARCHAR}, + + + user_view_id = #{record.userViewId,jdbcType=VARCHAR}, + + + `name` = #{record.name,jdbcType=VARCHAR}, + + + `value` = #{record.value,jdbcType=VARCHAR}, + + + value_type = #{record.valueType,jdbcType=VARCHAR}, + + + custom_field = #{record.customField,jdbcType=BIT}, + + + `operator` = #{record.operator,jdbcType=VARCHAR}, + + + + + + + + update user_view_condition + set id = #{record.id,jdbcType=VARCHAR}, + user_view_id = #{record.userViewId,jdbcType=VARCHAR}, + `name` = #{record.name,jdbcType=VARCHAR}, + `value` = #{record.value,jdbcType=VARCHAR}, + value_type = #{record.valueType,jdbcType=VARCHAR}, + custom_field = #{record.customField,jdbcType=BIT}, + `operator` = #{record.operator,jdbcType=VARCHAR} + + + + + + update user_view_condition + + + user_view_id = #{userViewId,jdbcType=VARCHAR}, + + + `name` = #{name,jdbcType=VARCHAR}, + + + `value` = #{value,jdbcType=VARCHAR}, + + + value_type = #{valueType,jdbcType=VARCHAR}, + + + custom_field = #{customField,jdbcType=BIT}, + + + `operator` = #{operator,jdbcType=VARCHAR}, + + + where id = #{id,jdbcType=VARCHAR} + + + update user_view_condition + set user_view_id = #{userViewId,jdbcType=VARCHAR}, + `name` = #{name,jdbcType=VARCHAR}, + `value` = #{value,jdbcType=VARCHAR}, + value_type = #{valueType,jdbcType=VARCHAR}, + custom_field = #{customField,jdbcType=BIT}, + `operator` = #{operator,jdbcType=VARCHAR} + where id = #{id,jdbcType=VARCHAR} + + + insert into user_view_condition + (id, user_view_id, `name`, `value`, value_type, custom_field, `operator`) + values + + (#{item.id,jdbcType=VARCHAR}, #{item.userViewId,jdbcType=VARCHAR}, #{item.name,jdbcType=VARCHAR}, + #{item.value,jdbcType=VARCHAR}, #{item.valueType,jdbcType=VARCHAR}, #{item.customField,jdbcType=BIT}, + #{item.operator,jdbcType=VARCHAR}) + + + + insert into user_view_condition ( + + ${column.escapedColumnName} + + ) + values + + ( + + + #{item.id,jdbcType=VARCHAR} + + + #{item.userViewId,jdbcType=VARCHAR} + + + #{item.name,jdbcType=VARCHAR} + + + #{item.value,jdbcType=VARCHAR} + + + #{item.valueType,jdbcType=VARCHAR} + + + #{item.customField,jdbcType=BIT} + + + #{item.operator,jdbcType=VARCHAR} + + + ) + + + \ No newline at end of file diff --git a/backend/framework/domain/src/main/java/io/metersphere/system/mapper/UserViewMapper.java b/backend/framework/domain/src/main/java/io/metersphere/system/mapper/UserViewMapper.java new file mode 100644 index 0000000000..59dded2f5c --- /dev/null +++ b/backend/framework/domain/src/main/java/io/metersphere/system/mapper/UserViewMapper.java @@ -0,0 +1,34 @@ +package io.metersphere.system.mapper; + +import io.metersphere.system.domain.UserView; +import io.metersphere.system.domain.UserViewExample; +import java.util.List; +import org.apache.ibatis.annotations.Param; + +public interface UserViewMapper { + long countByExample(UserViewExample example); + + int deleteByExample(UserViewExample example); + + int deleteByPrimaryKey(String id); + + int insert(UserView record); + + int insertSelective(UserView record); + + List selectByExample(UserViewExample example); + + UserView selectByPrimaryKey(String id); + + int updateByExampleSelective(@Param("record") UserView record, @Param("example") UserViewExample example); + + int updateByExample(@Param("record") UserView record, @Param("example") UserViewExample example); + + int updateByPrimaryKeySelective(UserView record); + + int updateByPrimaryKey(UserView record); + + int batchInsert(@Param("list") List list); + + int batchInsertSelective(@Param("list") List list, @Param("selective") UserView.Column ... selective); +} \ No newline at end of file diff --git a/backend/framework/domain/src/main/java/io/metersphere/system/mapper/UserViewMapper.xml b/backend/framework/domain/src/main/java/io/metersphere/system/mapper/UserViewMapper.xml new file mode 100644 index 0000000000..7e893b264f --- /dev/null +++ b/backend/framework/domain/src/main/java/io/metersphere/system/mapper/UserViewMapper.xml @@ -0,0 +1,328 @@ + + + + + + + + + + + + + + + + + + + + + + + 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} + + + + + + + + + + + id, user_id, `name`, view_type, scope_id, pos, search_mode, create_time, update_time + + + + + delete from user_view + where id = #{id,jdbcType=VARCHAR} + + + delete from user_view + + + + + + insert into user_view (id, user_id, `name`, + view_type, scope_id, pos, + search_mode, create_time, update_time + ) + values (#{id,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, + #{viewType,jdbcType=VARCHAR}, #{scopeId,jdbcType=VARCHAR}, #{pos,jdbcType=BIGINT}, + #{searchMode,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT} + ) + + + insert into user_view + + + id, + + + user_id, + + + `name`, + + + view_type, + + + scope_id, + + + pos, + + + search_mode, + + + create_time, + + + update_time, + + + + + #{id,jdbcType=VARCHAR}, + + + #{userId,jdbcType=VARCHAR}, + + + #{name,jdbcType=VARCHAR}, + + + #{viewType,jdbcType=VARCHAR}, + + + #{scopeId,jdbcType=VARCHAR}, + + + #{pos,jdbcType=BIGINT}, + + + #{searchMode,jdbcType=VARCHAR}, + + + #{createTime,jdbcType=BIGINT}, + + + #{updateTime,jdbcType=BIGINT}, + + + + + + update user_view + + + id = #{record.id,jdbcType=VARCHAR}, + + + user_id = #{record.userId,jdbcType=VARCHAR}, + + + `name` = #{record.name,jdbcType=VARCHAR}, + + + view_type = #{record.viewType,jdbcType=VARCHAR}, + + + scope_id = #{record.scopeId,jdbcType=VARCHAR}, + + + pos = #{record.pos,jdbcType=BIGINT}, + + + search_mode = #{record.searchMode,jdbcType=VARCHAR}, + + + create_time = #{record.createTime,jdbcType=BIGINT}, + + + update_time = #{record.updateTime,jdbcType=BIGINT}, + + + + + + + + update user_view + set id = #{record.id,jdbcType=VARCHAR}, + user_id = #{record.userId,jdbcType=VARCHAR}, + `name` = #{record.name,jdbcType=VARCHAR}, + view_type = #{record.viewType,jdbcType=VARCHAR}, + scope_id = #{record.scopeId,jdbcType=VARCHAR}, + pos = #{record.pos,jdbcType=BIGINT}, + search_mode = #{record.searchMode,jdbcType=VARCHAR}, + create_time = #{record.createTime,jdbcType=BIGINT}, + update_time = #{record.updateTime,jdbcType=BIGINT} + + + + + + update user_view + + + user_id = #{userId,jdbcType=VARCHAR}, + + + `name` = #{name,jdbcType=VARCHAR}, + + + view_type = #{viewType,jdbcType=VARCHAR}, + + + scope_id = #{scopeId,jdbcType=VARCHAR}, + + + pos = #{pos,jdbcType=BIGINT}, + + + search_mode = #{searchMode,jdbcType=VARCHAR}, + + + create_time = #{createTime,jdbcType=BIGINT}, + + + update_time = #{updateTime,jdbcType=BIGINT}, + + + where id = #{id,jdbcType=VARCHAR} + + + update user_view + set user_id = #{userId,jdbcType=VARCHAR}, + `name` = #{name,jdbcType=VARCHAR}, + view_type = #{viewType,jdbcType=VARCHAR}, + scope_id = #{scopeId,jdbcType=VARCHAR}, + pos = #{pos,jdbcType=BIGINT}, + search_mode = #{searchMode,jdbcType=VARCHAR}, + create_time = #{createTime,jdbcType=BIGINT}, + update_time = #{updateTime,jdbcType=BIGINT} + where id = #{id,jdbcType=VARCHAR} + + + insert into user_view + (id, user_id, `name`, view_type, scope_id, pos, search_mode, create_time, update_time + ) + values + + (#{item.id,jdbcType=VARCHAR}, #{item.userId,jdbcType=VARCHAR}, #{item.name,jdbcType=VARCHAR}, + #{item.viewType,jdbcType=VARCHAR}, #{item.scopeId,jdbcType=VARCHAR}, #{item.pos,jdbcType=BIGINT}, + #{item.searchMode,jdbcType=VARCHAR}, #{item.createTime,jdbcType=BIGINT}, #{item.updateTime,jdbcType=BIGINT} + ) + + + + insert into user_view ( + + ${column.escapedColumnName} + + ) + values + + ( + + + #{item.id,jdbcType=VARCHAR} + + + #{item.userId,jdbcType=VARCHAR} + + + #{item.name,jdbcType=VARCHAR} + + + #{item.viewType,jdbcType=VARCHAR} + + + #{item.scopeId,jdbcType=VARCHAR} + + + #{item.pos,jdbcType=BIGINT} + + + #{item.searchMode,jdbcType=VARCHAR} + + + #{item.createTime,jdbcType=BIGINT} + + + #{item.updateTime,jdbcType=BIGINT} + + + ) + + + \ No newline at end of file diff --git a/backend/framework/domain/src/main/resources/migration/3.3.0/ddl/V3.3.0_2__ga_ddl.sql b/backend/framework/domain/src/main/resources/migration/3.3.0/ddl/V3.3.0_2__ga_ddl.sql index f1e81433bb..06641cc5b5 100644 --- a/backend/framework/domain/src/main/resources/migration/3.3.0/ddl/V3.3.0_2__ga_ddl.sql +++ b/backend/framework/domain/src/main/resources/migration/3.3.0/ddl/V3.3.0_2__ga_ddl.sql @@ -5,5 +5,39 @@ SET SESSION innodb_lock_wait_timeout = 7200; ALTER TABLE test_plan_report_api_case ADD COLUMN api_case_bug_count bigint default 0 not null comment '接口用例关联缺陷数'; ALTER TABLE test_plan_report_api_scenario ADD COLUMN api_scenario_bug_count bigint default 0 not null comment '场景用例关联缺陷数'; +-- 创建用户视图表 +CREATE TABLE IF NOT EXISTS user_view( + `id` VARCHAR(50) NOT NULL COMMENT '视图ID' , + `user_id` VARCHAR(50) NOT NULL COMMENT '用户ID' , + `name` VARCHAR(255) NOT NULL COMMENT '视图名称' , + `view_type` VARCHAR(50) NOT NULL COMMENT '视图类型,例如功能用例视图' , + `scope_id` VARCHAR(50) NOT NULL COMMENT '视图的应用范围,一般为项目ID' , + `pos` BIGINT NOT NULL COMMENT '自定义排序' , + `search_mode` VARCHAR(10) NOT NULL DEFAULT 'AND' COMMENT '匹配模式:AND/OR' , + `create_time` BIGINT NOT NULL COMMENT '创建时间' , + `update_time` BIGINT NOT NULL COMMENT '更新时间' , + PRIMARY KEY (id) + ) ENGINE = InnoDB + DEFAULT CHARSET = utf8mb4 + COLLATE = utf8mb4_general_ci COMMENT = '用户视图'; +-- 创建用户视图索引 +CREATE INDEX idx_user_id_scope_id_type ON user_view(`user_id`,`view_type`,`scope_id`); + +-- 创建用户视图条件项表 +CREATE TABLE IF NOT EXISTS user_view_condition( + `id` VARCHAR(50) NOT NULL COMMENT '条件ID' , + `user_view_id` VARCHAR(50) NOT NULL COMMENT '视图ID' , + `name` VARCHAR(255) NOT NULL COMMENT '参数名称' , + `value` VARCHAR(1000) COMMENT '查询的期望值' , + `value_type` VARCHAR(20) DEFAULT 'STRING' COMMENT '期望值的数据类型:STRING,INT,FLOAT,ARRAY' , + `custom_field` BIT NOT NULL DEFAULT 1 COMMENT '是否为自定义字段' , + `operator` VARCHAR(50) COMMENT '操作符:等于、大于、小于、等' , + PRIMARY KEY (id) +) ENGINE = InnoDB + DEFAULT CHARSET = utf8mb4 + COLLATE = utf8mb4_general_ci COMMENT = '用户视图条件项'; +-- 创建用户视图条件项索引 +CREATE INDEX idx_user_view_id ON user_view_condition(`user_view_id`); + -- set innodb lock wait timeout to default SET SESSION innodb_lock_wait_timeout = DEFAULT; \ No newline at end of file diff --git a/backend/framework/sdk/src/main/resources/i18n/commons.properties b/backend/framework/sdk/src/main/resources/i18n/commons.properties index 759cf6039f..1f673ab77c 100644 --- a/backend/framework/sdk/src/main/resources/i18n/commons.properties +++ b/backend/framework/sdk/src/main/resources/i18n/commons.properties @@ -551,3 +551,9 @@ url_format_error=请检查Swagger URL是否输入正确! swagger_version_error=Swagger 版本不支持,请检查是否为3.0版本! test_plan=测试计划 ID + +#user_view +internal_user_view_permission_error=系统视图无法删除! +user_view.all_data=全部数据 +user_view.my_follow=我关注的 +user_view.my_create=我创建的 \ No newline at end of file diff --git a/backend/framework/sdk/src/main/resources/i18n/commons_en_US.properties b/backend/framework/sdk/src/main/resources/i18n/commons_en_US.properties index 022afc35b7..b4cece61bb 100644 --- a/backend/framework/sdk/src/main/resources/i18n/commons_en_US.properties +++ b/backend/framework/sdk/src/main/resources/i18n/commons_en_US.properties @@ -588,4 +588,10 @@ url_format_error=Please check if the Swagger URL is entered correctly! swagger_version_error=Swagger version not supported, please check if it is version 3.0! -test_plan=Test Plan ID \ No newline at end of file +test_plan=Test Plan ID + +#user_view +internal_user_view_permission_error=System views cannot be deleted! +user_view.all_data=All data +user_view.my_follow=I followed +user_view.my_create=I created \ No newline at end of file diff --git a/backend/framework/sdk/src/main/resources/i18n/commons_zh_CN.properties b/backend/framework/sdk/src/main/resources/i18n/commons_zh_CN.properties index 88f46fb9b3..3d8a85536c 100644 --- a/backend/framework/sdk/src/main/resources/i18n/commons_zh_CN.properties +++ b/backend/framework/sdk/src/main/resources/i18n/commons_zh_CN.properties @@ -583,4 +583,10 @@ global_request_header=全局请求头 url_format_error=请检查Swagger URL是否输入正确! swagger_version_error=Swagger 版本不支持,请检查是否为3.0版本! -test_plan=测试计划 ID \ No newline at end of file +test_plan=测试计划 ID + +#user_view +internal_user_view_permission_error=系统视图无法删除! +user_view.all_data=全部数据 +user_view.my_follow=我关注的 +user_view.my_create=我创建的 \ No newline at end of file diff --git a/backend/framework/sdk/src/main/resources/i18n/commons_zh_TW.properties b/backend/framework/sdk/src/main/resources/i18n/commons_zh_TW.properties index 9dfca47725..685fbb4a4b 100644 --- a/backend/framework/sdk/src/main/resources/i18n/commons_zh_TW.properties +++ b/backend/framework/sdk/src/main/resources/i18n/commons_zh_TW.properties @@ -583,4 +583,10 @@ global_request_header=全局請求頭 url_format_error=请检查Swagger URL是否输入正确! swagger_version_error=Swagger 版本不支持,请检查是否为3.0版本! -test_plan=測試計劃 ID \ No newline at end of file +test_plan=測試計劃 ID + +#user_view +internal_user_view_permission_error=系統視圖無法刪除! +user_view.all_data=全部數據 +user_view.my_follow=我關注的 +user_view.my_create=我創建的 \ No newline at end of file diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/constants/InternalUserView.java b/backend/services/system-setting/src/main/java/io/metersphere/system/constants/InternalUserView.java new file mode 100644 index 0000000000..7d01cd9b81 --- /dev/null +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/constants/InternalUserView.java @@ -0,0 +1,62 @@ +package io.metersphere.system.constants; + +import io.metersphere.system.dto.UserViewDTO; +import io.metersphere.system.dto.sdk.CombineCondition; +import io.metersphere.system.dto.sdk.CombineSearch; + +import java.util.List; +import java.util.function.Supplier; + +/** + * @Author: jianxing + * @CreateTime: 2024-09-02 10:47 + */ +public enum InternalUserView { + ALL_DATA(() -> { + UserViewDTO userViewDTO = getUserViewDTO("all_data"); + userViewDTO.setConditions(List.of()); + return userViewDTO; + }), + MY_FOLLOW(() -> { + UserViewDTO userViewDTO = getUserViewDTO("my_follow"); + CombineCondition condition = new CombineCondition(); + condition.setName("follower"); + condition.setValue(getCurrentUserValue()); + condition.setOperator(CombineCondition.CombineConditionOperator.EQUALS.name()); + userViewDTO.setConditions(List.of(condition)); + return userViewDTO; + }), + MY_CREATE(() -> { + UserViewDTO userViewDTO = getUserViewDTO("my_create"); + CombineCondition condition = new CombineCondition(); + condition.setName("create_user"); + condition.setValue(getCurrentUserValue()); + condition.setOperator(CombineCondition.CombineConditionOperator.EQUALS.name()); + userViewDTO.setConditions(List.of(condition)); + return userViewDTO; + }); + + private static UserViewDTO getUserViewDTO(String name) { + UserViewDTO userViewDTO = new UserViewDTO(); + userViewDTO.setSearchMode(CombineSearch.SearchMode.AND.name()); + userViewDTO.setName(name); + userViewDTO.setId(name); + userViewDTO.setInternalViewKey(name.toUpperCase()); + return userViewDTO; + } + + private UserViewDTO userView; + public static final String CURRENT_USER = "CURRENT_USER"; + + InternalUserView(Supplier initCombineSearchFunc) { + userView = initCombineSearchFunc.get(); + } + + public static String getCurrentUserValue() { + return CURRENT_USER; + } + + public UserViewDTO getUserView() { + return userView; + } +} diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/constants/UserViewConditionValueType.java b/backend/services/system-setting/src/main/java/io/metersphere/system/constants/UserViewConditionValueType.java new file mode 100644 index 0000000000..b16208b0df --- /dev/null +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/constants/UserViewConditionValueType.java @@ -0,0 +1,9 @@ +package io.metersphere.system.constants; + +/** + * @Author: jianxing + * @CreateTime: 2024-09-02 10:47 + */ +public enum UserViewConditionValueType { + ARRAY,STRING,INT,FLOAT +} diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/constants/UserViewType.java b/backend/services/system-setting/src/main/java/io/metersphere/system/constants/UserViewType.java new file mode 100644 index 0000000000..ac0b8744b8 --- /dev/null +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/constants/UserViewType.java @@ -0,0 +1,43 @@ +package io.metersphere.system.constants; + +import io.metersphere.sdk.constants.ValueEnum; +import io.metersphere.sdk.exception.MSException; + +import java.util.List; + +/** + * @Author: jianxing + * @CreateTime: 2024-09-02 10:47 + */ +public enum UserViewType implements ValueEnum { + + FUNCTIONAL_CASE("functional-case", + List.of(InternalUserView.ALL_DATA, InternalUserView.MY_FOLLOW, InternalUserView.MY_CREATE)), + ; + + private String value; + private List internalViews; + + UserViewType(String value, List internalViews) { + this.value = value; + this.internalViews = internalViews; + } + + @Override + public Object getValue() { + return this.value; + } + + public List getInternalViews() { + return internalViews; + } + + public static UserViewType getByValue(String value) { + for (UserViewType userViewType : UserViewType.values()) { + if (userViewType.value.equals(value)) { + return userViewType; + } + } + throw new MSException("No such view type"); + } +} diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/UserViewController.java b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/UserViewController.java new file mode 100644 index 0000000000..6d19558681 --- /dev/null +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/UserViewController.java @@ -0,0 +1,70 @@ +package io.metersphere.system.controller; + +import io.metersphere.system.constants.UserViewType; +import io.metersphere.system.dto.UserViewDTO; +import io.metersphere.system.dto.UserViewListDTO; +import io.metersphere.system.dto.UserViewListGroupedDTO; +import io.metersphere.system.dto.request.UserViewAddRequest; +import io.metersphere.system.dto.request.UserViewUpdateRequest; +import io.metersphere.system.service.UserViewService; +import io.metersphere.system.utils.SessionUtils; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +/** + * @Author: jianxing + * @CreateTime: 2024-08-30 14:43 + */ +@Tag(name = "视图") +@RestController +@RequestMapping("/user-view") +public class UserViewController { + @Resource + private UserViewService userViewService; + + @GetMapping("/{viewType}/list") + @Operation(summary = "视图列表") + public List list(@RequestParam String scopeId, @PathVariable String viewType) { + UserViewType userViewType = UserViewType.getByValue(viewType); + return userViewService.list(scopeId, userViewType, SessionUtils.getUserId()); + } + + @GetMapping("/{viewType}/grouped/list") + @Operation(summary = "视图列表") + public UserViewListGroupedDTO groupedList(@RequestParam String scopeId, @PathVariable String viewType) { + UserViewType userViewType = UserViewType.getByValue(viewType); + return userViewService.groupedList(scopeId, userViewType, SessionUtils.getUserId()); + } + + @GetMapping("/{viewType}/get/{id}") + @Operation(summary = "视图详情") + public UserViewDTO get(@PathVariable String id, @PathVariable String viewType) { + UserViewType userViewType = UserViewType.getByValue(viewType); + return userViewService.get(id, userViewType, SessionUtils.getUserId()); + } + + @PostMapping("/{viewType}/add") + @Operation(summary = "新增视图") + public UserViewDTO add(@Validated @RequestBody UserViewAddRequest request, @PathVariable String viewType) { + UserViewType userViewType = UserViewType.getByValue(viewType); + return userViewService.add(request, userViewType.name(), SessionUtils.getUserId()); + } + + @PostMapping("/{viewType}/update") + @Operation(summary = "编辑视图") + public UserViewDTO update(@Validated @RequestBody UserViewUpdateRequest request, @PathVariable String viewType) { + UserViewType userViewType = UserViewType.getByValue(viewType); + return userViewService.update(request, userViewType.name(), SessionUtils.getUserId()); + } + + @GetMapping("/{viewType}/delete/{id}") + @Operation(summary = "删除视图") + public void delete(@PathVariable String id, @PathVariable String viewType) { + userViewService.delete(id, SessionUtils.getUserId()); + } +} \ No newline at end of file diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/UserViewDTO.java b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/UserViewDTO.java new file mode 100644 index 0000000000..012d1824dd --- /dev/null +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/UserViewDTO.java @@ -0,0 +1,24 @@ +package io.metersphere.system.dto; + +import io.metersphere.system.domain.UserView; +import io.metersphere.system.dto.sdk.CombineCondition; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +import java.util.List; + +/** + * @Author: jianxing + * @CreateTime: 2024-09-02 10:15 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class UserViewDTO extends UserView { + @Schema(description = "内置视图的 key") + private String internalViewKey; + @Schema(description = "筛选条件") + private List conditions; +} diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/UserViewListDTO.java b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/UserViewListDTO.java new file mode 100644 index 0000000000..bfb2600256 --- /dev/null +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/UserViewListDTO.java @@ -0,0 +1,15 @@ +package io.metersphere.system.dto; + +import io.metersphere.system.domain.UserView; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + * @Author: jianxing + * @CreateTime: 2024-09-02 10:15 + */ +@Data +public class UserViewListDTO extends UserView { + @Schema(description = "内置视图的 key") + private String internalViewKey; +} diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/UserViewListGroupedDTO.java b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/UserViewListGroupedDTO.java new file mode 100644 index 0000000000..904c06ea56 --- /dev/null +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/UserViewListGroupedDTO.java @@ -0,0 +1,18 @@ +package io.metersphere.system.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.List; + +/** + * @Author: jianxing + * @CreateTime: 2024-09-02 10:15 + */ +@Data +public class UserViewListGroupedDTO { + @Schema(description = "系统视图") + private List internalViews; + @Schema(description = "自定义视图") + private List customViews; +} diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/request/UserViewAddRequest.java b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/request/UserViewAddRequest.java new file mode 100644 index 0000000000..439513fda1 --- /dev/null +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/request/UserViewAddRequest.java @@ -0,0 +1,24 @@ +package io.metersphere.system.dto.request; + +import io.metersphere.system.dto.sdk.CombineSearch; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +/** + * @Author: jianxing + * @CreateTime: 2024-09-02 10:15 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class UserViewAddRequest extends CombineSearch { + @Schema(description = "视图的应用范围,一般为项目ID") + @NotBlank + private String scopeId; + @Schema(description = "视图名称") + @NotBlank + private String name; +} diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/request/UserViewUpdateRequest.java b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/request/UserViewUpdateRequest.java new file mode 100644 index 0000000000..e8b45b5c50 --- /dev/null +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/request/UserViewUpdateRequest.java @@ -0,0 +1,24 @@ +package io.metersphere.system.dto.request; + +import io.metersphere.system.dto.sdk.CombineSearch; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +/** + * @Author: jianxing + * @CreateTime: 2024-09-02 10:15 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class UserViewUpdateRequest extends CombineSearch { + @Schema(description = "视图ID") + @NotBlank + private String id; + @Schema(description = "视图名称") + @NotBlank + private String name; +} diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/sdk/CombineCondition.java b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/sdk/CombineCondition.java index 07d0453660..6a68b963a6 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/sdk/CombineCondition.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/sdk/CombineCondition.java @@ -13,8 +13,9 @@ import org.apache.commons.lang3.StringUtils; @Data public class CombineCondition { - @Schema(description = "参数key") - private String key; + @Schema(description = "参数名称") + @NotNull + private String name; @Schema(description = "期望值, BETWEEN,IN,NOT_IN 时为数组, 其他为单值") private Object value; @@ -29,7 +30,7 @@ public class CombineCondition { private String operator; public boolean valid() { - return StringUtils.isNotBlank(key) && StringUtils.isNotBlank(operator) && value != null; + return StringUtils.isNotBlank(name) && StringUtils.isNotBlank(operator) && value != null; } public enum CombineConditionOperator { diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/sdk/CombineSearch.java b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/sdk/CombineSearch.java index d015f7e484..4163fcab9e 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/sdk/CombineSearch.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/sdk/CombineSearch.java @@ -22,12 +22,8 @@ public class CombineSearch { @Valid private List conditions; - public List getValidConditions(List conditions) { - return conditions.stream().filter(CombineCondition::valid).toList(); - } - public List getConditions() { - return getValidConditions(conditions); + return conditions; } public String getSearchMode() { diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtUserViewMapper.java b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtUserViewMapper.java new file mode 100644 index 0000000000..2ff6a989e7 --- /dev/null +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtUserViewMapper.java @@ -0,0 +1,7 @@ +package io.metersphere.system.mapper; + +import org.apache.ibatis.annotations.Param; + +public interface ExtUserViewMapper { + Long getLastPos(@Param("scopeId") String scopeId, @Param("userId") String userId, @Param("viewType") String viewType, @Param("baseOrder") Long baseOrder); +} diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtUserViewMapper.xml b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtUserViewMapper.xml new file mode 100644 index 0000000000..9fb97cced5 --- /dev/null +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/mapper/ExtUserViewMapper.xml @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserViewService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserViewService.java new file mode 100644 index 0000000000..b43604b63f --- /dev/null +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserViewService.java @@ -0,0 +1,262 @@ +package io.metersphere.system.service; + +import io.metersphere.sdk.exception.MSException; +import io.metersphere.sdk.util.BeanUtils; +import io.metersphere.sdk.util.EnumValidator; +import io.metersphere.sdk.util.JSON; +import io.metersphere.sdk.util.Translator; +import io.metersphere.system.constants.InternalUserView; +import io.metersphere.system.constants.UserViewConditionValueType; +import io.metersphere.system.constants.UserViewType; +import io.metersphere.system.domain.UserView; +import io.metersphere.system.domain.UserViewCondition; +import io.metersphere.system.domain.UserViewConditionExample; +import io.metersphere.system.domain.UserViewExample; +import io.metersphere.system.dto.UserViewDTO; +import io.metersphere.system.dto.UserViewListDTO; +import io.metersphere.system.dto.UserViewListGroupedDTO; +import io.metersphere.system.dto.request.UserViewAddRequest; +import io.metersphere.system.dto.request.UserViewUpdateRequest; +import io.metersphere.system.dto.sdk.CombineCondition; +import io.metersphere.system.mapper.ExtUserViewMapper; +import io.metersphere.system.mapper.UserViewConditionMapper; +import io.metersphere.system.mapper.UserViewMapper; +import io.metersphere.system.uid.IDGenerator; +import jakarta.annotation.Resource; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Comparator; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @Author: jianxing + * @CreateTime: 2024-08-30 14:30 + */ +@Service +@Transactional(rollbackFor = Exception.class) +public class UserViewService { + @Resource + private UserViewMapper userViewMapper; + @Resource + private UserViewConditionMapper userViewConditionMapper; + @Resource + private ExtUserViewMapper extUserViewMapper; + + public static final Long POS_STEP = 5000L; + + public List list(String scopeId, UserViewType viewType, String userId) { + UserViewListGroupedDTO userViews = groupedList(scopeId, viewType, userId); + userViews.getCustomViews().addAll(userViews.getInternalViews()); + return userViews.getCustomViews(); + } + + public UserViewDTO get(String id, UserViewType viewType, String userId) { + // 先尝试获取系统内置视图 + InternalUserView[] values = InternalUserView.values(); + for (InternalUserView value : values) { + if (StringUtils.equalsIgnoreCase(id, value.name())) { + UserViewDTO userView = value.getUserView(); + UserViewDTO userViewDTO = BeanUtils.copyBean(new UserViewDTO(), userView); + userViewDTO.setName(translateInternalView(userView.getName())); + userViewDTO.setViewType(viewType.name()); + userViewDTO.setUserId(userId); + return userViewDTO; + } + } + + // 查询用户自定义视图 + UserView userView = userViewMapper.selectByPrimaryKey(id); + checkOwner(userId, userView); + UserViewDTO userViewDTO = BeanUtils.copyBean(new UserViewDTO(), userView); + List conditions = getUserViewConditionsByViewId(id).stream().map(condition -> { + CombineCondition combineCondition = BeanUtils.copyBean(new CombineCondition(), condition); + Object value = getConditionValueByType(condition.getValueType(), condition.getValue()); + combineCondition.setValue(value); + return combineCondition; + }).toList(); + userViewDTO.setConditions(conditions); + return userViewDTO; + } + + private List getUserViewConditionsByViewId(String userViewId) { + UserViewConditionExample example = new UserViewConditionExample(); + example.createCriteria() + .andUserViewIdEqualTo(userViewId); + List conditions = userViewConditionMapper.selectByExample(example); + return conditions; + } + + public UserViewDTO add(UserViewAddRequest request, String viewType, String userId) { + Long nextPos = getNextPos(request.getScopeId(), userId, viewType); + UserView userView = BeanUtils.copyBean(new UserView(), request); + userView.setCreateTime(System.currentTimeMillis()); + userView.setUpdateTime(System.currentTimeMillis()); + userView.setViewType(viewType); + userView.setUserId(userId); + userView.setId(IDGenerator.nextStr()); + userView.setPos(nextPos); + userViewMapper.insertSelective(userView); + + addUserViewConditions(request.getConditions(), userView); + + UserViewDTO userViewDTO = BeanUtils.copyBean(new UserViewDTO(), request); + userViewDTO.setId(userView.getId()); + userViewDTO.setCreateTime(userView.getCreateTime()); + userViewDTO.setUpdateTime(userView.getUpdateTime()); + userViewDTO.setUserId(userId); + userViewDTO.setViewType(viewType); + userViewDTO.setScopeId(request.getScopeId()); + userViewDTO.setPos(nextPos); + return userViewDTO; + } + + public Long getNextPos(String scopeId, String userId, String viewType) { + Long pos = extUserViewMapper.getLastPos(scopeId, userId, viewType, null); + return (pos == null ? 0 : pos) + POS_STEP; + } + + public void delete(String id, String userId) { + UserView originUserView = userViewMapper.selectByPrimaryKey(id); + // 校验权限,只能修改自己的视图 + checkOwner(userId, originUserView); + userViewMapper.deleteByPrimaryKey(id); + } + + private void deleteConditionsByViewId(String userViewId) { + UserViewConditionExample example = new UserViewConditionExample(); + example.createCriteria() + .andUserViewIdEqualTo(userViewId); + userViewConditionMapper.deleteByExample(example); + } + + private void addUserViewConditions(List conditions, UserView userView) { + List insertConditions = conditions.stream().map(condition -> { + UserViewCondition userViewCondition = BeanUtils.copyBean(new UserViewCondition(), condition); + userViewCondition.setId(IDGenerator.nextStr()); + userViewCondition.setOperator(condition.getOperator()); + Object value = condition.getValue(); + String conditionValueType = getConditionValueType(value); + userViewCondition.setValueType(conditionValueType); + if (condition.getValue() != null) { + if (value instanceof List) { + userViewCondition.setValue(JSON.toJSONString(value)); + } else { + userViewCondition.setValue(condition.getValue().toString()); + } + } + userViewCondition.setUserViewId(userView.getId()); + return userViewCondition; + }).toList(); + + userViewConditionMapper.batchInsert(insertConditions); + } + + private String getConditionValueType(Object value) { + if (value instanceof List) { + return UserViewConditionValueType.ARRAY.name(); + } else if (value instanceof Integer || value instanceof Long) { + return UserViewConditionValueType.INT.name(); + } else if (value instanceof Float || value instanceof Double) { + return UserViewConditionValueType.FLOAT.name(); + } else { + return UserViewConditionValueType.STRING.name(); + } + } + + private Object getConditionValueByType(String conditionValueTypeStr, String valueStr) { + UserViewConditionValueType conditionValueType = EnumValidator.validateEnum(UserViewConditionValueType.class, conditionValueTypeStr); + if (StringUtils.isBlank(valueStr)) { + return null; + } + switch (conditionValueType) { + case ARRAY: + return JSON.parseObject(valueStr); + case INT: + return Long.valueOf(valueStr); + case FLOAT: + return Double.valueOf(valueStr); + default: + return valueStr; + } + } + + public UserViewDTO update(UserViewUpdateRequest request, String viewType, String userId) { + UserView originUserView = userViewMapper.selectByPrimaryKey(request.getId()); + // 校验权限,只能修改自己的视图 + checkOwner(userId, originUserView); + + UserView userView = BeanUtils.copyBean(new UserView(), request); + userView.setViewType(viewType); + userView.setUpdateTime(System.currentTimeMillis()); + userViewMapper.updateByPrimaryKeySelective(userView); + + // 先删除 + deleteConditionsByViewId(originUserView.getId()); + // 再新增 + addUserViewConditions(request.getConditions(), userView); + + UserViewDTO userViewDTO = BeanUtils.copyBean(new UserViewDTO(), request); + userViewDTO.setId(originUserView.getId()); + userViewDTO.setCreateTime(originUserView.getCreateTime()); + userViewDTO.setUpdateTime(userView.getUpdateTime()); + userViewDTO.setUserId(userId); + userViewDTO.setViewType(viewType); + userViewDTO.setScopeId(originUserView.getScopeId()); + userViewDTO.setPos(originUserView.getPos()); + return userViewDTO; + } + + /** + * 校验权限,只能修改自己的视图 + * + * @param userId + * @param originView + */ + private void checkOwner(String userId, UserView originView) { + if (!StringUtils.equals(userId, originView.getUserId())) { + throw new MSException(Translator.get("check_owner_case")); + } + } + + public UserViewListGroupedDTO groupedList(String scopeId, UserViewType viewType, String userId) { + // 查询系统内置视图 + List internalViews = viewType.getInternalViews().stream().map(userViewEnum -> { + UserViewDTO userView = userViewEnum.getUserView(); + UserViewListDTO userViewListDTO = BeanUtils.copyBean(new UserViewListDTO(), userView); + userViewListDTO.setName(translateInternalView(userView.getName())); + userViewListDTO.setViewType(viewType.name()); + userViewListDTO.setScopeId(scopeId); + userViewListDTO.setUserId(userId); + return userViewListDTO; + }).collect(Collectors.toList()); + + // 查询用户自定义视图 + UserViewExample example = new UserViewExample(); + example.createCriteria() + .andUserIdEqualTo(userId) + .andScopeIdEqualTo(scopeId) + .andViewTypeEqualTo(viewType.name()); + List customUserViews = userViewMapper.selectByExample(example).stream() + .sorted(Comparator.comparing(UserView::getPos)) + .map(userView -> BeanUtils.copyBean(new UserViewListDTO(), userView)) + .collect(Collectors.toList()); + + UserViewListGroupedDTO groupedDTO = new UserViewListGroupedDTO(); + groupedDTO.setInternalViews(internalViews); + groupedDTO.setCustomViews(customUserViews); + return groupedDTO; + } + + /** + * 翻译内置视图 + * + * @param viewName + * @return + */ + public String translateInternalView(String viewName) { + return Translator.get("user_view." + viewName); + } +} diff --git a/backend/services/system-setting/src/main/resources/systemGeneratorConfig.xml b/backend/services/system-setting/src/main/resources/systemGeneratorConfig.xml index 4fe70b3e4a..b4e022fc93 100644 --- a/backend/services/system-setting/src/main/resources/systemGeneratorConfig.xml +++ b/backend/services/system-setting/src/main/resources/systemGeneratorConfig.xml @@ -85,7 +85,9 @@ - + +
+
diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/UserViewControllerTests.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/UserViewControllerTests.java new file mode 100644 index 0000000000..f6a2ad855a --- /dev/null +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/UserViewControllerTests.java @@ -0,0 +1,173 @@ +package io.metersphere.system.controller; + +import io.metersphere.sdk.constants.InternalUser; +import io.metersphere.sdk.util.BeanUtils; +import io.metersphere.system.base.BaseTest; +import io.metersphere.system.constants.InternalUserView; +import io.metersphere.system.constants.UserViewType; +import io.metersphere.system.dto.UserViewDTO; +import io.metersphere.system.dto.UserViewListDTO; +import io.metersphere.system.dto.UserViewListGroupedDTO; +import io.metersphere.system.dto.request.UserViewAddRequest; +import io.metersphere.system.dto.request.UserViewUpdateRequest; +import io.metersphere.system.dto.sdk.CombineCondition; +import io.metersphere.system.dto.sdk.CombineSearch; +import io.metersphere.system.mapper.UserViewMapper; +import io.metersphere.system.service.UserViewService; +import jakarta.annotation.Resource; +import org.junit.jupiter.api.*; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.web.servlet.MvcResult; + +import java.util.List; +import java.util.UUID; + +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@AutoConfigureMockMvc +@TestMethodOrder(MethodOrderer.OrderAnnotation.class) +public class UserViewControllerTests extends BaseTest { + + private final String BASE_URL = "/user-view/functional-case/"; + private final String LIST = "list?scopeId={0}"; + private final String GROUPED_LIST = "grouped/list?scopeId={0}"; + + private static UserViewDTO addUserViewDTO; + + @Resource + private UserViewService userViewService; + @Resource + private UserViewMapper userViewMapper; + + @Override + public String getBasePath() { + return BASE_URL; + } + + @Test + @Order(1) + public void emptyList() throws Exception { + // @@请求成功 + MvcResult mvcResult = this.requestGetWithOkAndReturn(LIST, DEFAULT_PROJECT_ID); + List result = getResultDataArray(mvcResult, UserViewListDTO.class); + Assertions.assertEquals(result.size(), 3); + UserViewListDTO allData = result.get(0); + Assertions.assertEquals(allData.getName(), "全部数据"); + Assertions.assertEquals(allData.getInternalViewKey(), InternalUserView.ALL_DATA.name()); + Assertions.assertEquals(allData.getId(), InternalUserView.ALL_DATA.name().toLowerCase()); + + UserViewListDTO myFollow = result.get(1); + Assertions.assertEquals(myFollow.getName(), "我关注的"); + Assertions.assertEquals(myFollow.getInternalViewKey(), InternalUserView.MY_FOLLOW.name()); + Assertions.assertEquals(myFollow.getId(), InternalUserView.MY_FOLLOW.name().toLowerCase()); + + UserViewListDTO myCreate = result.get(2); + Assertions.assertEquals(myCreate.getName(), "我创建的"); + Assertions.assertEquals(myCreate.getInternalViewKey(), InternalUserView.MY_CREATE.name()); + Assertions.assertEquals(myCreate.getId(), InternalUserView.MY_CREATE.name().toLowerCase()); + + for (UserViewListDTO item : result) { + Assertions.assertEquals(item.getScopeId(), DEFAULT_PROJECT_ID); + Assertions.assertEquals(item.getUserId(), InternalUser.ADMIN.getValue()); + Assertions.assertEquals(item.getSearchMode(), CombineSearch.SearchMode.AND.name()); + } + } + + @Test + @Order(1) + public void emptyGroupedList() throws Exception { + // @@请求成功 + MvcResult mvcResult = this.requestGetWithOkAndReturn(GROUPED_LIST, DEFAULT_PROJECT_ID); + UserViewListGroupedDTO result = getResultData(mvcResult, UserViewListGroupedDTO.class); + Assertions.assertEquals(result.getInternalViews().size(), 3); + } + + @Test + @Order(2) + public void add() throws Exception { + UserViewAddRequest request = new UserViewAddRequest(); + request.setName(UUID.randomUUID().toString()); + request.setScopeId(DEFAULT_PROJECT_ID); + request.setSearchMode(CombineSearch.SearchMode.AND.name()); + CombineCondition condition = new CombineCondition(); + condition.setCustomField(true); + condition.setName(UUID.randomUUID().toString()); + condition.setOperator(CombineCondition.CombineConditionOperator.EQUALS.name()); + condition.setValue(UUID.randomUUID().toString()); + CombineCondition arrayCondition = new CombineCondition(); + arrayCondition.setName(UUID.randomUUID().toString()); + arrayCondition.setOperator(CombineCondition.CombineConditionOperator.IN.name()); + arrayCondition.setValue(List.of(UUID.randomUUID().toString())); + CombineCondition intCondition = new CombineCondition(); + intCondition.setName(UUID.randomUUID().toString()); + intCondition.setOperator(CombineCondition.CombineConditionOperator.GT.name()); + intCondition.setValue(1130L); + CombineCondition flotCondition = new CombineCondition(); + flotCondition.setName(UUID.randomUUID().toString()); + flotCondition.setOperator(CombineCondition.CombineConditionOperator.GT.name()); + flotCondition.setValue(Double.valueOf(1130.1)); + CombineCondition blankCondition = new CombineCondition(); + blankCondition.setName(UUID.randomUUID().toString()); + request.setConditions(List.of(condition, arrayCondition, intCondition, flotCondition, blankCondition)); + + // @@请求成功 + MvcResult mvcResult = this.requestPostWithOkAndReturn(DEFAULT_ADD, request); + addUserViewDTO = getResultData(mvcResult, UserViewDTO.class); + addUserViewDTO.setConditions(request.getConditions()); + UserViewDTO userViewDTO = userViewService.get(addUserViewDTO.getId(), UserViewType.FUNCTIONAL_CASE, InternalUser.ADMIN.getValue()); + Assertions.assertEquals(request, BeanUtils.copyBean(new UserViewAddRequest(), userViewDTO)); + Assertions.assertEquals(request.getConditions(), userViewDTO.getConditions()); + } + + @Test + @Order(3) + public void update() throws Exception { + UserViewUpdateRequest request = BeanUtils.copyBean(new UserViewUpdateRequest(), addUserViewDTO); + request.setName(UUID.randomUUID().toString()); + request.setSearchMode(CombineSearch.SearchMode.OR.name()); + request.getConditions().get(0).setName(UUID.randomUUID().toString()); + + // @@请求成功 + MvcResult mvcResult = this.requestPostWithOkAndReturn(DEFAULT_UPDATE, request); + addUserViewDTO = getResultData(mvcResult, UserViewDTO.class); + addUserViewDTO.setConditions(request.getConditions()); + UserViewDTO userViewDTO = userViewService.get(addUserViewDTO.getId(), UserViewType.FUNCTIONAL_CASE, InternalUser.ADMIN.getValue()); + Assertions.assertEquals(request, BeanUtils.copyBean(new UserViewUpdateRequest(), userViewDTO)); + Assertions.assertEquals(request.getConditions(), userViewDTO.getConditions()); + } + + @Test + @Order(4) + public void get() throws Exception { + MvcResult mvcResult = this.requestGetWithOkAndReturn(DEFAULT_GET, addUserViewDTO.getId()); + UserViewDTO resultData = getResultData(mvcResult, UserViewDTO.class); + resultData.getConditions().get(2).setValue(Long.valueOf(resultData.getConditions().get(2).getValue().toString())); + resultData.getConditions().get(3).setValue(Double.valueOf(resultData.getConditions().get(3).getValue().toString())); + Assertions.assertEquals(resultData, addUserViewDTO); + Assertions.assertEquals(resultData.getConditions(), addUserViewDTO.getConditions()); + + mvcResult = this.requestGetWithOkAndReturn(DEFAULT_GET, InternalUserView.ALL_DATA.name()); + resultData = getResultData(mvcResult, UserViewDTO.class); + Assertions.assertEquals(resultData.getName(), "全部数据"); + Assertions.assertEquals(resultData.getInternalViewKey(), InternalUserView.ALL_DATA.name()); + Assertions.assertEquals(resultData.getId(), InternalUserView.ALL_DATA.name().toLowerCase()); + Assertions.assertEquals(resultData.getConditions().size(), 0); + } + + @Test + @Order(4) + public void groupedList() throws Exception { + MvcResult mvcResult = this.requestGetWithOkAndReturn(GROUPED_LIST, DEFAULT_PROJECT_ID); + UserViewListGroupedDTO result = getResultData(mvcResult, UserViewListGroupedDTO.class); + Assertions.assertEquals(result.getInternalViews().size(), 3); + Assertions.assertEquals(result.getCustomViews().size(), 1); + Assertions.assertEquals(result.getCustomViews().get(0), BeanUtils.copyBean(new UserViewListDTO(), addUserViewDTO)); + } + + @Test + @Order(5) + public void delete() throws Exception { + this.requestGetWithOkAndReturn(DEFAULT_DELETE, addUserViewDTO.getId()); + Assertions.assertNull(userViewMapper.selectByPrimaryKey(addUserViewDTO.getId())); + } +}