diff --git a/backend/src/main/java/io/metersphere/base/domain/CustomFunction.java b/backend/src/main/java/io/metersphere/base/domain/CustomFunction.java new file mode 100644 index 0000000000..ed76eba447 --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/domain/CustomFunction.java @@ -0,0 +1,27 @@ +package io.metersphere.base.domain; + +import java.io.Serializable; +import lombok.Data; + +@Data +public class CustomFunction implements Serializable { + private String id; + + private String name; + + private String tags; + + private String description; + + private String type; + + private String createUser; + + private Long createTime; + + private Long updateTime; + + private String projectId; + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/CustomFunctionExample.java b/backend/src/main/java/io/metersphere/base/domain/CustomFunctionExample.java new file mode 100644 index 0000000000..69ae6fcd34 --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/domain/CustomFunctionExample.java @@ -0,0 +1,810 @@ +package io.metersphere.base.domain; + +import java.util.ArrayList; +import java.util.List; + +public class CustomFunctionExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + public CustomFunctionExample() { + oredCriteria = new ArrayList(); + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public boolean isDistinct() { + return distinct; + } + + public List getOredCriteria() { + return oredCriteria; + } + + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andIdIsNull() { + addCriterion("id is null"); + return (Criteria) this; + } + + public Criteria andIdIsNotNull() { + addCriterion("id is not null"); + return (Criteria) this; + } + + public Criteria andIdEqualTo(String value) { + addCriterion("id =", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotEqualTo(String value) { + addCriterion("id <>", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThan(String value) { + addCriterion("id >", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThanOrEqualTo(String value) { + addCriterion("id >=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThan(String value) { + addCriterion("id <", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThanOrEqualTo(String value) { + addCriterion("id <=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLike(String value) { + addCriterion("id like", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotLike(String value) { + addCriterion("id not like", value, "id"); + return (Criteria) this; + } + + public Criteria andIdIn(List values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List values) { + addCriterion("id not in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdBetween(String value1, String value2) { + addCriterion("id between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdNotBetween(String value1, String value2) { + addCriterion("id not between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andNameIsNull() { + addCriterion("`name` is null"); + return (Criteria) this; + } + + public Criteria andNameIsNotNull() { + addCriterion("`name` is not null"); + return (Criteria) this; + } + + public Criteria andNameEqualTo(String value) { + addCriterion("`name` =", value, "name"); + return (Criteria) this; + } + + public Criteria andNameNotEqualTo(String value) { + addCriterion("`name` <>", value, "name"); + return (Criteria) this; + } + + public Criteria andNameGreaterThan(String value) { + addCriterion("`name` >", value, "name"); + return (Criteria) this; + } + + public Criteria andNameGreaterThanOrEqualTo(String value) { + addCriterion("`name` >=", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLessThan(String value) { + addCriterion("`name` <", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLessThanOrEqualTo(String value) { + addCriterion("`name` <=", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLike(String value) { + addCriterion("`name` like", value, "name"); + return (Criteria) this; + } + + public Criteria andNameNotLike(String value) { + addCriterion("`name` not like", value, "name"); + return (Criteria) this; + } + + public Criteria andNameIn(List values) { + addCriterion("`name` in", values, "name"); + return (Criteria) this; + } + + public Criteria andNameNotIn(List values) { + addCriterion("`name` not in", values, "name"); + return (Criteria) this; + } + + public Criteria andNameBetween(String value1, String value2) { + addCriterion("`name` between", value1, value2, "name"); + return (Criteria) this; + } + + public Criteria andNameNotBetween(String value1, String value2) { + addCriterion("`name` not between", value1, value2, "name"); + return (Criteria) this; + } + + public Criteria andTagsIsNull() { + addCriterion("tags is null"); + return (Criteria) this; + } + + public Criteria andTagsIsNotNull() { + addCriterion("tags is not null"); + return (Criteria) this; + } + + public Criteria andTagsEqualTo(String value) { + addCriterion("tags =", value, "tags"); + return (Criteria) this; + } + + public Criteria andTagsNotEqualTo(String value) { + addCriterion("tags <>", value, "tags"); + return (Criteria) this; + } + + public Criteria andTagsGreaterThan(String value) { + addCriterion("tags >", value, "tags"); + return (Criteria) this; + } + + public Criteria andTagsGreaterThanOrEqualTo(String value) { + addCriterion("tags >=", value, "tags"); + return (Criteria) this; + } + + public Criteria andTagsLessThan(String value) { + addCriterion("tags <", value, "tags"); + return (Criteria) this; + } + + public Criteria andTagsLessThanOrEqualTo(String value) { + addCriterion("tags <=", value, "tags"); + return (Criteria) this; + } + + public Criteria andTagsLike(String value) { + addCriterion("tags like", value, "tags"); + return (Criteria) this; + } + + public Criteria andTagsNotLike(String value) { + addCriterion("tags not like", value, "tags"); + return (Criteria) this; + } + + public Criteria andTagsIn(List values) { + addCriterion("tags in", values, "tags"); + return (Criteria) this; + } + + public Criteria andTagsNotIn(List values) { + addCriterion("tags not in", values, "tags"); + return (Criteria) this; + } + + public Criteria andTagsBetween(String value1, String value2) { + addCriterion("tags between", value1, value2, "tags"); + return (Criteria) this; + } + + public Criteria andTagsNotBetween(String value1, String value2) { + addCriterion("tags not between", value1, value2, "tags"); + return (Criteria) this; + } + + public Criteria andDescriptionIsNull() { + addCriterion("description is null"); + return (Criteria) this; + } + + public Criteria andDescriptionIsNotNull() { + addCriterion("description is not null"); + return (Criteria) this; + } + + public Criteria andDescriptionEqualTo(String value) { + addCriterion("description =", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionNotEqualTo(String value) { + addCriterion("description <>", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionGreaterThan(String value) { + addCriterion("description >", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionGreaterThanOrEqualTo(String value) { + addCriterion("description >=", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionLessThan(String value) { + addCriterion("description <", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionLessThanOrEqualTo(String value) { + addCriterion("description <=", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionLike(String value) { + addCriterion("description like", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionNotLike(String value) { + addCriterion("description not like", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionIn(List values) { + addCriterion("description in", values, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionNotIn(List values) { + addCriterion("description not in", values, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionBetween(String value1, String value2) { + addCriterion("description between", value1, value2, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionNotBetween(String value1, String value2) { + addCriterion("description not between", value1, value2, "description"); + return (Criteria) this; + } + + public Criteria andTypeIsNull() { + addCriterion("`type` is null"); + return (Criteria) this; + } + + public Criteria andTypeIsNotNull() { + addCriterion("`type` is not null"); + return (Criteria) this; + } + + public Criteria andTypeEqualTo(String value) { + addCriterion("`type` =", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeNotEqualTo(String value) { + addCriterion("`type` <>", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeGreaterThan(String value) { + addCriterion("`type` >", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeGreaterThanOrEqualTo(String value) { + addCriterion("`type` >=", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeLessThan(String value) { + addCriterion("`type` <", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeLessThanOrEqualTo(String value) { + addCriterion("`type` <=", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeLike(String value) { + addCriterion("`type` like", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeNotLike(String value) { + addCriterion("`type` not like", value, "type"); + return (Criteria) this; + } + + public Criteria andTypeIn(List values) { + addCriterion("`type` in", values, "type"); + return (Criteria) this; + } + + public Criteria andTypeNotIn(List values) { + addCriterion("`type` not in", values, "type"); + return (Criteria) this; + } + + public Criteria andTypeBetween(String value1, String value2) { + addCriterion("`type` between", value1, value2, "type"); + return (Criteria) this; + } + + public Criteria andTypeNotBetween(String value1, String value2) { + addCriterion("`type` not between", value1, value2, "type"); + return (Criteria) this; + } + + public Criteria andCreateUserIsNull() { + addCriterion("create_user is null"); + return (Criteria) this; + } + + public Criteria andCreateUserIsNotNull() { + addCriterion("create_user is not null"); + return (Criteria) this; + } + + public Criteria andCreateUserEqualTo(String value) { + addCriterion("create_user =", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotEqualTo(String value) { + addCriterion("create_user <>", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserGreaterThan(String value) { + addCriterion("create_user >", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserGreaterThanOrEqualTo(String value) { + addCriterion("create_user >=", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserLessThan(String value) { + addCriterion("create_user <", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserLessThanOrEqualTo(String value) { + addCriterion("create_user <=", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserLike(String value) { + addCriterion("create_user like", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotLike(String value) { + addCriterion("create_user not like", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserIn(List values) { + addCriterion("create_user in", values, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotIn(List values) { + addCriterion("create_user not in", values, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserBetween(String value1, String value2) { + addCriterion("create_user between", value1, value2, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotBetween(String value1, String value2) { + addCriterion("create_user not between", value1, value2, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateTimeIsNull() { + addCriterion("create_time is null"); + return (Criteria) this; + } + + public Criteria andCreateTimeIsNotNull() { + addCriterion("create_time is not null"); + return (Criteria) this; + } + + public Criteria andCreateTimeEqualTo(Long value) { + addCriterion("create_time =", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotEqualTo(Long value) { + addCriterion("create_time <>", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeGreaterThan(Long value) { + addCriterion("create_time >", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeGreaterThanOrEqualTo(Long value) { + addCriterion("create_time >=", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeLessThan(Long value) { + addCriterion("create_time <", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeLessThanOrEqualTo(Long value) { + addCriterion("create_time <=", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeIn(List values) { + addCriterion("create_time in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotIn(List values) { + addCriterion("create_time not in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeBetween(Long value1, Long value2) { + addCriterion("create_time between", value1, value2, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotBetween(Long value1, Long value2) { + addCriterion("create_time not between", value1, value2, "createTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeIsNull() { + addCriterion("update_time is null"); + return (Criteria) this; + } + + public Criteria andUpdateTimeIsNotNull() { + addCriterion("update_time is not null"); + return (Criteria) this; + } + + public Criteria andUpdateTimeEqualTo(Long value) { + addCriterion("update_time =", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeNotEqualTo(Long value) { + addCriterion("update_time <>", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeGreaterThan(Long value) { + addCriterion("update_time >", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeGreaterThanOrEqualTo(Long value) { + addCriterion("update_time >=", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeLessThan(Long value) { + addCriterion("update_time <", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeLessThanOrEqualTo(Long value) { + addCriterion("update_time <=", value, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeIn(List values) { + addCriterion("update_time in", values, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeNotIn(List values) { + addCriterion("update_time not in", values, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeBetween(Long value1, Long value2) { + addCriterion("update_time between", value1, value2, "updateTime"); + return (Criteria) this; + } + + public Criteria andUpdateTimeNotBetween(Long value1, Long value2) { + addCriterion("update_time not between", value1, value2, "updateTime"); + return (Criteria) this; + } + + public Criteria andProjectIdIsNull() { + addCriterion("project_id is null"); + return (Criteria) this; + } + + public Criteria andProjectIdIsNotNull() { + addCriterion("project_id is not null"); + return (Criteria) this; + } + + public Criteria andProjectIdEqualTo(String value) { + addCriterion("project_id =", value, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdNotEqualTo(String value) { + addCriterion("project_id <>", value, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdGreaterThan(String value) { + addCriterion("project_id >", value, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdGreaterThanOrEqualTo(String value) { + addCriterion("project_id >=", value, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdLessThan(String value) { + addCriterion("project_id <", value, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdLessThanOrEqualTo(String value) { + addCriterion("project_id <=", value, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdLike(String value) { + addCriterion("project_id like", value, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdNotLike(String value) { + addCriterion("project_id not like", value, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdIn(List values) { + addCriterion("project_id in", values, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdNotIn(List values) { + addCriterion("project_id not in", values, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdBetween(String value1, String value2) { + addCriterion("project_id between", value1, value2, "projectId"); + return (Criteria) this; + } + + public Criteria andProjectIdNotBetween(String value1, String value2) { + addCriterion("project_id not between", value1, value2, "projectId"); + return (Criteria) this; + } + } + + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/CustomFunctionWithBLOBs.java b/backend/src/main/java/io/metersphere/base/domain/CustomFunctionWithBLOBs.java new file mode 100644 index 0000000000..a9ff833bf5 --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/domain/CustomFunctionWithBLOBs.java @@ -0,0 +1,19 @@ +package io.metersphere.base.domain; + +import java.io.Serializable; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class CustomFunctionWithBLOBs extends CustomFunction implements Serializable { + private String params; + + private String script; + + private String result; + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/CustomFunctionMapper.java b/backend/src/main/java/io/metersphere/base/mapper/CustomFunctionMapper.java new file mode 100644 index 0000000000..2ddeb7bf47 --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/mapper/CustomFunctionMapper.java @@ -0,0 +1,37 @@ +package io.metersphere.base.mapper; + +import io.metersphere.base.domain.CustomFunction; +import io.metersphere.base.domain.CustomFunctionExample; +import io.metersphere.base.domain.CustomFunctionWithBLOBs; +import java.util.List; +import org.apache.ibatis.annotations.Param; + +public interface CustomFunctionMapper { + long countByExample(CustomFunctionExample example); + + int deleteByExample(CustomFunctionExample example); + + int deleteByPrimaryKey(String id); + + int insert(CustomFunctionWithBLOBs record); + + int insertSelective(CustomFunctionWithBLOBs record); + + List selectByExampleWithBLOBs(CustomFunctionExample example); + + List selectByExample(CustomFunctionExample example); + + CustomFunctionWithBLOBs selectByPrimaryKey(String id); + + int updateByExampleSelective(@Param("record") CustomFunctionWithBLOBs record, @Param("example") CustomFunctionExample example); + + int updateByExampleWithBLOBs(@Param("record") CustomFunctionWithBLOBs record, @Param("example") CustomFunctionExample example); + + int updateByExample(@Param("record") CustomFunction record, @Param("example") CustomFunctionExample example); + + int updateByPrimaryKeySelective(CustomFunctionWithBLOBs record); + + int updateByPrimaryKeyWithBLOBs(CustomFunctionWithBLOBs record); + + int updateByPrimaryKey(CustomFunction record); +} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/CustomFunctionMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/CustomFunctionMapper.xml new file mode 100644 index 0000000000..aa32fd57dd --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/mapper/CustomFunctionMapper.xml @@ -0,0 +1,372 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + id, `name`, tags, description, `type`, create_user, create_time, update_time, project_id + + + params, script, `result` + + + + + + delete from custom_function + where id = #{id,jdbcType=VARCHAR} + + + delete from custom_function + + + + + + insert into custom_function (id, `name`, tags, + description, `type`, create_user, + create_time, update_time, project_id, + params, script, `result` + ) + values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{tags,jdbcType=VARCHAR}, + #{description,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{createUser,jdbcType=VARCHAR}, + #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{projectId,jdbcType=VARCHAR}, + #{params,jdbcType=LONGVARCHAR}, #{script,jdbcType=LONGVARCHAR}, #{result,jdbcType=LONGVARCHAR} + ) + + + insert into custom_function + + + id, + + + `name`, + + + tags, + + + description, + + + `type`, + + + create_user, + + + create_time, + + + update_time, + + + project_id, + + + params, + + + script, + + + `result`, + + + + + #{id,jdbcType=VARCHAR}, + + + #{name,jdbcType=VARCHAR}, + + + #{tags,jdbcType=VARCHAR}, + + + #{description,jdbcType=VARCHAR}, + + + #{type,jdbcType=VARCHAR}, + + + #{createUser,jdbcType=VARCHAR}, + + + #{createTime,jdbcType=BIGINT}, + + + #{updateTime,jdbcType=BIGINT}, + + + #{projectId,jdbcType=VARCHAR}, + + + #{params,jdbcType=LONGVARCHAR}, + + + #{script,jdbcType=LONGVARCHAR}, + + + #{result,jdbcType=LONGVARCHAR}, + + + + + + update custom_function + + + id = #{record.id,jdbcType=VARCHAR}, + + + `name` = #{record.name,jdbcType=VARCHAR}, + + + tags = #{record.tags,jdbcType=VARCHAR}, + + + description = #{record.description,jdbcType=VARCHAR}, + + + `type` = #{record.type,jdbcType=VARCHAR}, + + + create_user = #{record.createUser,jdbcType=VARCHAR}, + + + create_time = #{record.createTime,jdbcType=BIGINT}, + + + update_time = #{record.updateTime,jdbcType=BIGINT}, + + + project_id = #{record.projectId,jdbcType=VARCHAR}, + + + params = #{record.params,jdbcType=LONGVARCHAR}, + + + script = #{record.script,jdbcType=LONGVARCHAR}, + + + `result` = #{record.result,jdbcType=LONGVARCHAR}, + + + + + + + + update custom_function + set id = #{record.id,jdbcType=VARCHAR}, + `name` = #{record.name,jdbcType=VARCHAR}, + tags = #{record.tags,jdbcType=VARCHAR}, + description = #{record.description,jdbcType=VARCHAR}, + `type` = #{record.type,jdbcType=VARCHAR}, + create_user = #{record.createUser,jdbcType=VARCHAR}, + create_time = #{record.createTime,jdbcType=BIGINT}, + update_time = #{record.updateTime,jdbcType=BIGINT}, + project_id = #{record.projectId,jdbcType=VARCHAR}, + params = #{record.params,jdbcType=LONGVARCHAR}, + script = #{record.script,jdbcType=LONGVARCHAR}, + `result` = #{record.result,jdbcType=LONGVARCHAR} + + + + + + update custom_function + set id = #{record.id,jdbcType=VARCHAR}, + `name` = #{record.name,jdbcType=VARCHAR}, + tags = #{record.tags,jdbcType=VARCHAR}, + description = #{record.description,jdbcType=VARCHAR}, + `type` = #{record.type,jdbcType=VARCHAR}, + create_user = #{record.createUser,jdbcType=VARCHAR}, + create_time = #{record.createTime,jdbcType=BIGINT}, + update_time = #{record.updateTime,jdbcType=BIGINT}, + project_id = #{record.projectId,jdbcType=VARCHAR} + + + + + + update custom_function + + + `name` = #{name,jdbcType=VARCHAR}, + + + tags = #{tags,jdbcType=VARCHAR}, + + + description = #{description,jdbcType=VARCHAR}, + + + `type` = #{type,jdbcType=VARCHAR}, + + + create_user = #{createUser,jdbcType=VARCHAR}, + + + create_time = #{createTime,jdbcType=BIGINT}, + + + update_time = #{updateTime,jdbcType=BIGINT}, + + + project_id = #{projectId,jdbcType=VARCHAR}, + + + params = #{params,jdbcType=LONGVARCHAR}, + + + script = #{script,jdbcType=LONGVARCHAR}, + + + `result` = #{result,jdbcType=LONGVARCHAR}, + + + where id = #{id,jdbcType=VARCHAR} + + + update custom_function + set `name` = #{name,jdbcType=VARCHAR}, + tags = #{tags,jdbcType=VARCHAR}, + description = #{description,jdbcType=VARCHAR}, + `type` = #{type,jdbcType=VARCHAR}, + create_user = #{createUser,jdbcType=VARCHAR}, + create_time = #{createTime,jdbcType=BIGINT}, + update_time = #{updateTime,jdbcType=BIGINT}, + project_id = #{projectId,jdbcType=VARCHAR}, + params = #{params,jdbcType=LONGVARCHAR}, + script = #{script,jdbcType=LONGVARCHAR}, + `result` = #{result,jdbcType=LONGVARCHAR} + where id = #{id,jdbcType=VARCHAR} + + + update custom_function + set `name` = #{name,jdbcType=VARCHAR}, + tags = #{tags,jdbcType=VARCHAR}, + description = #{description,jdbcType=VARCHAR}, + `type` = #{type,jdbcType=VARCHAR}, + create_user = #{createUser,jdbcType=VARCHAR}, + create_time = #{createTime,jdbcType=BIGINT}, + update_time = #{updateTime,jdbcType=BIGINT}, + project_id = #{projectId,jdbcType=VARCHAR} + where id = #{id,jdbcType=VARCHAR} + + \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/controller/CustomFunctionController.java b/backend/src/main/java/io/metersphere/controller/CustomFunctionController.java new file mode 100644 index 0000000000..f73039e3ca --- /dev/null +++ b/backend/src/main/java/io/metersphere/controller/CustomFunctionController.java @@ -0,0 +1,57 @@ +package io.metersphere.controller; + +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import io.metersphere.base.domain.CustomFunction; +import io.metersphere.base.domain.CustomFunctionWithBLOBs; +import io.metersphere.commons.utils.PageUtils; +import io.metersphere.commons.utils.Pager; +import io.metersphere.controller.request.CustomFunctionRequest; +import io.metersphere.service.CustomFunctionService; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.List; + +/** + * @author lyh + */ + +@RequestMapping("custom/func") +@RestController +public class CustomFunctionController { + + @Resource + private CustomFunctionService customFunctionService; + + @PostMapping("/save") + public CustomFunctionWithBLOBs save(@RequestBody CustomFunctionRequest request) { + return customFunctionService.save(request); + } + + @GetMapping("/delete/{id}") + public void delete(@PathVariable String id) { + customFunctionService.delete(id); + } + + @PostMapping("/update") + public void update(@RequestBody CustomFunctionRequest request) { + customFunctionService.update(request); + } + + @PostMapping("/list/{goPage}/{pageSize}") + public Pager> query(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody CustomFunctionRequest request) { + Page page = PageHelper.startPage(goPage, pageSize, true); + return PageUtils.setPageInfo(page, customFunctionService.query(request)); + } + + @GetMapping("/copy/{id}") + public CustomFunctionWithBLOBs copy(@PathVariable String id) { + return customFunctionService.copy(id); + } + + @GetMapping("/get/{id}") + public CustomFunctionWithBLOBs get(@PathVariable String id) { + return customFunctionService.get(id); + } +} diff --git a/backend/src/main/java/io/metersphere/controller/request/CustomFunctionRequest.java b/backend/src/main/java/io/metersphere/controller/request/CustomFunctionRequest.java new file mode 100644 index 0000000000..580bff4abe --- /dev/null +++ b/backend/src/main/java/io/metersphere/controller/request/CustomFunctionRequest.java @@ -0,0 +1,12 @@ +package io.metersphere.controller.request; + +import io.metersphere.base.domain.CustomFunctionWithBLOBs; +import lombok.Getter; +import lombok.Setter; + + +@Getter +@Setter +public class CustomFunctionRequest extends CustomFunctionWithBLOBs { + +} diff --git a/backend/src/main/java/io/metersphere/service/CustomFunctionService.java b/backend/src/main/java/io/metersphere/service/CustomFunctionService.java new file mode 100644 index 0000000000..c736d318ca --- /dev/null +++ b/backend/src/main/java/io/metersphere/service/CustomFunctionService.java @@ -0,0 +1,109 @@ +package io.metersphere.service; + + +import io.metersphere.base.domain.CustomFunction; +import io.metersphere.base.domain.CustomFunctionExample; +import io.metersphere.base.domain.CustomFunctionWithBLOBs; +import io.metersphere.base.mapper.CustomFunctionMapper; +import io.metersphere.commons.exception.MSException; +import io.metersphere.commons.utils.BeanUtils; +import io.metersphere.commons.utils.SessionUtils; +import io.metersphere.controller.request.CustomFunctionRequest; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.List; +import java.util.UUID; + +/** + * @author lyh + */ + +@Service +@Transactional(rollbackFor = Exception.class) +public class CustomFunctionService { + + + @Resource + private CustomFunctionMapper customFunctionMapper; + + public CustomFunctionWithBLOBs save(CustomFunctionRequest request) { + request.setId(UUID.randomUUID().toString()); + request.setCreateUser(SessionUtils.getUserId()); + request.setProjectId(SessionUtils.getCurrentProjectId()); + + checkFuncExist(request); + + request.setCreateTime(System.currentTimeMillis()); + request.setUpdateTime(System.currentTimeMillis()); + customFunctionMapper.insert(request); + return request; + } + + private void checkFuncExist(CustomFunctionRequest request) { + String id = request.getId(); + String name = request.getName(); + CustomFunctionExample example = new CustomFunctionExample(); + CustomFunctionExample.Criteria criteria = example + .createCriteria() + .andProjectIdEqualTo(request.getProjectId()) + .andNameEqualTo(name); + if (StringUtils.isNotBlank(id)) { + criteria.andIdNotEqualTo(id); + } + if (customFunctionMapper.countByExample(example) > 0) { + MSException.throwException("自定义函数名称已存在!"); + } + } + + public void delete(String id) { + if (StringUtils.isBlank(id)) { + return; + } + customFunctionMapper.deleteByPrimaryKey(id); + } + + public List query(CustomFunctionRequest request) { + String projectId = request.getProjectId(); + if (StringUtils.isBlank(projectId)) { + projectId = SessionUtils.getCurrentProjectId(); + } + CustomFunctionExample example = new CustomFunctionExample(); + example.createCriteria().andProjectIdEqualTo(projectId); + return customFunctionMapper.selectByExample(example); + } + + public void update(CustomFunctionRequest request) { + checkFuncExist(request); + request.setUpdateTime(System.currentTimeMillis()); + customFunctionMapper.updateByPrimaryKeyWithBLOBs(request); + } + + public CustomFunctionWithBLOBs copy(String id) { + CustomFunctionWithBLOBs blob = customFunctionMapper.selectByPrimaryKey(id); + if (blob == null) { + MSException.throwException("copy fail, source obj is null."); + } + CustomFunctionWithBLOBs copyBlob = new CustomFunctionWithBLOBs(); + BeanUtils.copyBean(copyBlob, blob); + String copyId = UUID.randomUUID().toString(); + String copyNameId = copyId.substring(0, 3); + String copyName = blob.getName() + "_" + copyNameId + "_COPY"; + copyBlob.setId(copyId); + copyBlob.setName(copyName); + copyBlob.setCreateUser(SessionUtils.getUserId()); + copyBlob.setCreateTime(System.currentTimeMillis()); + copyBlob.setUpdateTime(System.currentTimeMillis()); + customFunctionMapper.insert(copyBlob); + return copyBlob; + } + + public CustomFunctionWithBLOBs get(String id) { + if (StringUtils.isBlank(id)) { + return new CustomFunctionWithBLOBs(); + } + return customFunctionMapper.selectByPrimaryKey(id); + } +} diff --git a/frontend/src/business/components/settings/project/function/CustomFunction.vue b/frontend/src/business/components/settings/project/function/CustomFunction.vue new file mode 100644 index 0000000000..a33e956e20 --- /dev/null +++ b/frontend/src/business/components/settings/project/function/CustomFunction.vue @@ -0,0 +1,156 @@ + + + + + + diff --git a/frontend/src/business/components/settings/project/function/EditFunction.vue b/frontend/src/business/components/settings/project/function/EditFunction.vue new file mode 100644 index 0000000000..ca1bddee35 --- /dev/null +++ b/frontend/src/business/components/settings/project/function/EditFunction.vue @@ -0,0 +1,285 @@ + + + + + diff --git a/frontend/src/business/components/settings/project/function/FunctionParams.vue b/frontend/src/business/components/settings/project/function/FunctionParams.vue new file mode 100644 index 0000000000..fdb919ff0b --- /dev/null +++ b/frontend/src/business/components/settings/project/function/FunctionParams.vue @@ -0,0 +1,92 @@ + + + + + diff --git a/frontend/src/business/components/settings/router.js b/frontend/src/business/components/settings/router.js index 0d6a570ca9..af96c2a8f2 100644 --- a/frontend/src/business/components/settings/router.js +++ b/frontend/src/business/components/settings/router.js @@ -158,5 +158,10 @@ export default { component: () => import('@/business/components/settings/plugin/PluginConfig'), meta: {system: true, title: 'plugin.title', permissions: ['SYSTEM_USER:READ']} }, + { + path: 'function', + component: () => import('@/business/components/settings/project/function/CustomFunction'), + meta: {project: true, title: '自定义函数'} + } ] };