refactor(接口测试): 去除无用表结构
This commit is contained in:
parent
f76785d4e6
commit
df1064f803
|
@ -1,108 +0,0 @@
|
|||
package io.metersphere.api.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 ApiEnvironmentConfig implements Serializable {
|
||||
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "{api_environment_config.id.not_blank}", groups = {Updated.class})
|
||||
@Size(min = 1, max = 50, message = "{api_environment_config.id.length_range}", groups = {Created.class, Updated.class})
|
||||
private String id;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private Long createTime;
|
||||
|
||||
@Schema(description = "修改时间")
|
||||
private Long updateTime;
|
||||
|
||||
@Schema(description = "用户fk")
|
||||
private String createUser;
|
||||
|
||||
@Schema(description = "环境fk", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "{api_environment_config.environment_id.not_blank}", groups = {Created.class})
|
||||
@Size(min = 1, max = 50, message = "{api_environment_config.environment_id.length_range}", groups = {Created.class, Updated.class})
|
||||
private String environmentId;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public enum Column {
|
||||
id("id", "id", "VARCHAR", false),
|
||||
createTime("create_time", "createTime", "BIGINT", false),
|
||||
updateTime("update_time", "updateTime", "BIGINT", false),
|
||||
createUser("create_user", "createUser", "VARCHAR", false),
|
||||
environmentId("environment_id", "environmentId", "VARCHAR", 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();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,530 +0,0 @@
|
|||
package io.metersphere.api.domain;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ApiEnvironmentConfigExample {
|
||||
protected String orderByClause;
|
||||
|
||||
protected boolean distinct;
|
||||
|
||||
protected List<Criteria> oredCriteria;
|
||||
|
||||
public ApiEnvironmentConfigExample() {
|
||||
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 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 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<String> values) {
|
||||
addCriterion("create_user in", values, "createUser");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateUserNotIn(List<String> 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 andEnvironmentIdIsNull() {
|
||||
addCriterion("environment_id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEnvironmentIdIsNotNull() {
|
||||
addCriterion("environment_id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEnvironmentIdEqualTo(String value) {
|
||||
addCriterion("environment_id =", value, "environmentId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEnvironmentIdNotEqualTo(String value) {
|
||||
addCriterion("environment_id <>", value, "environmentId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEnvironmentIdGreaterThan(String value) {
|
||||
addCriterion("environment_id >", value, "environmentId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEnvironmentIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("environment_id >=", value, "environmentId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEnvironmentIdLessThan(String value) {
|
||||
addCriterion("environment_id <", value, "environmentId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEnvironmentIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("environment_id <=", value, "environmentId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEnvironmentIdLike(String value) {
|
||||
addCriterion("environment_id like", value, "environmentId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEnvironmentIdNotLike(String value) {
|
||||
addCriterion("environment_id not like", value, "environmentId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEnvironmentIdIn(List<String> values) {
|
||||
addCriterion("environment_id in", values, "environmentId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEnvironmentIdNotIn(List<String> values) {
|
||||
addCriterion("environment_id not in", values, "environmentId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEnvironmentIdBetween(String value1, String value2) {
|
||||
addCriterion("environment_id between", value1, value2, "environmentId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEnvironmentIdNotBetween(String value1, String value2) {
|
||||
addCriterion("environment_id not between", value1, value2, "environmentId");
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
package io.metersphere.api.mapper;
|
||||
|
||||
import io.metersphere.api.domain.ApiEnvironmentConfig;
|
||||
import io.metersphere.api.domain.ApiEnvironmentConfigExample;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface ApiEnvironmentConfigMapper {
|
||||
long countByExample(ApiEnvironmentConfigExample example);
|
||||
|
||||
int deleteByExample(ApiEnvironmentConfigExample example);
|
||||
|
||||
int deleteByPrimaryKey(String id);
|
||||
|
||||
int insert(ApiEnvironmentConfig record);
|
||||
|
||||
int insertSelective(ApiEnvironmentConfig record);
|
||||
|
||||
List<ApiEnvironmentConfig> selectByExample(ApiEnvironmentConfigExample example);
|
||||
|
||||
ApiEnvironmentConfig selectByPrimaryKey(String id);
|
||||
|
||||
int updateByExampleSelective(@Param("record") ApiEnvironmentConfig record, @Param("example") ApiEnvironmentConfigExample example);
|
||||
|
||||
int updateByExample(@Param("record") ApiEnvironmentConfig record, @Param("example") ApiEnvironmentConfigExample example);
|
||||
|
||||
int updateByPrimaryKeySelective(ApiEnvironmentConfig record);
|
||||
|
||||
int updateByPrimaryKey(ApiEnvironmentConfig record);
|
||||
|
||||
int batchInsert(@Param("list") List<ApiEnvironmentConfig> list);
|
||||
|
||||
int batchInsertSelective(@Param("list") List<ApiEnvironmentConfig> list, @Param("selective") ApiEnvironmentConfig.Column ... selective);
|
||||
}
|
|
@ -1,249 +0,0 @@
|
|||
<?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.api.mapper.ApiEnvironmentConfigMapper">
|
||||
<resultMap id="BaseResultMap" type="io.metersphere.api.domain.ApiEnvironmentConfig">
|
||||
<id column="id" jdbcType="VARCHAR" property="id" />
|
||||
<result column="create_time" jdbcType="BIGINT" property="createTime" />
|
||||
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
|
||||
<result column="create_user" jdbcType="VARCHAR" property="createUser" />
|
||||
<result column="environment_id" jdbcType="VARCHAR" property="environmentId" />
|
||||
</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, create_time, update_time, create_user, environment_id
|
||||
</sql>
|
||||
<select id="selectByExample" parameterType="io.metersphere.api.domain.ApiEnvironmentConfigExample" resultMap="BaseResultMap">
|
||||
select
|
||||
<if test="distinct">
|
||||
distinct
|
||||
</if>
|
||||
<include refid="Base_Column_List" />
|
||||
from api_environment_config
|
||||
<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 api_environment_config
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
|
||||
delete from api_environment_config
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</delete>
|
||||
<delete id="deleteByExample" parameterType="io.metersphere.api.domain.ApiEnvironmentConfigExample">
|
||||
delete from api_environment_config
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</delete>
|
||||
<insert id="insert" parameterType="io.metersphere.api.domain.ApiEnvironmentConfig">
|
||||
insert into api_environment_config (id, create_time, update_time,
|
||||
create_user, environment_id)
|
||||
values (#{id,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT},
|
||||
#{createUser,jdbcType=VARCHAR}, #{environmentId,jdbcType=VARCHAR})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="io.metersphere.api.domain.ApiEnvironmentConfig">
|
||||
insert into api_environment_config
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
id,
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time,
|
||||
</if>
|
||||
<if test="createUser != null">
|
||||
create_user,
|
||||
</if>
|
||||
<if test="environmentId != null">
|
||||
environment_id,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
#{id,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
#{createTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
#{updateTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="createUser != null">
|
||||
#{createUser,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="environmentId != null">
|
||||
#{environmentId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<select id="countByExample" parameterType="io.metersphere.api.domain.ApiEnvironmentConfigExample" resultType="java.lang.Long">
|
||||
select count(*) from api_environment_config
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</select>
|
||||
<update id="updateByExampleSelective" parameterType="map">
|
||||
update api_environment_config
|
||||
<set>
|
||||
<if test="record.id != null">
|
||||
id = #{record.id,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>
|
||||
<if test="record.createUser != null">
|
||||
create_user = #{record.createUser,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.environmentId != null">
|
||||
environment_id = #{record.environmentId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByExample" parameterType="map">
|
||||
update api_environment_config
|
||||
set id = #{record.id,jdbcType=VARCHAR},
|
||||
create_time = #{record.createTime,jdbcType=BIGINT},
|
||||
update_time = #{record.updateTime,jdbcType=BIGINT},
|
||||
create_user = #{record.createUser,jdbcType=VARCHAR},
|
||||
environment_id = #{record.environmentId,jdbcType=VARCHAR}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.api.domain.ApiEnvironmentConfig">
|
||||
update api_environment_config
|
||||
<set>
|
||||
<if test="createTime != null">
|
||||
create_time = #{createTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time = #{updateTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="createUser != null">
|
||||
create_user = #{createUser,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="environmentId != null">
|
||||
environment_id = #{environmentId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="io.metersphere.api.domain.ApiEnvironmentConfig">
|
||||
update api_environment_config
|
||||
set create_time = #{createTime,jdbcType=BIGINT},
|
||||
update_time = #{updateTime,jdbcType=BIGINT},
|
||||
create_user = #{createUser,jdbcType=VARCHAR},
|
||||
environment_id = #{environmentId,jdbcType=VARCHAR}
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
<insert id="batchInsert" parameterType="map">
|
||||
insert into api_environment_config
|
||||
(id, create_time, update_time, create_user, environment_id)
|
||||
values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.id,jdbcType=VARCHAR}, #{item.createTime,jdbcType=BIGINT}, #{item.updateTime,jdbcType=BIGINT},
|
||||
#{item.createUser,jdbcType=VARCHAR}, #{item.environmentId,jdbcType=VARCHAR})
|
||||
</foreach>
|
||||
</insert>
|
||||
<insert id="batchInsertSelective" parameterType="map">
|
||||
insert into api_environment_config (
|
||||
<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="'create_time'.toString() == column.value">
|
||||
#{item.createTime,jdbcType=BIGINT}
|
||||
</if>
|
||||
<if test="'update_time'.toString() == column.value">
|
||||
#{item.updateTime,jdbcType=BIGINT}
|
||||
</if>
|
||||
<if test="'create_user'.toString() == column.value">
|
||||
#{item.createUser,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<if test="'environment_id'.toString() == column.value">
|
||||
#{item.environmentId,jdbcType=VARCHAR}
|
||||
</if>
|
||||
</foreach>
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
</mapper>
|
|
@ -99,17 +99,6 @@ CREATE INDEX idx_create_time ON api_definition(create_time desc);
|
|||
CREATE INDEX idx_create_user ON api_definition(create_user);
|
||||
CREATE INDEX idx_name ON api_definition(name);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS api_environment_config(
|
||||
`id` VARCHAR(50) NOT NULL COMMENT 'ID' ,
|
||||
`create_time` BIGINT NOT NULL COMMENT '创建时间' ,
|
||||
`update_time` BIGINT NOT NULL COMMENT '修改时间' ,
|
||||
`create_user` VARCHAR(50) NOT NULL COMMENT '用户fk' ,
|
||||
`environment_id` VARCHAR(50) NOT NULL COMMENT '环境fk' ,
|
||||
PRIMARY KEY (id)
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4
|
||||
COLLATE = utf8mb4_general_ci COMMENT = '接口定义公共部分环境';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS api_report(
|
||||
`id` VARCHAR(50) NOT NULL COMMENT '接口结果报告pk' ,
|
||||
`name` VARCHAR(200) NOT NULL COMMENT '接口报告名称' ,
|
||||
|
|
|
@ -28,6 +28,7 @@ public class Body {
|
|||
NONE,
|
||||
RAW,
|
||||
WWW_FORM,
|
||||
XML
|
||||
XML,
|
||||
JSON
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
package io.metersphere.api.controller.definition;
|
||||
|
||||
import io.metersphere.api.domain.ApiEnvironmentConfig;
|
||||
import io.metersphere.api.service.definition.ApiEnvironmentConfigService;
|
||||
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.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Tag(name = "接口测试-接口管理-环境")
|
||||
@RestController
|
||||
@RequestMapping(value = "/api/definition/env")
|
||||
public class ApiEnvironmentConfigController {
|
||||
@Resource
|
||||
private ApiEnvironmentConfigService apiEnvironmentConfigService;
|
||||
|
||||
@GetMapping("/get/{projectId}")
|
||||
@Operation(summary = "接口测试-接口管理-获取当前用户配置的环境")
|
||||
public ApiEnvironmentConfig get(@PathVariable String projectId) {
|
||||
return apiEnvironmentConfigService.get(SessionUtils.getUserId(), projectId);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/add/{environmentId}")
|
||||
@Operation(summary = "接口测试-接口管理-添加当前用户的环境配置")
|
||||
public String add(@PathVariable String environmentId) {
|
||||
return apiEnvironmentConfigService.add(environmentId, SessionUtils.getUserId(), SessionUtils.getCurrentProjectId());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
package io.metersphere.api.service.definition;
|
||||
|
||||
import io.metersphere.api.domain.ApiEnvironmentConfig;
|
||||
import io.metersphere.project.domain.Project;
|
||||
import io.metersphere.project.mapper.ProjectMapper;
|
||||
import io.metersphere.sdk.constants.HttpMethodConstants;
|
||||
import io.metersphere.sdk.domain.Environment;
|
||||
import io.metersphere.sdk.mapper.EnvironmentMapper;
|
||||
import io.metersphere.system.dto.builder.LogDTOBuilder;
|
||||
import io.metersphere.system.log.constants.OperationLogModule;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.log.dto.LogDTO;
|
||||
import io.metersphere.system.log.service.OperationLogService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class ApiEnvironmentConfigLogService {
|
||||
|
||||
@Resource
|
||||
private EnvironmentMapper environmentMapper;
|
||||
@Resource
|
||||
private ProjectMapper projectMapper;
|
||||
@Resource
|
||||
private OperationLogService operationLogService;
|
||||
|
||||
public void addLog(ApiEnvironmentConfig env, String projectId) {
|
||||
Project project = projectMapper.selectByPrimaryKey(projectId);
|
||||
Environment environment = environmentMapper.selectByPrimaryKey(env.getEnvironmentId());
|
||||
LogDTO dto = LogDTOBuilder.builder()
|
||||
.projectId(projectId)
|
||||
.organizationId(project.getOrganizationId())
|
||||
.type(OperationLogType.ADD.name())
|
||||
.module(OperationLogModule.API_DEFINITION_ENVIRONMENT)
|
||||
.method(HttpMethodConstants.GET.name())
|
||||
.path("/api/definition/env/add/")
|
||||
.sourceId(env.getId())
|
||||
.content(environment.getName())
|
||||
.createUser(env.getCreateUser())
|
||||
.build().getLogDTO();
|
||||
operationLogService.add(dto);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,82 +0,0 @@
|
|||
package io.metersphere.api.service.definition;
|
||||
|
||||
import io.metersphere.api.domain.ApiEnvironmentConfig;
|
||||
import io.metersphere.api.domain.ApiEnvironmentConfigExample;
|
||||
import io.metersphere.api.mapper.ApiEnvironmentConfigMapper;
|
||||
import io.metersphere.sdk.domain.Environment;
|
||||
import io.metersphere.sdk.domain.EnvironmentExample;
|
||||
import io.metersphere.sdk.mapper.EnvironmentMapper;
|
||||
import io.metersphere.system.uid.IDGenerator;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class ApiEnvironmentConfigService {
|
||||
@Resource
|
||||
private ApiEnvironmentConfigMapper apiEnvironmentConfigMapper;
|
||||
@Resource
|
||||
private EnvironmentMapper environmentMapper;
|
||||
@Resource
|
||||
private ApiEnvironmentConfigLogService apiEnvironmentConfigLogService;
|
||||
|
||||
|
||||
public ApiEnvironmentConfig get(String userId, String projectId) {
|
||||
ApiEnvironmentConfigExample example = new ApiEnvironmentConfigExample();
|
||||
example.createCriteria().andCreateUserEqualTo(userId);
|
||||
List<ApiEnvironmentConfig> list = apiEnvironmentConfigMapper.selectByExample(example);
|
||||
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
EnvironmentExample environmentExample = new EnvironmentExample();
|
||||
if (StringUtils.isNotEmpty(list.get(0).getEnvironmentId())) {
|
||||
environmentExample.createCriteria().andProjectIdEqualTo(projectId).andIdEqualTo(list.get(0).getEnvironmentId());
|
||||
long count = environmentMapper.countByExample(environmentExample);
|
||||
if (count > 0) {
|
||||
return list.get(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
EnvironmentExample environmentExample = new EnvironmentExample();
|
||||
environmentExample.createCriteria().andProjectIdEqualTo(projectId).andMockEqualTo(true);
|
||||
List<Environment> environments = environmentMapper.selectByExample(environmentExample);
|
||||
list.get(0).setEnvironmentId(environments.get(0).getId());
|
||||
return list.get(0);
|
||||
}
|
||||
|
||||
public String add(String envId, String userId, String projectId) {
|
||||
ApiEnvironmentConfig env = new ApiEnvironmentConfig();
|
||||
env.setId(IDGenerator.nextStr());
|
||||
env.setCreateTime(System.currentTimeMillis());
|
||||
env.setUpdateTime(System.currentTimeMillis());
|
||||
env.setEnvironmentId(envId);
|
||||
env.setCreateUser(userId);
|
||||
ApiEnvironmentConfig apiDefinitionEnv = this.get(userId);
|
||||
if (apiDefinitionEnv == null) {
|
||||
apiEnvironmentConfigMapper.insert(env);
|
||||
} else {
|
||||
apiDefinitionEnv.setEnvironmentId(envId);
|
||||
apiDefinitionEnv.setUpdateTime(System.currentTimeMillis());
|
||||
apiEnvironmentConfigMapper.updateByPrimaryKey(apiDefinitionEnv);
|
||||
return apiDefinitionEnv.getId();
|
||||
}
|
||||
apiEnvironmentConfigLogService.addLog(env, projectId);
|
||||
return env.getId();
|
||||
}
|
||||
|
||||
public ApiEnvironmentConfig get(String userId) {
|
||||
ApiEnvironmentConfigExample example = new ApiEnvironmentConfigExample();
|
||||
example.createCriteria().andCreateUserEqualTo(userId);
|
||||
List<ApiEnvironmentConfig> list = apiEnvironmentConfigMapper.selectByExample(example);
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
return list.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -9,11 +9,11 @@ import io.metersphere.api.dto.definition.ApiTestCaseLogDTO;
|
|||
import io.metersphere.api.dto.definition.ApiTestCaseUpdateRequest;
|
||||
import io.metersphere.api.mapper.ApiTestCaseBlobMapper;
|
||||
import io.metersphere.api.mapper.ApiTestCaseMapper;
|
||||
import io.metersphere.sdk.util.ApiDataUtils;
|
||||
import io.metersphere.plugin.api.spi.AbstractMsTestElement;
|
||||
import io.metersphere.project.domain.Project;
|
||||
import io.metersphere.project.mapper.ProjectMapper;
|
||||
import io.metersphere.sdk.constants.HttpMethodConstants;
|
||||
import io.metersphere.sdk.util.ApiDataUtils;
|
||||
import io.metersphere.sdk.util.BeanUtils;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.sdk.util.Translator;
|
||||
|
@ -112,7 +112,7 @@ public class ApiTestCaseLogService {
|
|||
OperationLogType.RECOVER.name(),
|
||||
OperationLogModule.API_DEFINITION_CASE,
|
||||
apiTestCase.getName());
|
||||
|
||||
dto.setHistory(true);
|
||||
dto.setPath("/api/case/recover/" + id);
|
||||
dto.setMethod(HttpMethodConstants.GET.name());
|
||||
dto.setOriginalValue(JSON.toJSONBytes(apiTestCase));
|
||||
|
@ -169,6 +169,7 @@ public class ApiTestCaseLogService {
|
|||
request.getName());
|
||||
|
||||
dto.setPath("/api/case/update");
|
||||
dto.setHistory(true);
|
||||
dto.setMethod(HttpMethodConstants.POST.name());
|
||||
ApiTestCaseLogDTO apiTestCaseDTO = new ApiTestCaseLogDTO();
|
||||
BeanUtils.copyBean(apiTestCaseDTO, apiTestCase);
|
||||
|
@ -191,6 +192,7 @@ public class ApiTestCaseLogService {
|
|||
apiTestCase.getName());
|
||||
|
||||
dto.setPath("/api/case/update");
|
||||
dto.setHistory(true);
|
||||
dto.setMethod(HttpMethodConstants.POST.name());
|
||||
ApiTestCaseLogDTO apiTestCaseDTO = new ApiTestCaseLogDTO();
|
||||
BeanUtils.copyBean(apiTestCaseDTO, apiTestCase);
|
||||
|
@ -221,18 +223,18 @@ public class ApiTestCaseLogService {
|
|||
}
|
||||
|
||||
public void batchToGcLog(List<ApiTestCase> apiTestCases, String operator, String projectId) {
|
||||
saveBatchLog(projectId, apiTestCases, "/api/case/batch/move-gc", operator, OperationLogType.DELETE.name());
|
||||
saveBatchLog(projectId, apiTestCases, "/api/case/batch/move-gc", operator, OperationLogType.DELETE.name(), false);
|
||||
}
|
||||
|
||||
public void batchEditLog(List<ApiTestCase> apiTestCases, String operator, String projectId) {
|
||||
saveBatchLog(projectId, apiTestCases, "/api/case/batch/edit", operator, OperationLogType.UPDATE.name());
|
||||
saveBatchLog(projectId, apiTestCases, "/api/case/batch/edit", operator, OperationLogType.UPDATE.name(), true);
|
||||
}
|
||||
|
||||
public void batchRecoverLog(List<ApiTestCase> apiTestCases, String operator, String projectId) {
|
||||
saveBatchLog(projectId, apiTestCases, "/api/case/recover", operator, OperationLogType.RECOVER.name());
|
||||
saveBatchLog(projectId, apiTestCases, "/api/case/recover", operator, OperationLogType.RECOVER.name(), true);
|
||||
}
|
||||
|
||||
private void saveBatchLog(String projectId, List<ApiTestCase> apiTestCases, String path, String operator, String operationType) {
|
||||
private void saveBatchLog(String projectId, List<ApiTestCase> apiTestCases, String path, String operator, String operationType, boolean isHistory) {
|
||||
Project project = projectMapper.selectByPrimaryKey(projectId);
|
||||
//取出apiTestCases所有的id为新的list
|
||||
List<String> caseId = apiTestCases.stream().map(ApiTestCase::getId).distinct().toList();
|
||||
|
@ -265,6 +267,7 @@ public class ApiTestCaseLogService {
|
|||
.createUser(operator)
|
||||
.originalValue(JSON.toJSONBytes(apiTestCaseDTO))
|
||||
.build().getLogDTO();
|
||||
dto.setHistory(isHistory);
|
||||
logs.add(dto);
|
||||
}
|
||||
);
|
||||
|
|
|
@ -1,120 +0,0 @@
|
|||
package io.metersphere.api.controller;
|
||||
|
||||
import io.metersphere.api.domain.ApiEnvironmentConfig;
|
||||
import io.metersphere.api.domain.ApiEnvironmentConfigExample;
|
||||
import io.metersphere.api.mapper.ApiEnvironmentConfigMapper;
|
||||
import io.metersphere.sdk.constants.SessionConstants;
|
||||
import io.metersphere.sdk.domain.Environment;
|
||||
import io.metersphere.sdk.mapper.EnvironmentMapper;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.system.base.BaseTest;
|
||||
import io.metersphere.system.controller.handler.ResultHolder;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.uid.IDGenerator;
|
||||
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.http.MediaType;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.MvcResult;
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
@AutoConfigureMockMvc
|
||||
public class ApiEnvironmentConfigControllerTests extends BaseTest {
|
||||
private final static String add = "/api/definition/env/add/";
|
||||
private final static String get = "/api/definition/env/get/";
|
||||
private static String envId;
|
||||
@Resource
|
||||
private MockMvc mockMvc;
|
||||
@Resource
|
||||
private EnvironmentMapper environmentMapper;
|
||||
@Resource
|
||||
private ApiEnvironmentConfigMapper apiEnvironmentConfigMapper;
|
||||
private Environment environment;
|
||||
|
||||
public static <T> T parseObjectFromMvcResult(MvcResult mvcResult, Class<T> parseClass) {
|
||||
try {
|
||||
String returnData = mvcResult.getResponse().getContentAsString(StandardCharsets.UTF_8);
|
||||
ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class);
|
||||
//返回请求正常
|
||||
Assertions.assertNotNull(resultHolder);
|
||||
return JSON.parseObject(JSON.toJSONString(resultHolder.getData()), parseClass);
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
public void initData() {
|
||||
//生成环境
|
||||
if (environment == null) {
|
||||
Environment env = new Environment();
|
||||
env.setId(IDGenerator.nextStr());
|
||||
env.setName("test-env-name");
|
||||
env.setProjectId(DEFAULT_PROJECT_ID);
|
||||
env.setCreateUser("admin");
|
||||
env.setCreateTime(System.currentTimeMillis());
|
||||
env.setUpdateUser("admin");
|
||||
env.setUpdateTime(System.currentTimeMillis());
|
||||
environmentMapper.insertSelective(env);
|
||||
environment = environmentMapper.selectByPrimaryKey(env.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private MvcResult responseGet(String url, String projectId) throws Exception {
|
||||
return mockMvc.perform(MockMvcRequestBuilders.get(url)
|
||||
.header(SessionConstants.HEADER_TOKEN, sessionId)
|
||||
.header(SessionConstants.CSRF_TOKEN, csrfToken)
|
||||
.header(SessionConstants.CURRENT_PROJECT, projectId)
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON)).andReturn();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(1)
|
||||
public void addDataTestSuccess() throws Exception {
|
||||
this.responseGet(add + environment.getId(), DEFAULT_PROJECT_ID);
|
||||
ApiEnvironmentConfigExample example = new ApiEnvironmentConfigExample();
|
||||
example.createCriteria().andCreateUserEqualTo("admin");
|
||||
List<ApiEnvironmentConfig> apiEnvironmentConfigs = apiEnvironmentConfigMapper.selectByExample(example);
|
||||
Assertions.assertEquals(apiEnvironmentConfigs.get(0).getEnvironmentId(), environment.getId());
|
||||
envId = apiEnvironmentConfigs.get(0).getEnvironmentId();
|
||||
//检查日志
|
||||
checkLog(apiEnvironmentConfigs.get(0).getId(), OperationLogType.ADD, add);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
public void getDataTestFail() throws Exception {
|
||||
MvcResult mvcResult = responseGet(get + DEFAULT_PROJECT_ID, DEFAULT_PROJECT_ID);
|
||||
ApiEnvironmentConfig environmentConfig = parseObjectFromMvcResult(mvcResult, ApiEnvironmentConfig.class);
|
||||
Assertions.assertNotNull(environmentConfig);
|
||||
Assertions.assertEquals(environmentConfig.getEnvironmentId(), envId);
|
||||
|
||||
responseGet(add + "env-1111", DEFAULT_PROJECT_ID);
|
||||
ApiEnvironmentConfigExample example = new ApiEnvironmentConfigExample();
|
||||
example.createCriteria().andCreateUserEqualTo("admin");
|
||||
List<ApiEnvironmentConfig> apiEnvironmentConfigs = apiEnvironmentConfigMapper.selectByExample(example);
|
||||
Assertions.assertEquals(apiEnvironmentConfigs.get(0).getEnvironmentId(), "env-1111");
|
||||
|
||||
mvcResult = responseGet(get + DEFAULT_PROJECT_ID, DEFAULT_PROJECT_ID);
|
||||
environmentConfig = parseObjectFromMvcResult(mvcResult, ApiEnvironmentConfig.class);
|
||||
Assertions.assertNotNull(environmentConfig);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -103,12 +103,7 @@ public class UserKeyService {
|
|||
userKeyExample.createCriteria().andAccessKeyEqualTo(accessKey).andEnableEqualTo(true);
|
||||
List<UserKey> userKeysList = userKeyMapper.selectByExample(userKeyExample);
|
||||
if (!CollectionUtils.isEmpty(userKeysList)) {
|
||||
//校验是否过期
|
||||
if (BooleanUtils.isTrue(userKeysList.get(0).getForever()) || userKeysList.get(0).getExpireTime() > System.currentTimeMillis()) {
|
||||
return userKeysList.get(0);
|
||||
} else {
|
||||
throw new MSException(Translator.get("apikey_has_expired") + ": " + userKeysList.get(0).getAccessKey());
|
||||
}
|
||||
return userKeysList.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue