refactor(项目设置): 优化环境http配置参数

This commit is contained in:
AgAngle 2024-02-05 20:24:05 +08:00 committed by 刘瑞斌
parent 1cc659f0e9
commit 174d2f00d2
5 changed files with 110 additions and 37 deletions

View File

@ -2,7 +2,7 @@ package io.metersphere.project.api.assertion;
import com.fasterxml.jackson.annotation.JsonTypeName;
import io.metersphere.project.api.KeyValueParam;
import io.metersphere.project.api.processor.ScriptProcessor;
import io.metersphere.project.constants.ScriptLanguageType;
import lombok.Data;
import java.util.List;
@ -21,7 +21,7 @@ public class MsScriptAssertion extends MsAssertion {
private String script;
/**
* 脚本语言
* @see ScriptProcessor.ScriptLanguageType
* {@link ScriptLanguageType}
*/
private String scriptLanguage;
/**

View File

@ -1,16 +0,0 @@
package io.metersphere.project.dto.environment;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
public class KeyValue {
@Schema(description = "参数名")
private String name;
@Schema(description = "参数值")
private String value;
@Schema(description = "是否启用")
private Boolean enable = true;
}

View File

@ -1,36 +1,54 @@
package io.metersphere.project.dto.environment.http;
import io.metersphere.project.dto.environment.KeyValue;
import io.metersphere.project.api.KeyValueEnableParam;
import io.metersphere.system.valid.EnumValue;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.Valid;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@Data
public class HttpConfig implements Serializable {
@Schema(description = "环境域名")
private String url;
@Schema(description = "启用条件 NONE/MODULE/PATH")
private String type = "NONE";
@Schema(description = "启用条件为PATH时需要填写的路径/ key为equal时value为路径key为contain时value为包含的路径")
private List<KeyValue> details;
@Schema(description = "启用条件为MODULE时需要模块的id")
private List<String> moduleIds;
@Schema(description = "请求头")
private List<KeyValueEnableParam> headers;
@Schema(description = "浏览器 选项为chrome/firefox")
private String browser;
private String description;
@Serial
private static final long serialVersionUID = 1L;
public HttpConfig() {
this.headers = List.of(new KeyValueEnableParam());
}
@Schema(description = "环境域名")
private String url;
/**
* 启用条件
* {@link HttpConfigMatchType}
*/
@Schema(description = "启用条件 NONE/MODULE/PATH")
@EnumValue(enumClass = HttpConfigMatchType.class)
private String type = HttpConfigMatchType.NONE.name();
@Valid
@Schema(description = "路径匹配规则")
private HttpConfigPathMatchRule pathMatchRule = new HttpConfigPathMatchRule();
@Valid
@Schema(description = "模块匹配规则")
private HttpConfigModuleMatchRule moduleMatchRule = new HttpConfigModuleMatchRule();
@Schema(description = "请求头")
private List<@Valid KeyValueEnableParam> headers = new ArrayList<>(0);
/**
* 启用条件匹配类型
*/
public enum HttpConfigMatchType {
/**
* 路径匹配
*/
PATH,
/**
* 模块匹配
*/
MODULE,
/**
* 无条件
*/
NONE
}
}

View File

@ -0,0 +1,32 @@
package io.metersphere.project.dto.environment.http;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.Valid;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* @Author: jianxing
* @CreateTime: 2024-02-05 18:53
*/
@Data
public class HttpConfigModuleMatchRule implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
@Schema(description = "选中模块")
@Valid
private List<SelectModule> modules = new ArrayList<>(0);
@Data
public class SelectModule {
@Schema(description = "模块ID")
private String moduleId;
@Schema(description = "是否包含新增子模块")
private Boolean containChildModule = false;
}
}

View File

@ -0,0 +1,39 @@
package io.metersphere.project.dto.environment.http;
import io.metersphere.system.valid.EnumValue;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
/**
* @Author: jianxing
* @CreateTime: 2024-02-05 18:53
*/
@Data
public class HttpConfigPathMatchRule implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 匹配规则 CONTAINS/EQUALS
* {@link MatchRuleCondition}
*/
@Schema(description = "匹配条件 CONTAINS/EQUALS")
@EnumValue(enumClass = MatchRuleCondition.class)
private String condition;
@Schema(description = "路径")
private String path;
public enum MatchRuleCondition {
/**
* 包含
*/
CONTAINS,
/**
* 等于
*/
EQUALS
}
}