refactor: 环境里的变量在脚本中修改后环境中的值也同步修改

环境里的变量在脚本中修改后环境中的值也同步修改
This commit is contained in:
song-tianyang 2021-05-17 17:14:02 +08:00 committed by 刘瑞斌
parent ea4b9692be
commit b70d84b117
8 changed files with 65 additions and 1138 deletions

View File

@ -16,18 +16,6 @@ public class RunningParam {
}
public static void deleteParam(String enviromentId, String key){
checkService();
apiEnvironmentRunningParamService.deleteParam(enviromentId,key);
}
public static String getParam(String enviromentId, String key){
checkService();
return apiEnvironmentRunningParamService.getParam(enviromentId,key);
}
public static String showParams(String enviromentId){
checkService();
return apiEnvironmentRunningParamService.showParams(enviromentId);
}
public static void checkService(){

View File

@ -1,19 +1,14 @@
package io.metersphere.api.service;
import com.alibaba.fastjson.JSONArray;
import io.metersphere.base.domain.ApiEnvironmentRunningParam;
import io.metersphere.base.domain.ApiEnvironmentRunningParamExample;
import io.metersphere.base.mapper.ApiEnvironmentRunningParamMapper;
import io.metersphere.commons.utils.SessionUtils;
import com.alibaba.fastjson.JSONObject;
import io.metersphere.base.domain.ApiTestEnvironmentWithBLOBs;
import io.metersphere.commons.exception.MSException;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
* @author song.tianyang
@ -23,66 +18,75 @@ import java.util.UUID;
@Transactional(rollbackFor = Exception.class)
public class ApiEnvironmentRunningParamService {
@Resource
ApiEnvironmentRunningParamMapper apiEnvironmentRunningParamMapper;
ApiTestEnvironmentService apiTestEnvironmentService;
public synchronized void addParam(String enviromentId, String key, String value) {
if(StringUtils.isEmpty(key)){
return;
}
ApiEnvironmentRunningParamExample example = new ApiEnvironmentRunningParamExample();
example.createCriteria().andApiEnviromentIdEqualTo(enviromentId).andKeyEqualTo(key);
List<ApiEnvironmentRunningParam> list = apiEnvironmentRunningParamMapper.selectByExampleWithBLOBs(example);
long timeStamp = System.currentTimeMillis();
String userId = SessionUtils.getUserId();
if(list.isEmpty()){
ApiEnvironmentRunningParam model = new ApiEnvironmentRunningParam();
model.setApiEnviromentId(enviromentId);
model.setKey(key);
model.setValue(value);
model.setCreateUserId(userId);
model.setId(UUID.randomUUID().toString());
model.setCreateTime(timeStamp);
model.setUpdateTime(timeStamp);
model.setUpdateUserId(userId);
apiEnvironmentRunningParamMapper.insert(model);
ApiTestEnvironmentWithBLOBs apiTestEnvironmentWithBLOBs = apiTestEnvironmentService.get(enviromentId);
if(apiTestEnvironmentWithBLOBs == null ){
MSException.throwException("Unable find environment!");
}
JSONObject configObj = JSONObject.parseObject(apiTestEnvironmentWithBLOBs.getConfig());
if(configObj.containsKey("commonConfig")){
JSONObject commonConfig = configObj.getJSONObject("commonConfig");
if(commonConfig.containsKey("variables")){
JSONArray variables = commonConfig.getJSONArray("variables");
boolean contains = false;
for(int i = 0;i<variables.size();i++){
JSONObject jsonObj = variables.getJSONObject(i);
if(jsonObj.containsKey("name")&&StringUtils.equals(jsonObj.getString("name"), key)){
contains = true;
jsonObj.put("value",value);
}
}
if(!contains){
JSONObject itemObj = new JSONObject();
itemObj.put("name",key);
itemObj.put("value",value);
itemObj.put("enable",true);
if(variables.size() == 0){
variables.add(itemObj);
}else {
ApiEnvironmentRunningParam model = list.get(0);
model.setValue(value);
model.setUpdateTime(timeStamp);
model.setUpdateUserId(userId);
apiEnvironmentRunningParamMapper.updateByPrimaryKeySelective(model);
variables.add(variables.size()-1,itemObj);
}
commonConfig.put("variables",variables);
}
public void deleteParam(String enviromentId, String key) {
ApiEnvironmentRunningParamExample example = new ApiEnvironmentRunningParamExample();
example.createCriteria().andApiEnviromentIdEqualTo(enviromentId).andKeyEqualTo(key);
apiEnvironmentRunningParamMapper.deleteByExample(example);
}
public String getParam(String enviromentId, String key) {
ApiEnvironmentRunningParamExample example = new ApiEnvironmentRunningParamExample();
example.createCriteria().andApiEnviromentIdEqualTo(enviromentId).andKeyEqualTo(key);
List<ApiEnvironmentRunningParam> list = apiEnvironmentRunningParamMapper.selectByExampleWithBLOBs(example);
if(list.isEmpty()){
return "";
}else {
return list.get(0).getValue();
JSONArray variables = new JSONArray();
JSONObject itemObj = new JSONObject();
itemObj.put("name",key);
itemObj.put("value",value);
itemObj.put("enable",true);
JSONObject emptyObj = new JSONObject();
emptyObj.put("enable",true);
variables.add(itemObj);
variables.add(emptyObj);
commonConfig.put("variables",variables);
}
}else {
JSONObject commonConfig = new JSONObject();
JSONArray variables = new JSONArray();
JSONObject itemObj = new JSONObject();
itemObj.put("name",key);
itemObj.put("value",value);
itemObj.put("enable",true);
JSONObject emptyObj = new JSONObject();
emptyObj.put("enable",true);
variables.add(itemObj);
variables.add(emptyObj);
commonConfig.put("variables",variables);
configObj.put("commonConfig",commonConfig);
}
apiTestEnvironmentWithBLOBs.setConfig(configObj.toJSONString());
apiTestEnvironmentService.update(apiTestEnvironmentWithBLOBs);
}
public String showParams(String enviromentId) {
Map<String,String> paramMap = new LinkedHashMap<>();
ApiEnvironmentRunningParamExample example = new ApiEnvironmentRunningParamExample();
example.createCriteria().andApiEnviromentIdEqualTo(enviromentId);
List<ApiEnvironmentRunningParam> list = apiEnvironmentRunningParamMapper.selectByExampleWithBLOBs(example);
for (ApiEnvironmentRunningParam model:
list) {
paramMap.put(model.getKey(),model.getValue());
}
return JSONArray.toJSONString(paramMap);
}
}

View File

@ -1,25 +0,0 @@
package io.metersphere.base.domain;
import java.io.Serializable;
import lombok.Data;
@Data
public class ApiEnvironmentRunningParam implements Serializable {
private String id;
private String apiEnviromentId;
private String key;
private Long createTime;
private Long updateTime;
private String createUserId;
private String updateUserId;
private String value;
private static final long serialVersionUID = 1L;
}

View File

@ -1,670 +0,0 @@
package io.metersphere.base.domain;
import java.util.ArrayList;
import java.util.List;
public class ApiEnvironmentRunningParamExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public ApiEnvironmentRunningParamExample() {
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 andApiEnviromentIdIsNull() {
addCriterion("api_enviroment_id is null");
return (Criteria) this;
}
public Criteria andApiEnviromentIdIsNotNull() {
addCriterion("api_enviroment_id is not null");
return (Criteria) this;
}
public Criteria andApiEnviromentIdEqualTo(String value) {
addCriterion("api_enviroment_id =", value, "apiEnviromentId");
return (Criteria) this;
}
public Criteria andApiEnviromentIdNotEqualTo(String value) {
addCriterion("api_enviroment_id <>", value, "apiEnviromentId");
return (Criteria) this;
}
public Criteria andApiEnviromentIdGreaterThan(String value) {
addCriterion("api_enviroment_id >", value, "apiEnviromentId");
return (Criteria) this;
}
public Criteria andApiEnviromentIdGreaterThanOrEqualTo(String value) {
addCriterion("api_enviroment_id >=", value, "apiEnviromentId");
return (Criteria) this;
}
public Criteria andApiEnviromentIdLessThan(String value) {
addCriterion("api_enviroment_id <", value, "apiEnviromentId");
return (Criteria) this;
}
public Criteria andApiEnviromentIdLessThanOrEqualTo(String value) {
addCriterion("api_enviroment_id <=", value, "apiEnviromentId");
return (Criteria) this;
}
public Criteria andApiEnviromentIdLike(String value) {
addCriterion("api_enviroment_id like", value, "apiEnviromentId");
return (Criteria) this;
}
public Criteria andApiEnviromentIdNotLike(String value) {
addCriterion("api_enviroment_id not like", value, "apiEnviromentId");
return (Criteria) this;
}
public Criteria andApiEnviromentIdIn(List<String> values) {
addCriterion("api_enviroment_id in", values, "apiEnviromentId");
return (Criteria) this;
}
public Criteria andApiEnviromentIdNotIn(List<String> values) {
addCriterion("api_enviroment_id not in", values, "apiEnviromentId");
return (Criteria) this;
}
public Criteria andApiEnviromentIdBetween(String value1, String value2) {
addCriterion("api_enviroment_id between", value1, value2, "apiEnviromentId");
return (Criteria) this;
}
public Criteria andApiEnviromentIdNotBetween(String value1, String value2) {
addCriterion("api_enviroment_id not between", value1, value2, "apiEnviromentId");
return (Criteria) this;
}
public Criteria andKeyIsNull() {
addCriterion("`key` is null");
return (Criteria) this;
}
public Criteria andKeyIsNotNull() {
addCriterion("`key` is not null");
return (Criteria) this;
}
public Criteria andKeyEqualTo(String value) {
addCriterion("`key` =", value, "key");
return (Criteria) this;
}
public Criteria andKeyNotEqualTo(String value) {
addCriterion("`key` <>", value, "key");
return (Criteria) this;
}
public Criteria andKeyGreaterThan(String value) {
addCriterion("`key` >", value, "key");
return (Criteria) this;
}
public Criteria andKeyGreaterThanOrEqualTo(String value) {
addCriterion("`key` >=", value, "key");
return (Criteria) this;
}
public Criteria andKeyLessThan(String value) {
addCriterion("`key` <", value, "key");
return (Criteria) this;
}
public Criteria andKeyLessThanOrEqualTo(String value) {
addCriterion("`key` <=", value, "key");
return (Criteria) this;
}
public Criteria andKeyLike(String value) {
addCriterion("`key` like", value, "key");
return (Criteria) this;
}
public Criteria andKeyNotLike(String value) {
addCriterion("`key` not like", value, "key");
return (Criteria) this;
}
public Criteria andKeyIn(List<String> values) {
addCriterion("`key` in", values, "key");
return (Criteria) this;
}
public Criteria andKeyNotIn(List<String> values) {
addCriterion("`key` not in", values, "key");
return (Criteria) this;
}
public Criteria andKeyBetween(String value1, String value2) {
addCriterion("`key` between", value1, value2, "key");
return (Criteria) this;
}
public Criteria andKeyNotBetween(String value1, String value2) {
addCriterion("`key` not between", value1, value2, "key");
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 andCreateUserIdIsNull() {
addCriterion("create_user_id is null");
return (Criteria) this;
}
public Criteria andCreateUserIdIsNotNull() {
addCriterion("create_user_id is not null");
return (Criteria) this;
}
public Criteria andCreateUserIdEqualTo(String value) {
addCriterion("create_user_id =", value, "createUserId");
return (Criteria) this;
}
public Criteria andCreateUserIdNotEqualTo(String value) {
addCriterion("create_user_id <>", value, "createUserId");
return (Criteria) this;
}
public Criteria andCreateUserIdGreaterThan(String value) {
addCriterion("create_user_id >", value, "createUserId");
return (Criteria) this;
}
public Criteria andCreateUserIdGreaterThanOrEqualTo(String value) {
addCriterion("create_user_id >=", value, "createUserId");
return (Criteria) this;
}
public Criteria andCreateUserIdLessThan(String value) {
addCriterion("create_user_id <", value, "createUserId");
return (Criteria) this;
}
public Criteria andCreateUserIdLessThanOrEqualTo(String value) {
addCriterion("create_user_id <=", value, "createUserId");
return (Criteria) this;
}
public Criteria andCreateUserIdLike(String value) {
addCriterion("create_user_id like", value, "createUserId");
return (Criteria) this;
}
public Criteria andCreateUserIdNotLike(String value) {
addCriterion("create_user_id not like", value, "createUserId");
return (Criteria) this;
}
public Criteria andCreateUserIdIn(List<String> values) {
addCriterion("create_user_id in", values, "createUserId");
return (Criteria) this;
}
public Criteria andCreateUserIdNotIn(List<String> values) {
addCriterion("create_user_id not in", values, "createUserId");
return (Criteria) this;
}
public Criteria andCreateUserIdBetween(String value1, String value2) {
addCriterion("create_user_id between", value1, value2, "createUserId");
return (Criteria) this;
}
public Criteria andCreateUserIdNotBetween(String value1, String value2) {
addCriterion("create_user_id not between", value1, value2, "createUserId");
return (Criteria) this;
}
public Criteria andUpdateUserIdIsNull() {
addCriterion("update_user_id is null");
return (Criteria) this;
}
public Criteria andUpdateUserIdIsNotNull() {
addCriterion("update_user_id is not null");
return (Criteria) this;
}
public Criteria andUpdateUserIdEqualTo(String value) {
addCriterion("update_user_id =", value, "updateUserId");
return (Criteria) this;
}
public Criteria andUpdateUserIdNotEqualTo(String value) {
addCriterion("update_user_id <>", value, "updateUserId");
return (Criteria) this;
}
public Criteria andUpdateUserIdGreaterThan(String value) {
addCriterion("update_user_id >", value, "updateUserId");
return (Criteria) this;
}
public Criteria andUpdateUserIdGreaterThanOrEqualTo(String value) {
addCriterion("update_user_id >=", value, "updateUserId");
return (Criteria) this;
}
public Criteria andUpdateUserIdLessThan(String value) {
addCriterion("update_user_id <", value, "updateUserId");
return (Criteria) this;
}
public Criteria andUpdateUserIdLessThanOrEqualTo(String value) {
addCriterion("update_user_id <=", value, "updateUserId");
return (Criteria) this;
}
public Criteria andUpdateUserIdLike(String value) {
addCriterion("update_user_id like", value, "updateUserId");
return (Criteria) this;
}
public Criteria andUpdateUserIdNotLike(String value) {
addCriterion("update_user_id not like", value, "updateUserId");
return (Criteria) this;
}
public Criteria andUpdateUserIdIn(List<String> values) {
addCriterion("update_user_id in", values, "updateUserId");
return (Criteria) this;
}
public Criteria andUpdateUserIdNotIn(List<String> values) {
addCriterion("update_user_id not in", values, "updateUserId");
return (Criteria) this;
}
public Criteria andUpdateUserIdBetween(String value1, String value2) {
addCriterion("update_user_id between", value1, value2, "updateUserId");
return (Criteria) this;
}
public Criteria andUpdateUserIdNotBetween(String value1, String value2) {
addCriterion("update_user_id not between", value1, value2, "updateUserId");
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

@ -1,36 +0,0 @@
package io.metersphere.base.mapper;
import io.metersphere.base.domain.ApiEnvironmentRunningParam;
import io.metersphere.base.domain.ApiEnvironmentRunningParamExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface ApiEnvironmentRunningParamMapper {
long countByExample(ApiEnvironmentRunningParamExample example);
int deleteByExample(ApiEnvironmentRunningParamExample example);
int deleteByPrimaryKey(String id);
int insert(ApiEnvironmentRunningParam record);
int insertSelective(ApiEnvironmentRunningParam record);
List<ApiEnvironmentRunningParam> selectByExampleWithBLOBs(ApiEnvironmentRunningParamExample example);
List<ApiEnvironmentRunningParam> selectByExample(ApiEnvironmentRunningParamExample example);
ApiEnvironmentRunningParam selectByPrimaryKey(String id);
int updateByExampleSelective(@Param("record") ApiEnvironmentRunningParam record, @Param("example") ApiEnvironmentRunningParamExample example);
int updateByExampleWithBLOBs(@Param("record") ApiEnvironmentRunningParam record, @Param("example") ApiEnvironmentRunningParamExample example);
int updateByExample(@Param("record") ApiEnvironmentRunningParam record, @Param("example") ApiEnvironmentRunningParamExample example);
int updateByPrimaryKeySelective(ApiEnvironmentRunningParam record);
int updateByPrimaryKeyWithBLOBs(ApiEnvironmentRunningParam record);
int updateByPrimaryKey(ApiEnvironmentRunningParam record);
}

View File

@ -1,304 +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.base.mapper.ApiEnvironmentRunningParamMapper">
<resultMap id="BaseResultMap" type="io.metersphere.base.domain.ApiEnvironmentRunningParam">
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="api_enviroment_id" jdbcType="VARCHAR" property="apiEnviromentId" />
<result column="key" jdbcType="VARCHAR" property="key" />
<result column="create_time" jdbcType="BIGINT" property="createTime" />
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
<result column="create_user_id" jdbcType="VARCHAR" property="createUserId" />
<result column="update_user_id" jdbcType="VARCHAR" property="updateUserId" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.ApiEnvironmentRunningParam">
<result column="value" jdbcType="LONGVARCHAR" property="value" />
</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, api_enviroment_id, `key`, create_time, update_time, create_user_id, update_user_id
</sql>
<sql id="Blob_Column_List">
`value`
</sql>
<select id="selectByExampleWithBLOBs" parameterType="io.metersphere.base.domain.ApiEnvironmentRunningParamExample" resultMap="ResultMapWithBLOBs">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from api_environment_running_param
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByExample" parameterType="io.metersphere.base.domain.ApiEnvironmentRunningParamExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from api_environment_running_param
<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="ResultMapWithBLOBs">
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from api_environment_running_param
where id = #{id,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from api_environment_running_param
where id = #{id,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="io.metersphere.base.domain.ApiEnvironmentRunningParamExample">
delete from api_environment_running_param
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="io.metersphere.base.domain.ApiEnvironmentRunningParam">
insert into api_environment_running_param (id, api_enviroment_id, `key`,
create_time, update_time, create_user_id,
update_user_id, `value`)
values (#{id,jdbcType=VARCHAR}, #{apiEnviromentId,jdbcType=VARCHAR}, #{key,jdbcType=VARCHAR},
#{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{createUserId,jdbcType=VARCHAR},
#{updateUserId,jdbcType=VARCHAR}, #{value,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.ApiEnvironmentRunningParam">
insert into api_environment_running_param
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="apiEnviromentId != null">
api_enviroment_id,
</if>
<if test="key != null">
`key`,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="createUserId != null">
create_user_id,
</if>
<if test="updateUserId != null">
update_user_id,
</if>
<if test="value != null">
`value`,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="apiEnviromentId != null">
#{apiEnviromentId,jdbcType=VARCHAR},
</if>
<if test="key != null">
#{key,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=BIGINT},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=BIGINT},
</if>
<if test="createUserId != null">
#{createUserId,jdbcType=VARCHAR},
</if>
<if test="updateUserId != null">
#{updateUserId,jdbcType=VARCHAR},
</if>
<if test="value != null">
#{value,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.ApiEnvironmentRunningParamExample" resultType="java.lang.Long">
select count(*) from api_environment_running_param
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update api_environment_running_param
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=VARCHAR},
</if>
<if test="record.apiEnviromentId != null">
api_enviroment_id = #{record.apiEnviromentId,jdbcType=VARCHAR},
</if>
<if test="record.key != null">
`key` = #{record.key,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.createUserId != null">
create_user_id = #{record.createUserId,jdbcType=VARCHAR},
</if>
<if test="record.updateUserId != null">
update_user_id = #{record.updateUserId,jdbcType=VARCHAR},
</if>
<if test="record.value != null">
`value` = #{record.value,jdbcType=LONGVARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExampleWithBLOBs" parameterType="map">
update api_environment_running_param
set id = #{record.id,jdbcType=VARCHAR},
api_enviroment_id = #{record.apiEnviromentId,jdbcType=VARCHAR},
`key` = #{record.key,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT},
create_user_id = #{record.createUserId,jdbcType=VARCHAR},
update_user_id = #{record.updateUserId,jdbcType=VARCHAR},
`value` = #{record.value,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update api_environment_running_param
set id = #{record.id,jdbcType=VARCHAR},
api_enviroment_id = #{record.apiEnviromentId,jdbcType=VARCHAR},
`key` = #{record.key,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT},
update_time = #{record.updateTime,jdbcType=BIGINT},
create_user_id = #{record.createUserId,jdbcType=VARCHAR},
update_user_id = #{record.updateUserId,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.base.domain.ApiEnvironmentRunningParam">
update api_environment_running_param
<set>
<if test="apiEnviromentId != null">
api_enviroment_id = #{apiEnviromentId,jdbcType=VARCHAR},
</if>
<if test="key != null">
`key` = #{key,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=BIGINT},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=BIGINT},
</if>
<if test="createUserId != null">
create_user_id = #{createUserId,jdbcType=VARCHAR},
</if>
<if test="updateUserId != null">
update_user_id = #{updateUserId,jdbcType=VARCHAR},
</if>
<if test="value != null">
`value` = #{value,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="io.metersphere.base.domain.ApiEnvironmentRunningParam">
update api_environment_running_param
set api_enviroment_id = #{apiEnviromentId,jdbcType=VARCHAR},
`key` = #{key,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT},
create_user_id = #{createUserId,jdbcType=VARCHAR},
update_user_id = #{updateUserId,jdbcType=VARCHAR},
`value` = #{value,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.ApiEnvironmentRunningParam">
update api_environment_running_param
set api_enviroment_id = #{apiEnviromentId,jdbcType=VARCHAR},
`key` = #{key,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT},
update_time = #{updateTime,jdbcType=BIGINT},
create_user_id = #{createUserId,jdbcType=VARCHAR},
update_user_id = #{updateUserId,jdbcType=VARCHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -13,24 +13,6 @@ SET load_test_report.project_id = load_test.project_id;
UPDATE load_test_report JOIN load_test ON load_test.id = load_test_report.test_id
SET load_test_report.test_name = load_test.name;
-- api_environment_running_param
CREATE TABLE IF NOT EXISTS api_environment_running_param (
`id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`api_enviroment_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`value` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL,
`create_time` bigint(13) NULL DEFAULT NULL,
`update_time` bigint(13) NULL DEFAULT NULL,
`create_user_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`update_user_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE,
INDEX `api_enviroment_id` (`api_enviroment_id`) USING BTREE,
INDEX `key_api_enviroment_id` (`api_enviroment_id`, `key`) USING BTREE
) ENGINE = InnoDB
CHARACTER SET = utf8mb4
COLLATE = utf8mb4_general_ci
ROW_FORMAT = Dynamic;
-- schedule
alter table schedule
add config VARCHAR(500) null;

View File

@ -49,22 +49,10 @@
title: this.$t('api_test.request.processor.code_template_set_global_variable'),
value: 'props.put("variable_name", "variable_value")',
},
{
title: this.$t('api_test.request.processor.param_environment_get_global_variable'),
value: 'io.metersphere.api.jmeter.RunningParam.getParam(${__metersphere_evn_id},"key")',
},
{
title: this.$t('api_test.request.processor.param_environment_set_global_variable'),
value: 'io.metersphere.api.jmeter.RunningParam.setParam(${__metersphere_evn_id},"key","value")',
},
{
title: this.$t('api_test.request.processor.param_environment_delete_global_variable'),
value: 'io.metersphere.api.jmeter.RunningParam.deleteParam(${__metersphere_evn_id},"key")',
},
{
title: this.$t('api_test.request.processor.param_environment_show_global_variable'),
value: 'io.metersphere.api.jmeter.RunningParam.showParams(${__metersphere_evn_id})',
},
{
title: this.$t('api_test.request.processor.code_add_report_length'),
value: 'String report = ctx.getCurrentSampler().getRequestData();\n' +