This commit is contained in:
fit2-zhao 2021-01-06 14:19:11 +08:00
commit 5ec2e11ca5
23 changed files with 384 additions and 293 deletions

View File

@ -2,6 +2,7 @@ package io.metersphere.api.parse;
import io.metersphere.api.dto.ApiTestImportRequest;
import io.metersphere.api.dto.definition.ApiDefinitionResult;
import io.metersphere.api.dto.definition.ApiModuleDTO;
import io.metersphere.api.dto.definition.request.sampler.MsHTTPSamplerProxy;
import io.metersphere.api.dto.scenario.Body;
import io.metersphere.api.dto.scenario.KeyValue;
@ -11,6 +12,8 @@ import io.metersphere.api.dto.scenario.request.RequestType;
import io.metersphere.api.service.ApiModuleService;
import io.metersphere.base.domain.ApiModule;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.BeanUtils;
import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.commons.utils.SessionUtils;
import org.apache.commons.collections.CollectionUtils;
@ -60,6 +63,32 @@ public abstract class ApiImportAbstractParser implements ApiImportParser {
}
}
protected ApiModule getSelectModule(String moduleId) {
apiModuleService = CommonBeanFactory.getBean(ApiModuleService.class);
if (StringUtils.isNotBlank(moduleId)) {
ApiModule module = new ApiModule();
ApiModuleDTO moduleDTO = apiModuleService.getNode(moduleId);
BeanUtils.copyBean(module, moduleDTO);
return module;
}
return null;
}
protected ApiModule buildModule(ApiModule parentModule, String name, boolean isSaved) {
apiModuleService = CommonBeanFactory.getBean(ApiModuleService.class);
ApiModule module;
if (parentModule != null) {
module = apiModuleService.getNewModule(name, this.projectId, parentModule.getLevel() + 1);
module.setParentId(parentModule.getId());
} else {
module = apiModuleService.getNewModule(name, this.projectId, 1);
}
if (isSaved) {
createModule(module);
}
return module;
}
protected void createModule(ApiModule module) {
module.setProtocol(RequestType.HTTP);
List<ApiModule> apiModules = apiModuleService.selectSameModule(module);

View File

@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.Feature;
import io.metersphere.api.dto.ApiTestImportRequest;
import io.metersphere.api.dto.definition.ApiDefinitionResult;
import io.metersphere.api.dto.definition.ApiModuleDTO;
import io.metersphere.api.dto.definition.parse.ApiDefinitionImport;
import io.metersphere.api.dto.definition.request.sampler.MsHTTPSamplerProxy;
import io.metersphere.api.dto.scenario.Body;
@ -31,7 +32,7 @@ public class MsParser extends ApiImportAbstractParser {
if (testObject.get("projectName") != null) {
return parseMsFormat(testStr, request);
} else {
return parsePluginFormat(testObject, request.isSaved());
return parsePluginFormat(testObject, request);
}
}
@ -44,7 +45,7 @@ public class MsParser extends ApiImportAbstractParser {
if (StringUtils.isBlank(apiDefinition.getModulePath())) {
apiDefinition.setModuleId(null);
}
parseModule(apiDefinition, importRequest.isSaved());
parseModule(apiDefinition, importRequest);
apiDefinition.setId(id);
apiDefinition.setProjectId(this.projectId);
String request = apiDefinition.getRequest();
@ -55,16 +56,16 @@ public class MsParser extends ApiImportAbstractParser {
return apiDefinitionImport;
}
private ApiDefinitionImport parsePluginFormat(JSONObject testObject, boolean isSaved) {
private ApiDefinitionImport parsePluginFormat(JSONObject testObject, ApiTestImportRequest importRequest) {
List<ApiDefinitionResult> results = new ArrayList<>();
ApiDefinitionImport apiImport = new ApiDefinitionImport();
apiImport.setProtocol(RequestType.HTTP);
apiImport.setData(results);
testObject.keySet().forEach(tag -> {
ApiModule module = apiModuleService.getNewModule(tag, this.projectId, 1);
if (isSaved) {
createModule(module);
}
ApiModule parentModule = getSelectModule(importRequest.getModuleId());
ApiModule module = buildModule(parentModule, tag, importRequest.isSaved());
JSONObject requests = testObject.getJSONObject(tag);
requests.keySet().forEach(requestName -> {
@ -125,7 +126,7 @@ public class MsParser extends ApiImportAbstractParser {
}
private void parseModule(ApiDefinitionResult apiDefinition, Boolean isSaved) {
private void parseModule(ApiDefinitionResult apiDefinition, ApiTestImportRequest importRequest) {
String modulePath = apiDefinition.getModulePath();
if (StringUtils.isBlank(modulePath)) {
return;
@ -137,29 +138,14 @@ public class MsParser extends ApiImportAbstractParser {
modulePath = modulePath.substring(0, modulePath.length() - 1);
}
List<String> modules = Arrays.asList(modulePath.split("/"));
ApiModule parent = null;
ApiModule parent = getSelectModule(importRequest.getModuleId());
Iterator<String> iterator = modules.iterator();
while (iterator.hasNext()) {
String item = iterator.next();
parent = buildModule(item, parent, isSaved);
parent = buildModule(parent, item, importRequest.isSaved());
if (!iterator.hasNext()) {
apiDefinition.setModuleId(parent.getId());
}
}
}
private ApiModule buildModule(String name, ApiModule parentModule, boolean isSaved) {
apiModuleService = CommonBeanFactory.getBean(ApiModuleService.class);
ApiModule module;
if (parentModule != null) {
module = apiModuleService.getNewModule(name, this.projectId, parentModule.getLevel() + 1);
module.setParentId(parentModule.getId());
} else {
module = apiModuleService.getNewModule(name, this.projectId, 1);
}
if (isSaved) {
createModule(module);
}
return module;
}
}

View File

@ -9,11 +9,9 @@ import io.metersphere.api.dto.definition.request.sampler.MsHTTPSamplerProxy;
import io.metersphere.api.dto.parse.postman.*;
import io.metersphere.api.dto.scenario.Body;
import io.metersphere.api.dto.scenario.KeyValue;
import io.metersphere.api.service.ApiModuleService;
import io.metersphere.base.domain.ApiModule;
import io.metersphere.commons.constants.MsRequestBodyType;
import io.metersphere.commons.constants.PostmanRequestBodyMode;
import io.metersphere.commons.utils.CommonBeanFactory;
import org.apache.commons.lang3.StringUtils;
import java.io.InputStream;
@ -30,7 +28,7 @@ public class PostmanParser extends ApiImportAbstractParser {
List<PostmanKeyValue> variables = postmanCollection.getVariable();
ApiDefinitionImport apiImport = new ApiDefinitionImport();
List<ApiDefinitionResult> results = new ArrayList<>();
parseItem(postmanCollection.getItem(), variables, results, buildModule(postmanCollection.getInfo().getName(), null, request.isSaved()), request.isSaved());
parseItem(postmanCollection.getItem(), variables, results, buildModule(getSelectModule(request.getModuleId()), postmanCollection.getInfo().getName(), request.isSaved()), request.isSaved());
apiImport.setData(results);
return apiImport;
}
@ -39,7 +37,7 @@ public class PostmanParser extends ApiImportAbstractParser {
for (PostmanItem item : items) {
List<PostmanItem> childItems = item.getItem();
if (childItems != null) {
ApiModule module = buildModule(item.getName(), parentModule, isSaved);
ApiModule module = buildModule(parentModule, item.getName() , isSaved);
parseItem(childItems, variables, results, module, isSaved);
} else {
ApiDefinitionResult request = parsePostman(item);
@ -53,21 +51,6 @@ public class PostmanParser extends ApiImportAbstractParser {
}
}
private ApiModule buildModule(String name, ApiModule parentModule, boolean isSaved) {
apiModuleService = CommonBeanFactory.getBean(ApiModuleService.class);
ApiModule module;
if (parentModule != null) {
module = apiModuleService.getNewModule(name, this.projectId, parentModule.getLevel() + 1);
module.setParentId(parentModule.getId());
} else {
module = apiModuleService.getNewModule(name, this.projectId, 1);
}
if (isSaved) {
createModule(module);
}
return module;
}
private ApiDefinitionResult parsePostman(PostmanItem requestItem) {
PostmanRequest requestDesc = requestItem.getRequest();
if (requestDesc == null) {

View File

@ -11,10 +11,8 @@ import io.metersphere.api.dto.definition.response.HttpResponse;
import io.metersphere.api.dto.scenario.Body;
import io.metersphere.api.dto.scenario.KeyValue;
import io.metersphere.api.dto.scenario.request.RequestType;
import io.metersphere.api.service.ApiModuleService;
import io.metersphere.base.domain.ApiModule;
import io.metersphere.commons.constants.SwaggerParameterType;
import io.metersphere.commons.utils.CommonBeanFactory;
import io.swagger.models.*;
import io.swagger.models.parameters.*;
import io.swagger.models.properties.*;
@ -25,7 +23,7 @@ import org.apache.commons.lang3.StringUtils;
import java.io.InputStream;
import java.util.*;
public class Swagger2Parser extends ApiImportAbstractParser {
public class Swagger2Parser extends SwaggerAbstractParser {
private Map<String, Model> definitions = null;
@ -47,11 +45,11 @@ public class Swagger2Parser extends ApiImportAbstractParser {
ApiDefinitionImport definitionImport = new ApiDefinitionImport();
this.projectId = request.getProjectId();
definitionImport.setData(parseRequests(swagger, request.isSaved()));
definitionImport.setData(parseRequests(swagger, request));
return definitionImport;
}
private List<ApiDefinitionResult> parseRequests(Swagger swagger, boolean isSaved) {
private List<ApiDefinitionResult> parseRequests(Swagger swagger, ApiTestImportRequest importRequest) {
Map<String, Path> paths = swagger.getPaths();
Set<String> pathNames = paths.keySet();
@ -59,6 +57,8 @@ public class Swagger2Parser extends ApiImportAbstractParser {
List<ApiDefinitionResult> results = new ArrayList<>();
ApiModule parentNode = getSelectModule(importRequest.getModuleId());
for (String pathName : pathNames) {
Path path = paths.get(pathName);
Map<HttpMethod, Operation> operationMap = path.getOperationMap();
@ -70,7 +70,7 @@ public class Swagger2Parser extends ApiImportAbstractParser {
parseParameters(operation, request);
apiDefinition.setRequest(JSON.toJSONString(request));
apiDefinition.setResponse(JSON.toJSONString(parseResponse(operation.getResponses())));
buildModule(apiDefinition, operation, isSaved);
buildModule(parentNode, apiDefinition, operation.getTags(), importRequest.isSaved());
results.add(apiDefinition);
}
}
@ -79,20 +79,6 @@ public class Swagger2Parser extends ApiImportAbstractParser {
return results;
}
private void buildModule(ApiDefinitionResult apiDefinition, Operation operation, boolean isSaved) {
List<String> tags = operation.getTags();
if (tags != null) {
tags.forEach(tag -> {
apiModuleService = CommonBeanFactory.getBean(ApiModuleService.class);
ApiModule module = apiModuleService.getNewModule(tag, this.projectId, 1);
if (isSaved) {
createModule(module);
}
apiDefinition.setModuleId(module.getId());
});
}
}
private ApiDefinitionResult buildApiDefinition(String id, Operation operation, String path, String method) {
String name = "";
if (StringUtils.isNotBlank(operation.getSummary())) {

View File

@ -11,10 +11,8 @@ import io.metersphere.api.dto.definition.response.HttpResponse;
import io.metersphere.api.dto.scenario.Body;
import io.metersphere.api.dto.scenario.KeyValue;
import io.metersphere.api.dto.scenario.request.RequestType;
import io.metersphere.api.service.ApiModuleService;
import io.metersphere.base.domain.ApiModule;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.commons.utils.XMLUtils;
import io.swagger.parser.OpenAPIParser;
@ -34,7 +32,7 @@ import java.io.InputStream;
import java.util.*;
public class Swagger3Parser extends ApiImportAbstractParser {
public class Swagger3Parser extends SwaggerAbstractParser {
private Components components;
@ -67,11 +65,11 @@ public class Swagger3Parser extends ApiImportAbstractParser {
ApiDefinitionImport definitionImport = new ApiDefinitionImport();
this.projectId = request.getProjectId();
definitionImport.setData(parseRequests(openAPI, request.isSaved()));
definitionImport.setData(parseRequests(openAPI, request));
return definitionImport;
}
private List<ApiDefinitionResult> parseRequests(OpenAPI openAPI, boolean isSaved) {
private List<ApiDefinitionResult> parseRequests(OpenAPI openAPI, ApiTestImportRequest importRequest) {
Paths paths = openAPI.getPaths();
Set<String> pathNames = paths.keySet();
@ -80,6 +78,8 @@ public class Swagger3Parser extends ApiImportAbstractParser {
List<ApiDefinitionResult> results = new ArrayList<>();
ApiModule parentNode = getSelectModule(importRequest.getModuleId());
for (String pathName : pathNames) {
PathItem pathItem = paths.get(pathName);
@ -102,7 +102,7 @@ public class Swagger3Parser extends ApiImportAbstractParser {
parseRequestBody(operation.getRequestBody(), request.getBody());
apiDefinition.setRequest(JSON.toJSONString(request));
apiDefinition.setResponse(JSON.toJSONString(parseResponse(operation.getResponses())));
buildModule(apiDefinition, operation, isSaved);
buildModule(parentNode, apiDefinition, operation.getTags(), importRequest.isSaved());
results.add(apiDefinition);
}
}
@ -111,20 +111,6 @@ public class Swagger3Parser extends ApiImportAbstractParser {
return results;
}
private void buildModule(ApiDefinitionResult apiDefinition, Operation operation, boolean isSaved) {
List<String> tags = operation.getTags();
if (tags != null) {
tags.forEach(tag -> {
apiModuleService = CommonBeanFactory.getBean(ApiModuleService.class);
ApiModule module = apiModuleService.getNewModule(tag, this.projectId, 1);
if (isSaved) {
createModule(module);
}
apiDefinition.setModuleId(module.getId());
});
}
}
private ApiDefinitionResult buildApiDefinition(String id, Operation operation, String path, String method) {
String name = "";
if (StringUtils.isNotBlank(operation.getSummary())) {

View File

@ -0,0 +1,19 @@
package io.metersphere.api.parse;
import io.metersphere.api.dto.definition.ApiDefinitionResult;
import io.metersphere.base.domain.ApiModule;
import java.util.List;
public abstract class SwaggerAbstractParser extends ApiImportAbstractParser {
protected void buildModule(ApiModule parentModule, ApiDefinitionResult apiDefinition, List<String> tags, boolean isSaved) {
if (tags != null) {
tags.forEach(tag -> {
ApiModule module = buildModule(parentModule, tag, isSaved);
apiDefinition.setModuleId(module.getId());
});
}
}
}

View File

@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import io.metersphere.api.dto.APIReportResult;
import io.metersphere.api.dto.ApiTestImportRequest;
import io.metersphere.api.dto.automation.ApiScenarioDTO;
import io.metersphere.api.dto.automation.ApiScenarioRequest;
import io.metersphere.api.dto.automation.ReferenceDTO;
import io.metersphere.api.dto.datacount.ApiDataCountResult;
@ -18,6 +17,7 @@ import io.metersphere.api.parse.ApiImportParserFactory;
import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.ApiDefinitionMapper;
import io.metersphere.base.mapper.ApiTestFileMapper;
import io.metersphere.base.mapper.ProjectMapper;
import io.metersphere.base.mapper.ext.ExtApiDefinitionExecResultMapper;
import io.metersphere.base.mapper.ext.ExtApiDefinitionMapper;
import io.metersphere.base.mapper.ext.ExtApiScenarioMapper;
@ -71,6 +71,8 @@ public class ApiDefinitionService {
private ExtApiScenarioMapper extApiScenarioMapper;
@Resource
private ExtTestPlanMapper extTestPlanMapper;
@Resource
private ProjectMapper projectMapper;
private static Cache cache = Cache.newHardMemoryCache(0, 3600 * 24);
@ -178,7 +180,8 @@ public class ApiDefinitionService {
example.createCriteria().andMethodEqualTo(request.getMethod()).andStatusNotEqualTo("Trash")
.andProtocolEqualTo(request.getProtocol()).andPathEqualTo(request.getPath())
.andProjectIdEqualTo(request.getProjectId()).andIdNotEqualTo(request.getId());
if (apiDefinitionMapper.countByExample(example) > 0) {
Project project = projectMapper.selectByPrimaryKey(request.getProjectId());
if (apiDefinitionMapper.countByExample(example) > 0 && !project.getRepeatable()) {
MSException.throwException(Translator.get("api_definition_url_not_repeating"));
}
} else {
@ -439,8 +442,8 @@ public class ApiDefinitionService {
public void editApiByParam(ApiBatchRequest request) {
List<String> ids = request.getIds();
if(request.isSelectAllDate()){
ids = this.getAllApiIdsByFontedSelect(request.getFilters(),request.getName(),request.getModuleIds(),request.getProjectId(),request.getUnSelectIds());
if (request.isSelectAllDate()) {
ids = this.getAllApiIdsByFontedSelect(request.getFilters(), request.getName(), request.getModuleIds(), request.getProjectId(), request.getUnSelectIds());
}
//name在这里只是查询参数
request.setName(null);
@ -503,15 +506,15 @@ public class ApiDefinitionService {
public void deleteByParams(ApiDefinitionBatchProcessingRequest request) {
List<String> apiIds = request.getDataIds();
if(request.isSelectAllDate()){
apiIds = this.getAllApiIdsByFontedSelect(request.getFilters(),request.getName(),request.getModuleIds(),request.getProjectId(),request.getUnSelectIds());
if (request.isSelectAllDate()) {
apiIds = this.getAllApiIdsByFontedSelect(request.getFilters(), request.getName(), request.getModuleIds(), request.getProjectId(), request.getUnSelectIds());
}
ApiDefinitionExample example = new ApiDefinitionExample();
example.createCriteria().andIdIn(apiIds);
apiDefinitionMapper.deleteByExample(example);
}
private List<String> getAllApiIdsByFontedSelect(List<String> filter,String name,List<String> moduleIds,String projectId,List<String>unSelectIds) {
private List<String> getAllApiIdsByFontedSelect(List<String> filter, String name, List<String> moduleIds, String projectId, List<String> unSelectIds) {
ApiDefinitionRequest request = new ApiDefinitionRequest();
request.setFilters(filter);
request.setName(name);
@ -529,8 +532,8 @@ public class ApiDefinitionService {
public void removeToGcByParams(ApiDefinitionBatchProcessingRequest request) {
List<String> apiIds = request.getDataIds();
if(request.isSelectAllDate()){
apiIds = this.getAllApiIdsByFontedSelect(request.getFilters(),request.getName(),request.getModuleIds(),request.getProjectId(),request.getUnSelectIds());
if (request.isSelectAllDate()) {
apiIds = this.getAllApiIdsByFontedSelect(request.getFilters(), request.getName(), request.getModuleIds(), request.getProjectId(), request.getUnSelectIds());
}
extApiDefinitionMapper.removeToGc(apiIds);
}

View File

@ -1,8 +1,9 @@
package io.metersphere.base.domain;
import java.io.Serializable;
import lombok.Data;
import java.io.Serializable;
@Data
public class Project implements Serializable {
private String id;
@ -23,5 +24,7 @@ public class Project implements Serializable {
private String zentaoId;
private Boolean repeatable;
private static final long serialVersionUID = 1L;
}

View File

@ -713,6 +713,66 @@ public class ProjectExample {
addCriterion("zentao_id not between", value1, value2, "zentaoId");
return (Criteria) this;
}
public Criteria andRepeatableIsNull() {
addCriterion("`repeatable` is null");
return (Criteria) this;
}
public Criteria andRepeatableIsNotNull() {
addCriterion("`repeatable` is not null");
return (Criteria) this;
}
public Criteria andRepeatableEqualTo(Boolean value) {
addCriterion("`repeatable` =", value, "repeatable");
return (Criteria) this;
}
public Criteria andRepeatableNotEqualTo(Boolean value) {
addCriterion("`repeatable` <>", value, "repeatable");
return (Criteria) this;
}
public Criteria andRepeatableGreaterThan(Boolean value) {
addCriterion("`repeatable` >", value, "repeatable");
return (Criteria) this;
}
public Criteria andRepeatableGreaterThanOrEqualTo(Boolean value) {
addCriterion("`repeatable` >=", value, "repeatable");
return (Criteria) this;
}
public Criteria andRepeatableLessThan(Boolean value) {
addCriterion("`repeatable` <", value, "repeatable");
return (Criteria) this;
}
public Criteria andRepeatableLessThanOrEqualTo(Boolean value) {
addCriterion("`repeatable` <=", value, "repeatable");
return (Criteria) this;
}
public Criteria andRepeatableIn(List<Boolean> values) {
addCriterion("`repeatable` in", values, "repeatable");
return (Criteria) this;
}
public Criteria andRepeatableNotIn(List<Boolean> values) {
addCriterion("`repeatable` not in", values, "repeatable");
return (Criteria) this;
}
public Criteria andRepeatableBetween(Boolean value1, Boolean value2) {
addCriterion("`repeatable` between", value1, value2, "repeatable");
return (Criteria) this;
}
public Criteria andRepeatableNotBetween(Boolean value1, Boolean value2) {
addCriterion("`repeatable` not between", value1, value2, "repeatable");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {

View File

@ -11,6 +11,7 @@
<result column="tapd_id" jdbcType="VARCHAR" property="tapdId" />
<result column="jira_key" jdbcType="VARCHAR" property="jiraKey" />
<result column="zentao_id" jdbcType="VARCHAR" property="zentaoId" />
<result column="repeatable" jdbcType="BIT" property="repeatable" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
@ -72,7 +73,7 @@
</sql>
<sql id="Base_Column_List">
id, workspace_id, `name`, description, create_time, update_time, tapd_id, jira_key,
zentao_id
zentao_id, `repeatable`
</sql>
<select id="selectByExample" parameterType="io.metersphere.base.domain.ProjectExample" resultMap="BaseResultMap">
select
@ -107,12 +108,12 @@
<insert id="insert" parameterType="io.metersphere.base.domain.Project">
insert into project (id, workspace_id, `name`,
description, create_time, update_time,
tapd_id, jira_key, zentao_id
)
tapd_id, jira_key, zentao_id,
`repeatable`)
values (#{id,jdbcType=VARCHAR}, #{workspaceId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
#{description,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT},
#{tapdId,jdbcType=VARCHAR}, #{jiraKey,jdbcType=VARCHAR}, #{zentaoId,jdbcType=VARCHAR}
)
#{tapdId,jdbcType=VARCHAR}, #{jiraKey,jdbcType=VARCHAR}, #{zentaoId,jdbcType=VARCHAR},
#{repeatable,jdbcType=BIT})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.Project">
insert into project
@ -144,6 +145,9 @@
<if test="zentaoId != null">
zentao_id,
</if>
<if test="repeatable != null">
`repeatable`,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
@ -173,6 +177,9 @@
<if test="zentaoId != null">
#{zentaoId,jdbcType=VARCHAR},
</if>
<if test="repeatable != null">
#{repeatable,jdbcType=BIT},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.ProjectExample" resultType="java.lang.Long">
@ -211,6 +218,9 @@
<if test="record.zentaoId != null">
zentao_id = #{record.zentaoId,jdbcType=VARCHAR},
</if>
<if test="record.repeatable != null">
`repeatable` = #{record.repeatable,jdbcType=BIT},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -226,7 +236,8 @@
update_time = #{record.updateTime,jdbcType=BIGINT},
tapd_id = #{record.tapdId,jdbcType=VARCHAR},
jira_key = #{record.jiraKey,jdbcType=VARCHAR},
zentao_id = #{record.zentaoId,jdbcType=VARCHAR}
zentao_id = #{record.zentaoId,jdbcType=VARCHAR},
`repeatable` = #{record.repeatable,jdbcType=BIT}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -258,6 +269,9 @@
<if test="zentaoId != null">
zentao_id = #{zentaoId,jdbcType=VARCHAR},
</if>
<if test="repeatable != null">
`repeatable` = #{repeatable,jdbcType=BIT},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
@ -270,7 +284,8 @@
update_time = #{updateTime,jdbcType=BIGINT},
tapd_id = #{tapdId,jdbcType=VARCHAR},
jira_key = #{jiraKey,jdbcType=VARCHAR},
zentao_id = #{zentaoId,jdbcType=VARCHAR}
zentao_id = #{zentaoId,jdbcType=VARCHAR},
`repeatable` = #{repeatable,jdbcType=BIT}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -4,7 +4,7 @@
<select id="getProjectWithWorkspace" resultType="io.metersphere.dto.ProjectDTO">
select p.id, p.workspace_id, p.name, p.description, p.update_time,
p.create_time, w.id as workspaceId, w.name as workspaceName, p.tapd_id, p.jira_key, p.zentao_id
p.create_time, w.id as workspaceId, w.name as workspaceName, p.tapd_id, p.jira_key, p.zentao_id,p.repeatable
from project p
join workspace w on p.workspace_id = w.id
<where>

View File

@ -17,4 +17,6 @@ public class ProjectDTO {
private String tapdId;
private String jiraKey;
private String zentaoId;
private boolean repeatable;
}

View File

@ -13,7 +13,7 @@ import javax.validation.constraints.Pattern;
public class TestCaseExcelDataCn extends TestCaseExcelData {
@NotBlank(message = "{cannot_be_null}")
@Length(max = 50)
@Length(max = 255)
@ExcelProperty("用例名称")
private String name;

View File

@ -13,7 +13,7 @@ import javax.validation.constraints.Pattern;
public class TestCaseExcelDataTw extends TestCaseExcelData {
@NotBlank(message = "{cannot_be_null}")
@Length(max = 50)
@Length(max = 255)
@ExcelProperty("用例名稱")
private String name;

View File

@ -14,7 +14,7 @@ import javax.validation.constraints.Pattern;
public class TestCaseExcelDataUs extends TestCaseExcelData {
@NotBlank(message = "{cannot_be_null}")
@Length(max = 50)
@Length(max = 255)
@ExcelProperty("Name")
private String name;

View File

@ -1,5 +1,5 @@
alter table test_plan add project_id varchar(50) null comment '测试计划所属项目';
ALTER TABLE api_test_case MODIFY COLUMN name varchar(255) NOT NULL COMMENT 'Test name';
ALTER TABLE api_test_case MODIFY COLUMN name varchar(255) NOT NULL COMMENT 'Test case name';
DROP PROCEDURE IF EXISTS test_cursor;
DELIMITER //

View File

@ -0,0 +1 @@
ALTER TABLE project ADD repeatable tinyint(1) DEFAULT null;

View File

@ -0,0 +1 @@
ALTER TABLE test_case MODIFY COLUMN name varchar(255) NOT NULL COMMENT 'Test case name';

View File

@ -64,7 +64,7 @@
<!--要生成的数据库表 -->
<table tableName="api_scenario"/>
<table tableName="project"/>
<!--<table tableName="test_plan_api_scenario"/>-->
<!--<table tableName="test_plan"/>-->
<!--<table tableName="api_scenario_report"/>-->

View File

@ -3,7 +3,12 @@
<el-card class="table-card">
<template v-slot:header>
<ms-table-header :is-tester-permission="true" :condition.sync="condition" @search="search" @create="create"
:create-tip="btnTips" :title="$t('commons.project')"/>
:create-tip="btnTips" :title="$t('commons.project')">
<template v-slot:button>
<ms-table-button :is-tester-permission="true" icon="el-icon-box"
:content="$t('api_test.jar_config.title')" @click="openJarConfig"/>
</template>
</ms-table-header>
</template>
<el-table border class="adjust-table" :data="items" style="width: 100%" @sort-change="sort">
<el-table-column prop="name" :label="$t('commons.name')" width="250" show-overflow-tooltip/>
@ -48,7 +53,7 @@
</el-card>
<el-dialog :close-on-click-modal="false" :title="title" :visible.sync="createVisible" destroy-on-close @close="handleClose">
<el-form :model="form" :rules="rules" ref="form" label-position="right" label-width="100px" size="small">
<el-form :model="form" :rules="rules" ref="form" label-position="right" label-width="140px" size="small">
<el-form-item :label="$t('commons.name')" prop="name">
<el-input v-model="form.name" autocomplete="off"></el-input>
</el-form-item>
@ -64,6 +69,9 @@
<el-form-item :label="$t('project.zentao_id')" v-if="zentao">
<el-input v-model="form.zentaoId" autocomplete="off"></el-input>
</el-form-item>
<el-form-item :label="$t('project.repeatable')" prop="repeatable">
<el-switch v-model="form.repeatable"></el-switch>
</el-form-item>
</el-form>
<template v-slot:footer>
<div class="dialog-footer">
@ -78,28 +86,33 @@
<api-environment-config ref="environmentConfig"/>
<ms-jar-config ref="jarConfig"/>
</div>
</template>
<script>
import MsCreateBox from "../CreateBox";
import {Message} from "element-ui";
import MsTablePagination from "../../common/pagination/TablePagination";
import MsTableHeader from "../../common/components/MsTableHeader";
import MsTableOperator from "../../common/components/MsTableOperator";
import MsDialogFooter from "../../common/components/MsDialogFooter";
import {_sort, getCurrentProjectID, getCurrentUser, listenGoBack, removeGoBackListener} from "@/common/js/utils";
import MsContainer from "../../common/components/MsContainer";
import MsMainContainer from "../../common/components/MsMainContainer";
import MsDeleteConfirm from "../../common/components/MsDeleteConfirm";
import MsTableOperatorButton from "../../common/components/MsTableOperatorButton";
import ApiEnvironmentConfig from "../../api/test/components/ApiEnvironmentConfig";
import TemplateComponent from "../../track/plan/view/comonents/report/TemplateComponent/TemplateComponent";
import {PROJECT_ID} from "@/common/js/constants";
export default {
import MsCreateBox from "../CreateBox";
import {Message} from "element-ui";
import MsTablePagination from "../../common/pagination/TablePagination";
import MsTableHeader from "../../common/components/MsTableHeader";
import MsTableOperator from "../../common/components/MsTableOperator";
import MsDialogFooter from "../../common/components/MsDialogFooter";
import {_sort, getCurrentProjectID, getCurrentUser, listenGoBack, removeGoBackListener} from "@/common/js/utils";
import MsContainer from "../../common/components/MsContainer";
import MsMainContainer from "../../common/components/MsMainContainer";
import MsDeleteConfirm from "../../common/components/MsDeleteConfirm";
import MsTableOperatorButton from "../../common/components/MsTableOperatorButton";
import ApiEnvironmentConfig from "../../api/test/components/ApiEnvironmentConfig";
import TemplateComponent from "../../track/plan/view/comonents/report/TemplateComponent/TemplateComponent";
import {PROJECT_ID} from "@/common/js/constants";
import MsJarConfig from "../../api/test/components/jar/JarConfig";
import MsTableButton from "../../common/components/MsTableButton";
export default {
name: "MsProject",
components: {
MsTableButton,
MsJarConfig,
TemplateComponent,
ApiEnvironmentConfig,
MsTableOperatorButton,
@ -188,7 +201,6 @@ export default {
}
});
},
submit(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
@ -206,6 +218,9 @@ export default {
}
});
},
openJarConfig() {
this.$refs.jarConfig.open();
},
handleDelete(project) {
this.$refs.deleteConfirm.open(project);
},
@ -267,7 +282,7 @@ export default {
beforeDestroy() {
document.removeEventListener('keydown', this.handleEvent);
}
}
}
</script>
<style scoped>
@ -275,5 +290,4 @@ export default {
margin: 0 0;
font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", Arial, sans-serif;
}
</style>

View File

@ -308,7 +308,8 @@ export default {
zentao_id: 'Zentao Project ID',
manager: 'Manager',
no_data: 'No Data',
select: 'Select'
select: 'Select',
repeatable: 'Interface definition URL repeatable'
},
member: {
create: 'Create',

View File

@ -305,7 +305,8 @@ export default {
zentao_id: 'Zentao项目ID',
manager: '项目管理',
no_data: '无数据',
select: '选择项目'
select: '选择项目',
repeatable: '接口定义URL可重复'
},
member: {
create: '添加成员',

View File

@ -305,7 +305,8 @@ export default {
zentao_id: 'Zentao項目ID',
manager: '項目管理',
no_data: '無數據',
select: '選擇項目'
select: '選擇項目',
repeatable: '接口定义URL可重复'
},
member: {
create: '添加成員',