feat(系统设置): 视图增删改查接口

--task=1016128 --user=陈建星 高级搜索-视图增删改查-后端 https://www.tapd.cn/55049933/s/1573254
This commit is contained in:
AgAngle 2024-09-03 20:49:09 +08:00 committed by Craftsman
parent f536f1ff6e
commit c843051f65
29 changed files with 3227 additions and 12 deletions

View File

@ -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<Column> 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();
}
}
}

View File

@ -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<Column> 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();
}
}
}

View File

@ -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<Criteria> oredCriteria;
public UserViewConditionExample() {
oredCriteria = new ArrayList<Criteria>();
}
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<Criteria> 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<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> 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<String> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<String> 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<String> values) {
addCriterion("user_view_id in", values, "userViewId");
return (Criteria) this;
}
public Criteria andUserViewIdNotIn(List<String> 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<String> values) {
addCriterion("`name` in", values, "name");
return (Criteria) this;
}
public Criteria andNameNotIn(List<String> 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<String> values) {
addCriterion("`value` in", values, "value");
return (Criteria) this;
}
public Criteria andValueNotIn(List<String> 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<String> values) {
addCriterion("value_type in", values, "valueType");
return (Criteria) this;
}
public Criteria andValueTypeNotIn(List<String> 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<Boolean> values) {
addCriterion("custom_field in", values, "customField");
return (Criteria) this;
}
public Criteria andCustomFieldNotIn(List<Boolean> 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<String> values) {
addCriterion("`operator` in", values, "operator");
return (Criteria) this;
}
public Criteria andOperatorNotIn(List<String> 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);
}
}
}

View File

@ -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<Criteria> oredCriteria;
public UserViewExample() {
oredCriteria = new ArrayList<Criteria>();
}
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<Criteria> 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<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> 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<String> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<String> 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<String> values) {
addCriterion("user_id in", values, "userId");
return (Criteria) this;
}
public Criteria andUserIdNotIn(List<String> 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<String> values) {
addCriterion("`name` in", values, "name");
return (Criteria) this;
}
public Criteria andNameNotIn(List<String> 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<String> values) {
addCriterion("view_type in", values, "viewType");
return (Criteria) this;
}
public Criteria andViewTypeNotIn(List<String> 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<String> values) {
addCriterion("scope_id in", values, "scopeId");
return (Criteria) this;
}
public Criteria andScopeIdNotIn(List<String> 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<Long> values) {
addCriterion("pos in", values, "pos");
return (Criteria) this;
}
public Criteria andPosNotIn(List<Long> 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<String> values) {
addCriterion("search_mode in", values, "searchMode");
return (Criteria) this;
}
public Criteria andSearchModeNotIn(List<String> 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<Long> values) {
addCriterion("create_time in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<Long> 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<Long> values) {
addCriterion("update_time in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotIn(List<Long> 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);
}
}
}

View File

@ -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<UserViewCondition> 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<UserViewCondition> list);
int batchInsertSelective(@Param("list") List<UserViewCondition> list, @Param("selective") UserViewCondition.Column ... selective);
}

View File

@ -0,0 +1,288 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="io.metersphere.system.mapper.UserViewConditionMapper">
<resultMap id="BaseResultMap" type="io.metersphere.system.domain.UserViewCondition">
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="user_view_id" jdbcType="VARCHAR" property="userViewId" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="value" jdbcType="VARCHAR" property="value" />
<result column="value_type" jdbcType="VARCHAR" property="valueType" />
<result column="custom_field" jdbcType="BIT" property="customField" />
<result column="operator" jdbcType="VARCHAR" property="operator" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, user_view_id, `name`, `value`, value_type, custom_field, `operator`
</sql>
<select id="selectByExample" parameterType="io.metersphere.system.domain.UserViewConditionExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from user_view_condition
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from user_view_condition
where id = #{id,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from user_view_condition
where id = #{id,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="io.metersphere.system.domain.UserViewConditionExample">
delete from user_view_condition
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="io.metersphere.system.domain.UserViewCondition">
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>
<insert id="insertSelective" parameterType="io.metersphere.system.domain.UserViewCondition">
insert into user_view_condition
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="userViewId != null">
user_view_id,
</if>
<if test="name != null">
`name`,
</if>
<if test="value != null">
`value`,
</if>
<if test="valueType != null">
value_type,
</if>
<if test="customField != null">
custom_field,
</if>
<if test="operator != null">
`operator`,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="userViewId != null">
#{userViewId,jdbcType=VARCHAR},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="value != null">
#{value,jdbcType=VARCHAR},
</if>
<if test="valueType != null">
#{valueType,jdbcType=VARCHAR},
</if>
<if test="customField != null">
#{customField,jdbcType=BIT},
</if>
<if test="operator != null">
#{operator,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.system.domain.UserViewConditionExample" resultType="java.lang.Long">
select count(*) from user_view_condition
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update user_view_condition
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=VARCHAR},
</if>
<if test="record.userViewId != null">
user_view_id = #{record.userViewId,jdbcType=VARCHAR},
</if>
<if test="record.name != null">
`name` = #{record.name,jdbcType=VARCHAR},
</if>
<if test="record.value != null">
`value` = #{record.value,jdbcType=VARCHAR},
</if>
<if test="record.valueType != null">
value_type = #{record.valueType,jdbcType=VARCHAR},
</if>
<if test="record.customField != null">
custom_field = #{record.customField,jdbcType=BIT},
</if>
<if test="record.operator != null">
`operator` = #{record.operator,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
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}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.system.domain.UserViewCondition">
update user_view_condition
<set>
<if test="userViewId != null">
user_view_id = #{userViewId,jdbcType=VARCHAR},
</if>
<if test="name != null">
`name` = #{name,jdbcType=VARCHAR},
</if>
<if test="value != null">
`value` = #{value,jdbcType=VARCHAR},
</if>
<if test="valueType != null">
value_type = #{valueType,jdbcType=VARCHAR},
</if>
<if test="customField != null">
custom_field = #{customField,jdbcType=BIT},
</if>
<if test="operator != null">
`operator` = #{operator,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="io.metersphere.system.domain.UserViewCondition">
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}
</update>
<insert id="batchInsert" parameterType="map">
insert into user_view_condition
(id, user_view_id, `name`, `value`, value_type, custom_field, `operator`)
values
<foreach collection="list" item="item" separator=",">
(#{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})
</foreach>
</insert>
<insert id="batchInsertSelective" parameterType="map">
insert into user_view_condition (
<foreach collection="selective" item="column" separator=",">
${column.escapedColumnName}
</foreach>
)
values
<foreach collection="list" item="item" separator=",">
(
<foreach collection="selective" item="column" separator=",">
<if test="'id'.toString() == column.value">
#{item.id,jdbcType=VARCHAR}
</if>
<if test="'user_view_id'.toString() == column.value">
#{item.userViewId,jdbcType=VARCHAR}
</if>
<if test="'name'.toString() == column.value">
#{item.name,jdbcType=VARCHAR}
</if>
<if test="'value'.toString() == column.value">
#{item.value,jdbcType=VARCHAR}
</if>
<if test="'value_type'.toString() == column.value">
#{item.valueType,jdbcType=VARCHAR}
</if>
<if test="'custom_field'.toString() == column.value">
#{item.customField,jdbcType=BIT}
</if>
<if test="'operator'.toString() == column.value">
#{item.operator,jdbcType=VARCHAR}
</if>
</foreach>
)
</foreach>
</insert>
</mapper>

View File

@ -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<UserView> 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<UserView> list);
int batchInsertSelective(@Param("list") List<UserView> list, @Param("selective") UserView.Column ... selective);
}

View File

@ -0,0 +1,328 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="io.metersphere.system.mapper.UserViewMapper">
<resultMap id="BaseResultMap" type="io.metersphere.system.domain.UserView">
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="user_id" jdbcType="VARCHAR" property="userId" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="view_type" jdbcType="VARCHAR" property="viewType" />
<result column="scope_id" jdbcType="VARCHAR" property="scopeId" />
<result column="pos" jdbcType="BIGINT" property="pos" />
<result column="search_mode" jdbcType="VARCHAR" property="searchMode" />
<result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, user_id, `name`, view_type, scope_id, pos, search_mode, create_time, update_time
</sql>
<select id="selectByExample" parameterType="io.metersphere.system.domain.UserViewExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from user_view
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from user_view
where id = #{id,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from user_view
where id = #{id,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="io.metersphere.system.domain.UserViewExample">
delete from user_view
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="io.metersphere.system.domain.UserView">
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>
<insert id="insertSelective" parameterType="io.metersphere.system.domain.UserView">
insert into user_view
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="userId != null">
user_id,
</if>
<if test="name != null">
`name`,
</if>
<if test="viewType != null">
view_type,
</if>
<if test="scopeId != null">
scope_id,
</if>
<if test="pos != null">
pos,
</if>
<if test="searchMode != null">
search_mode,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="userId != null">
#{userId,jdbcType=VARCHAR},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="viewType != null">
#{viewType,jdbcType=VARCHAR},
</if>
<if test="scopeId != null">
#{scopeId,jdbcType=VARCHAR},
</if>
<if test="pos != null">
#{pos,jdbcType=BIGINT},
</if>
<if test="searchMode != null">
#{searchMode,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=BIGINT},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=BIGINT},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.system.domain.UserViewExample" resultType="java.lang.Long">
select count(*) from user_view
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update user_view
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=VARCHAR},
</if>
<if test="record.userId != null">
user_id = #{record.userId,jdbcType=VARCHAR},
</if>
<if test="record.name != null">
`name` = #{record.name,jdbcType=VARCHAR},
</if>
<if test="record.viewType != null">
view_type = #{record.viewType,jdbcType=VARCHAR},
</if>
<if test="record.scopeId != null">
scope_id = #{record.scopeId,jdbcType=VARCHAR},
</if>
<if test="record.pos != null">
pos = #{record.pos,jdbcType=BIGINT},
</if>
<if test="record.searchMode != null">
search_mode = #{record.searchMode,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=BIGINT},
</if>
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=BIGINT},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
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}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.system.domain.UserView">
update user_view
<set>
<if test="userId != null">
user_id = #{userId,jdbcType=VARCHAR},
</if>
<if test="name != null">
`name` = #{name,jdbcType=VARCHAR},
</if>
<if test="viewType != null">
view_type = #{viewType,jdbcType=VARCHAR},
</if>
<if test="scopeId != null">
scope_id = #{scopeId,jdbcType=VARCHAR},
</if>
<if test="pos != null">
pos = #{pos,jdbcType=BIGINT},
</if>
<if test="searchMode != null">
search_mode = #{searchMode,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=BIGINT},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=BIGINT},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="io.metersphere.system.domain.UserView">
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}
</update>
<insert id="batchInsert" parameterType="map">
insert into user_view
(id, user_id, `name`, view_type, scope_id, pos, search_mode, create_time, update_time
)
values
<foreach collection="list" item="item" separator=",">
(#{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}
)
</foreach>
</insert>
<insert id="batchInsertSelective" parameterType="map">
insert into user_view (
<foreach collection="selective" item="column" separator=",">
${column.escapedColumnName}
</foreach>
)
values
<foreach collection="list" item="item" separator=",">
(
<foreach collection="selective" item="column" separator=",">
<if test="'id'.toString() == column.value">
#{item.id,jdbcType=VARCHAR}
</if>
<if test="'user_id'.toString() == column.value">
#{item.userId,jdbcType=VARCHAR}
</if>
<if test="'name'.toString() == column.value">
#{item.name,jdbcType=VARCHAR}
</if>
<if test="'view_type'.toString() == column.value">
#{item.viewType,jdbcType=VARCHAR}
</if>
<if test="'scope_id'.toString() == column.value">
#{item.scopeId,jdbcType=VARCHAR}
</if>
<if test="'pos'.toString() == column.value">
#{item.pos,jdbcType=BIGINT}
</if>
<if test="'search_mode'.toString() == column.value">
#{item.searchMode,jdbcType=VARCHAR}
</if>
<if test="'create_time'.toString() == column.value">
#{item.createTime,jdbcType=BIGINT}
</if>
<if test="'update_time'.toString() == column.value">
#{item.updateTime,jdbcType=BIGINT}
</if>
</foreach>
)
</foreach>
</insert>
</mapper>

View File

@ -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_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 '场景用例关联缺陷数'; 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 innodb lock wait timeout to default
SET SESSION innodb_lock_wait_timeout = DEFAULT; SET SESSION innodb_lock_wait_timeout = DEFAULT;

View File

@ -551,3 +551,9 @@ url_format_error=请检查Swagger URL是否输入正确
swagger_version_error=Swagger 版本不支持请检查是否为3.0版本! swagger_version_error=Swagger 版本不支持请检查是否为3.0版本!
test_plan=测试计划 ID test_plan=测试计划 ID
#user_view
internal_user_view_permission_error=系统视图无法删除!
user_view.all_data=全部数据
user_view.my_follow=我关注的
user_view.my_create=我创建的

View File

@ -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! swagger_version_error=Swagger version not supported, please check if it is version 3.0!
test_plan=Test Plan ID 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

View File

@ -583,4 +583,10 @@ global_request_header=全局请求头
url_format_error=请检查Swagger URL是否输入正确 url_format_error=请检查Swagger URL是否输入正确
swagger_version_error=Swagger 版本不支持请检查是否为3.0版本! swagger_version_error=Swagger 版本不支持请检查是否为3.0版本!
test_plan=测试计划 ID test_plan=测试计划 ID
#user_view
internal_user_view_permission_error=系统视图无法删除!
user_view.all_data=全部数据
user_view.my_follow=我关注的
user_view.my_create=我创建的

View File

@ -583,4 +583,10 @@ global_request_header=全局請求頭
url_format_error=请检查Swagger URL是否输入正确 url_format_error=请检查Swagger URL是否输入正确
swagger_version_error=Swagger 版本不支持请检查是否为3.0版本! swagger_version_error=Swagger 版本不支持请检查是否为3.0版本!
test_plan=測試計劃 ID test_plan=測試計劃 ID
#user_view
internal_user_view_permission_error=系統視圖無法刪除!
user_view.all_data=全部數據
user_view.my_follow=我關注的
user_view.my_create=我創建的

View File

@ -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<UserViewDTO> initCombineSearchFunc) {
userView = initCombineSearchFunc.get();
}
public static String getCurrentUserValue() {
return CURRENT_USER;
}
public UserViewDTO getUserView() {
return userView;
}
}

View File

@ -0,0 +1,9 @@
package io.metersphere.system.constants;
/**
* @Author: jianxing
* @CreateTime: 2024-09-02 10:47
*/
public enum UserViewConditionValueType {
ARRAY,STRING,INT,FLOAT
}

View File

@ -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<InternalUserView> internalViews;
UserViewType(String value, List<InternalUserView> internalViews) {
this.value = value;
this.internalViews = internalViews;
}
@Override
public Object getValue() {
return this.value;
}
public List<InternalUserView> 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");
}
}

View File

@ -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<UserViewListDTO> 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());
}
}

View File

@ -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<CombineCondition> conditions;
}

View File

@ -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;
}

View File

@ -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<UserViewListDTO> internalViews;
@Schema(description = "自定义视图")
private List<UserViewListDTO> customViews;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -13,8 +13,9 @@ import org.apache.commons.lang3.StringUtils;
@Data @Data
public class CombineCondition { public class CombineCondition {
@Schema(description = "参数key") @Schema(description = "参数名称")
private String key; @NotNull
private String name;
@Schema(description = "期望值, BETWEEN,IN,NOT_IN 时为数组, 其他为单值") @Schema(description = "期望值, BETWEEN,IN,NOT_IN 时为数组, 其他为单值")
private Object value; private Object value;
@ -29,7 +30,7 @@ public class CombineCondition {
private String operator; private String operator;
public boolean valid() { public boolean valid() {
return StringUtils.isNotBlank(key) && StringUtils.isNotBlank(operator) && value != null; return StringUtils.isNotBlank(name) && StringUtils.isNotBlank(operator) && value != null;
} }
public enum CombineConditionOperator { public enum CombineConditionOperator {

View File

@ -22,12 +22,8 @@ public class CombineSearch {
@Valid @Valid
private List<CombineCondition> conditions; private List<CombineCondition> conditions;
public List<CombineCondition> getValidConditions(List<CombineCondition> conditions) {
return conditions.stream().filter(CombineCondition::valid).toList();
}
public List<CombineCondition> getConditions() { public List<CombineCondition> getConditions() {
return getValidConditions(conditions); return conditions;
} }
public String getSearchMode() { public String getSearchMode() {

View File

@ -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);
}

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="io.metersphere.system.mapper.ExtUserViewMapper">
<select id="getLastPos" resultType="java.lang.Long">
select `pos` from user_view where scope_id = #{scopeId} and user_id = #{userId} and view_type = #{viewType}
<if test="baseOrder != null">
and `pos` &gt; #{baseOrder}
</if>
order by `pos` desc limit 1;
</select>
</mapper>

View File

@ -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<UserViewListDTO> 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<CombineCondition> 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<UserViewCondition> getUserViewConditionsByViewId(String userViewId) {
UserViewConditionExample example = new UserViewConditionExample();
example.createCriteria()
.andUserViewIdEqualTo(userViewId);
List<UserViewCondition> 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<CombineCondition> conditions, UserView userView) {
List<UserViewCondition> 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<UserViewListDTO> 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<UserViewListDTO> 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);
}
}

View File

@ -85,7 +85,9 @@
<!-- <table tableName="service_integration"/>--> <!-- <table tableName="service_integration"/>-->
<!-- <table tableName="system_parameter"/>--> <!-- <table tableName="system_parameter"/>-->
<!-- <table tableName="test_resource"/>--> <!-- <table tableName="test_resource"/>-->
<table tableName="test_resource_pool"/> <!-- <table tableName="test_resource_pool"/>-->
<table tableName="user_view"/>
<table tableName="user_view_condition"/>
<!-- <table tableName="user"/>--> <!-- <table tableName="user"/>-->
<!-- <table tableName="user_extend"/>--> <!-- <table tableName="user_extend"/>-->
<!-- <table tableName="user_key"/>--> <!-- <table tableName="user_key"/>-->

View File

@ -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<UserViewListDTO> 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()));
}
}