feat(我的工作台): 接口定义同步功能

--user=郭雨琦
This commit is contained in:
guoyuqi 2022-05-18 19:32:00 +08:00 committed by f2c-ci-robot[bot]
parent 7ffa6a18e2
commit 8592800998
27 changed files with 468 additions and 43 deletions

View File

@ -28,4 +28,6 @@ public class ApiDefinitionRequest extends BaseQueryRequest {
// 测试计划是否允许重复
private boolean repeatCase;
//是否进入待更新列表
private Boolean toBeUpdated;
}

View File

@ -0,0 +1,35 @@
package io.metersphere.api.dto.definition;
import lombok.*;
import java.util.List;
@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ApiSyncCaseRequest {
private Boolean protocol;
private Boolean method;
private Boolean path;
private Boolean headers;
private Boolean query;
private Boolean rest;
private Boolean body;
private Boolean delNotSame;
private Boolean runError;
private Boolean unRun;
private List<String> ids;
}

View File

@ -37,6 +37,10 @@ public class ApiTestCaseRequest extends BaseQueryRequest {
* 检查待更新的近三天有更新的或者状态为error的
*/
private boolean toUpdate;
/**
* 是否进入待更新列表
*/
private Boolean toBeUpdated;
/**
* 是否需要查询环境字段
*/

View File

@ -68,4 +68,7 @@ public class SaveApiDefinitionRequest {
private boolean newVersionMock;
// 复制的请求Id
private String sourceId;
//是否进入待更新列表
private Boolean toBeUpdated;
}

View File

@ -20,6 +20,7 @@ import io.metersphere.api.service.ApiTestEnvironmentService;
import io.metersphere.api.service.TcpApiParamService;
import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.ApiDefinitionExecResultMapper;
import io.metersphere.base.mapper.ApiDefinitionMapper;
import io.metersphere.base.mapper.ApiTestCaseMapper;
import io.metersphere.base.mapper.TestPlanApiCaseMapper;
import io.metersphere.base.mapper.ext.ExtApiTestCaseMapper;
@ -54,6 +55,8 @@ public class ApiExecuteService {
@Resource
private ApiDefinitionExecResultMapper apiDefinitionExecResultMapper;
@Resource
private ApiDefinitionMapper apiDefinitionMapper;
@Resource
private TestPlanApiCaseMapper testPlanApiCaseMapper;
@Resource
private ApiTestEnvironmentService environmentService;
@ -129,6 +132,11 @@ public class ApiExecuteService {
ApiTestCaseWithBLOBs caseWithBLOBs = apiTestCaseMapper.selectByPrimaryKey(request.getCaseId());
caseWithBLOBs.setStatus("error");
apiTestCaseMapper.updateByPrimaryKey(caseWithBLOBs);
ApiDefinitionWithBLOBs apiDefinitionWithBLOBs = apiDefinitionMapper.selectByPrimaryKey(caseWithBLOBs.getApiDefinitionId());
if (apiDefinitionWithBLOBs.getProtocol().equals("HTTP")) {
apiDefinitionWithBLOBs.setToBeUpdated(true);
apiDefinitionMapper.updateByPrimaryKey(apiDefinitionWithBLOBs);
}
}
LogUtil.error(ex.getMessage(), ex);
}

View File

@ -3,6 +3,9 @@ package io.metersphere.api.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.Feature;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import io.metersphere.api.dto.APIReportResult;
@ -342,6 +345,12 @@ public class ApiDefinitionService {
if (StringUtils.equals(request.getProtocol(), "DUBBO")) {
request.setMethod("dubbo://");
}
// 存储依赖关系
ApiDefinitionSyncService apiDefinitionSyncService = CommonBeanFactory.getBean(ApiDefinitionSyncService.class);
if (apiDefinitionSyncService != null) {
apiDefinitionSyncService.syncApi(request);
}
ApiDefinitionWithBLOBs returnModel = updateTest(request);
MockConfigService mockConfigService = CommonBeanFactory.getBean(MockConfigService.class);
mockConfigService.updateMockReturnMsgByApi(returnModel);
@ -535,30 +544,30 @@ public class ApiDefinitionService {
}
}
private List<ApiDefinition> getSameRequest(SaveApiDefinitionRequest request) {
private List<ApiDefinitionWithBLOBs> getSameRequest(SaveApiDefinitionRequest request) {
ApiDefinitionExample example = new ApiDefinitionExample();
if (request.getProtocol().equals(RequestType.HTTP)) {
example.createCriteria().andMethodEqualTo(request.getMethod()).andStatusNotEqualTo("Trash")
.andPathEqualTo(request.getPath())
.andProjectIdEqualTo(request.getProjectId()).andIdNotEqualTo(request.getId());
return apiDefinitionMapper.selectByExample(example);
return apiDefinitionMapper.selectByExampleWithBLOBs(example);
} else {
example.createCriteria().andProtocolEqualTo(request.getProtocol()).andStatusNotEqualTo("Trash")
.andNameEqualTo(request.getName()).andProjectIdEqualTo(request.getProjectId())
.andIdNotEqualTo(request.getId());
return apiDefinitionMapper.selectByExample(example);
return apiDefinitionMapper.selectByExampleWithBLOBs(example);
}
}
private List<ApiDefinition> getSameRequestById(String id, String projectId) {
private List<ApiDefinitionWithBLOBs> getSameRequestById(String id, String projectId) {
ApiDefinitionExample example = new ApiDefinitionExample();
example.createCriteria().andStatusNotEqualTo("Trash")
.andProjectIdEqualTo(projectId)
.andIdEqualTo(id);
return apiDefinitionMapper.selectByExample(example);
return apiDefinitionMapper.selectByExampleWithBLOBs(example);
}
private List<ApiDefinition> getSameRequestWithName(SaveApiDefinitionRequest request) {
private List<ApiDefinitionWithBLOBs> getSameRequestWithName(SaveApiDefinitionRequest request) {
ApiDefinitionExample example = new ApiDefinitionExample();
if (request.getProtocol().equals(RequestType.HTTP)) {
example.createCriteria()
@ -576,7 +585,7 @@ public class ApiDefinitionService {
.andIdNotEqualTo(request.getId());
}
return apiDefinitionMapper.selectByExample(example);
return apiDefinitionMapper.selectByExampleWithBLOBs(example);
}
@ -606,6 +615,9 @@ public class ApiDefinitionService {
test.setEnvironmentId(request.getEnvironmentId());
test.setUserId(request.getUserId());
test.setRemark(request.getRemark());
if (request.getToBeUpdated() != null && request.getToBeUpdated()) {
test.setToBeUpdated(request.getToBeUpdated());
}
if (StringUtils.isNotEmpty(request.getTags()) && !StringUtils.equals(request.getTags(), "[]")) {
test.setTags(request.getTags());
} else {
@ -637,7 +649,11 @@ public class ApiDefinitionService {
if (StringUtils.equals(test.getProtocol(), "HTTP")) {
List<String> ids = new ArrayList<>();
ids.add(request.getId());
apiTestCaseService.updateByApiDefinitionId(ids, test.getPath(), test.getMethod(), test.getProtocol());
Boolean toBeUpdated = null;
if(request.getToBeUpdated()!=null) {
toBeUpdated = request.getToBeUpdated();
}
apiTestCaseService.updateByApiDefinitionId(ids, test.getPath(), test.getMethod(), test.getProtocol(),toBeUpdated);
}
//
ApiDefinitionWithBLOBs result = apiDefinitionMapper.selectByPrimaryKey(test.getId());
@ -801,7 +817,7 @@ public class ApiDefinitionService {
}
apiDefinition.setDescription(apiDefinition.getDescription());
List<ApiDefinition> sameRequest;
List<ApiDefinitionWithBLOBs> sameRequest;
if (repeatable == null || !repeatable) {
sameRequest = getSameRequest(saveReq);
} else {
@ -868,7 +884,7 @@ public class ApiDefinitionService {
return order;
}
private void _importCreate(List<ApiDefinition> sameRequest, ApiDefinitionMapper batchMapper, ApiDefinitionWithBLOBs apiDefinition,
private void _importCreate(List<ApiDefinitionWithBLOBs> sameRequest, ApiDefinitionMapper batchMapper, ApiDefinitionWithBLOBs apiDefinition,
ApiTestCaseMapper apiTestCaseMapper, ExtApiDefinitionMapper extApiDefinitionMapper,
ApiTestImportRequest apiTestImportRequest, List<ApiTestCaseWithBLOBs> cases, List<MockConfigImportDTO> mocks) {
String originId = apiDefinition.getId();
@ -905,7 +921,7 @@ public class ApiDefinitionService {
if (StringUtils.isEmpty(apiTestImportRequest.getUpdateVersionId())) {
apiTestImportRequest.setUpdateVersionId(apiTestImportRequest.getDefaultVersion());
}
Optional<ApiDefinition> apiOp = sameRequest.stream()
Optional<ApiDefinitionWithBLOBs> apiOp = sameRequest.stream()
.filter(api -> StringUtils.equals(api.getVersionId(), apiTestImportRequest.getUpdateVersionId()))
.findFirst();
@ -920,7 +936,7 @@ public class ApiDefinitionService {
}
batchMapper.insert(apiDefinition);
} else {
ApiDefinition existApi = apiOp.get();
ApiDefinitionWithBLOBs existApi = apiOp.get();
apiDefinition.setStatus(existApi.getStatus());
apiDefinition.setOriginalState(existApi.getOriginalState());
apiDefinition.setCaseStatus(existApi.getCaseStatus());
@ -930,9 +946,17 @@ public class ApiDefinitionService {
if (existApi.getUserId() != null) {
apiDefinition.setUserId(existApi.getUserId());
}
//Check whether the content has changed, if not, do not change the creation time
Boolean toChangeTime = checkIsSynchronize(existApi, apiDefinition);
if (!toChangeTime) {
apiDefinition.setUpdateTime(existApi.getUpdateTime());
}
// case 设置版本
cases.forEach(c -> {
c.setVersionId(apiDefinition.getVersionId());
if (apiDefinition.getToBeUpdated() != null && apiDefinition.getToBeUpdated()) {
c.setToBeUpdated(true);
}
});
if (!StringUtils.equalsIgnoreCase(apiTestImportRequest.getPlatform(), ApiImportPlatform.Metersphere.name())) {
apiDefinition.setTags(existApi.getTags()); // 其他格式 tag 不变MS 格式替换
@ -965,6 +989,89 @@ public class ApiDefinitionService {
}
}
private Boolean checkIsSynchronize(ApiDefinitionWithBLOBs existApi,ApiDefinitionWithBLOBs apiDefinition) {
ApiDefinition exApi;
ApiDefinition api;
exApi = existApi;
api = apiDefinition;
ObjectMapper objectMapper = new ObjectMapper();
String exApiString = null;
String apiString = null;
try {
exApiString = objectMapper.writeValueAsString(exApi);
apiString = objectMapper.writeValueAsString(api);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
//Compare the basic information of the API. If it contains the comparison that needs to be done for the synchronization information,
// put the data into the to-be-synchronized
if (!StringUtils.equals(exApiString,apiString)) {
if (!StringUtils.equals(apiDefinition.getMethod(), existApi.getMethod())) {
apiDefinition.setToBeUpdated(true);
return true;
}
if (!StringUtils.equals(apiDefinition.getProtocol(), existApi.getProtocol())) {
apiDefinition.setToBeUpdated(true);
return true;
}
if (!StringUtils.equals(apiDefinition.getPath(), existApi.getPath())) {
apiDefinition.setToBeUpdated(true);
return true;
}
return true;
}
if (!StringUtils.equals(existApi.getRemark(),apiDefinition.getRemark())) {
return true;
}
if (!StringUtils.equals(existApi.getDescription(),apiDefinition.getDescription())) {
return true;
}
if (!StringUtils.equals(existApi.getResponse(),apiDefinition.getResponse())) {
return true;
}
JsonNode exApiRequest = null;
JsonNode apiRequest = null;
try {
exApiRequest = objectMapper.readTree(existApi.getRequest());
apiRequest = objectMapper.readTree(apiDefinition.getRequest());
} catch (JsonProcessingException e) {
e.printStackTrace();
}
if (exApiRequest == null || apiRequest == null) {
return false;
}
if (!StringUtils.equals(exApiRequest.get("headers").toString(),apiRequest.get("headers").toString())){
apiDefinition.setToBeUpdated(true);
return true;
}
if (!StringUtils.equals(exApiRequest.get("arguments").toString(),apiRequest.get("arguments").toString())){
apiDefinition.setToBeUpdated(true);
return true;
}
if (!StringUtils.equals(exApiRequest.get("rest").toString(),apiRequest.get("rest").toString())){
apiDefinition.setToBeUpdated(true);
return true;
}
if (!StringUtils.equals(exApiRequest.get("body").toString(), apiRequest.get("body").toString())){
apiDefinition.setToBeUpdated(true);
return true;
}
return false;
}
/**
* 如果是MS格式带用例导出最后创建用例重新设置接口id
*

View File

@ -0,0 +1,9 @@
package io.metersphere.api.service;
import io.metersphere.api.dto.definition.SaveApiDefinitionRequest;
public interface ApiDefinitionSyncService {
void syncApi(SaveApiDefinitionRequest request);
}

View File

@ -707,6 +707,12 @@ public class ApiTestCaseService {
apiDefinitionWithBLOBs.setUpdateTime(System.currentTimeMillis());
apiTestCaseMapper.updateByExampleSelective(apiDefinitionWithBLOBs, apiDefinitionExample);
}
if (StringUtils.isNotEmpty(request.getCaseStatus())) {
ApiTestCaseWithBLOBs apiDefinitionWithBLOBs = new ApiTestCaseWithBLOBs();
apiDefinitionWithBLOBs.setCaseStatus(request.getCaseStatus());
apiDefinitionWithBLOBs.setUpdateTime(System.currentTimeMillis());
apiTestCaseMapper.updateByExampleSelective(apiDefinitionWithBLOBs, apiDefinitionExample);
}
if (StringUtils.isNotEmpty(request.getEnvId())) {
List<ApiTestCaseWithBLOBs> bloBs = apiTestCaseMapper.selectByExampleWithBLOBs(apiDefinitionExample);
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
@ -758,7 +764,7 @@ public class ApiTestCaseService {
}
}
public void updateByApiDefinitionId(List<String> ids, String path, String method, String protocol) {
public void updateByApiDefinitionId(List<String> ids, String path, String method, String protocol,Boolean toBeUpdated) {
if ((StringUtils.isNotEmpty(method) || StringUtils.isNotEmpty(path) && RequestType.HTTP.equals(protocol))) {
ApiTestCaseExample apiDefinitionExample = new ApiTestCaseExample();
apiDefinitionExample.createCriteria().andApiDefinitionIdIn(ids);
@ -788,6 +794,9 @@ public class ApiTestCaseService {
}
String requestStr = JSON.toJSONString(req);
apiTestCase.setRequest(requestStr);
if(toBeUpdated!=null){
apiTestCase.setToBeUpdated(toBeUpdated);
}
batchMapper.updateByPrimaryKeySelective(apiTestCase);
});
sqlSession.flushStatements();

View File

@ -0,0 +1,10 @@
package io.metersphere.api.service;
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
public interface ApiTestCaseSyncService {
void setApiCaseUpdate(ApiTestCaseWithBLOBs test);
}

View File

@ -0,0 +1,9 @@
package io.metersphere.api.service;
import com.fasterxml.jackson.core.JsonProcessingException;
import io.metersphere.base.domain.ProjectApplication;
public interface ProjectApplicationSyncService {
// 初始化引用关系
ProjectApplication initProjectApplicationAboutWorkstation(ProjectApplication projectApplication ) throws JsonProcessingException;
}

View File

@ -28,6 +28,8 @@ public class RemakeReportService {
@Resource
private ApiTestCaseMapper apiTestCaseMapper;
@Resource
private ApiDefinitionMapper apiDefinitionMapper;
@Resource
private ApiDefinitionExecResultMapper execResultMapper;
@Resource
private TestPlanApiCaseMapper testPlanApiCaseMapper;
@ -70,6 +72,11 @@ public class RemakeReportService {
apiTestCase.setStatus("error");
apiTestCase.setUpdateTime(System.currentTimeMillis());
apiTestCaseMapper.updateByPrimaryKeySelective(apiTestCase);
ApiDefinitionWithBLOBs apiDefinitionWithBLOBs = apiDefinitionMapper.selectByPrimaryKey(apiTestCase.getApiDefinitionId());
if (apiDefinitionWithBLOBs.getProtocol().equals("HTTP")) {
apiDefinitionWithBLOBs.setToBeUpdated(true);
apiDefinitionMapper.updateByPrimaryKey(apiDefinitionWithBLOBs);
}
}
}
} else if (StringUtils.equals(request.getRunMode(), ApiRunMode.SCENARIO_PLAN.name())) {

View File

@ -1,8 +1,7 @@
package io.metersphere.base.domain;
import lombok.Data;
import java.io.Serializable;
import lombok.Data;
@Data
public class ApiDefinition implements Serializable {
@ -60,5 +59,7 @@ public class ApiDefinition implements Serializable {
private Boolean latest;
private Boolean toBeUpdated;
private static final long serialVersionUID = 1L;
}

View File

@ -1933,6 +1933,66 @@ public class ApiDefinitionExample {
addCriterion("latest not between", value1, value2, "latest");
return (Criteria) this;
}
public Criteria andToBeUpdatedIsNull() {
addCriterion("to_be_updated is null");
return (Criteria) this;
}
public Criteria andToBeUpdatedIsNotNull() {
addCriterion("to_be_updated is not null");
return (Criteria) this;
}
public Criteria andToBeUpdatedEqualTo(Boolean value) {
addCriterion("to_be_updated =", value, "toBeUpdated");
return (Criteria) this;
}
public Criteria andToBeUpdatedNotEqualTo(Boolean value) {
addCriterion("to_be_updated <>", value, "toBeUpdated");
return (Criteria) this;
}
public Criteria andToBeUpdatedGreaterThan(Boolean value) {
addCriterion("to_be_updated >", value, "toBeUpdated");
return (Criteria) this;
}
public Criteria andToBeUpdatedGreaterThanOrEqualTo(Boolean value) {
addCriterion("to_be_updated >=", value, "toBeUpdated");
return (Criteria) this;
}
public Criteria andToBeUpdatedLessThan(Boolean value) {
addCriterion("to_be_updated <", value, "toBeUpdated");
return (Criteria) this;
}
public Criteria andToBeUpdatedLessThanOrEqualTo(Boolean value) {
addCriterion("to_be_updated <=", value, "toBeUpdated");
return (Criteria) this;
}
public Criteria andToBeUpdatedIn(List<Boolean> values) {
addCriterion("to_be_updated in", values, "toBeUpdated");
return (Criteria) this;
}
public Criteria andToBeUpdatedNotIn(List<Boolean> values) {
addCriterion("to_be_updated not in", values, "toBeUpdated");
return (Criteria) this;
}
public Criteria andToBeUpdatedBetween(Boolean value1, Boolean value2) {
addCriterion("to_be_updated between", value1, value2, "toBeUpdated");
return (Criteria) this;
}
public Criteria andToBeUpdatedNotBetween(Boolean value1, Boolean value2) {
addCriterion("to_be_updated not between", value1, value2, "toBeUpdated");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {

View File

@ -45,5 +45,7 @@ public class ApiTestCase implements Serializable {
private String versionId;
private Boolean toBeUpdated;
private static final long serialVersionUID = 1L;
}

View File

@ -1443,6 +1443,66 @@ public class ApiTestCaseExample {
addCriterion("version_id not between", value1, value2, "versionId");
return (Criteria) this;
}
public Criteria andToBeUpdatedIsNull() {
addCriterion("to_be_updated is null");
return (Criteria) this;
}
public Criteria andToBeUpdatedIsNotNull() {
addCriterion("to_be_updated is not null");
return (Criteria) this;
}
public Criteria andToBeUpdatedEqualTo(Boolean value) {
addCriterion("to_be_updated =", value, "toBeUpdated");
return (Criteria) this;
}
public Criteria andToBeUpdatedNotEqualTo(Boolean value) {
addCriterion("to_be_updated <>", value, "toBeUpdated");
return (Criteria) this;
}
public Criteria andToBeUpdatedGreaterThan(Boolean value) {
addCriterion("to_be_updated >", value, "toBeUpdated");
return (Criteria) this;
}
public Criteria andToBeUpdatedGreaterThanOrEqualTo(Boolean value) {
addCriterion("to_be_updated >=", value, "toBeUpdated");
return (Criteria) this;
}
public Criteria andToBeUpdatedLessThan(Boolean value) {
addCriterion("to_be_updated <", value, "toBeUpdated");
return (Criteria) this;
}
public Criteria andToBeUpdatedLessThanOrEqualTo(Boolean value) {
addCriterion("to_be_updated <=", value, "toBeUpdated");
return (Criteria) this;
}
public Criteria andToBeUpdatedIn(List<Boolean> values) {
addCriterion("to_be_updated in", values, "toBeUpdated");
return (Criteria) this;
}
public Criteria andToBeUpdatedNotIn(List<Boolean> values) {
addCriterion("to_be_updated not in", values, "toBeUpdated");
return (Criteria) this;
}
public Criteria andToBeUpdatedBetween(Boolean value1, Boolean value2) {
addCriterion("to_be_updated between", value1, value2, "toBeUpdated");
return (Criteria) this;
}
public Criteria andToBeUpdatedNotBetween(Boolean value1, Boolean value2) {
addCriterion("to_be_updated not between", value1, value2, "toBeUpdated");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {

View File

@ -29,6 +29,7 @@
<result column="ref_id" jdbcType="VARCHAR" property="refId" />
<result column="version_id" jdbcType="VARCHAR" property="versionId" />
<result column="latest" jdbcType="BIT" property="latest" />
<result column="to_be_updated" jdbcType="BIT" property="toBeUpdated" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.ApiDefinitionWithBLOBs">
<result column="description" jdbcType="LONGVARCHAR" property="description" />
@ -98,7 +99,7 @@
id, project_id, `name`, `method`, module_path, environment_id, schedule, `status`,
module_id, user_id, create_time, update_time, protocol, `path`, num, tags, original_state,
create_user, case_total, case_status, case_passing_rate, delete_time, delete_user_id,
`order`, ref_id, version_id, latest
`order`, ref_id, version_id, latest, to_be_updated
</sql>
<sql id="Blob_Column_List">
description, request, response, remark
@ -152,7 +153,7 @@
</if>
</delete>
<insert id="insert" parameterType="io.metersphere.base.domain.ApiDefinitionWithBLOBs">
INSERT INTO api_definition (id, project_id, `name`,
insert into api_definition (id, project_id, `name`,
`method`, module_path, environment_id,
schedule, `status`, module_id,
user_id, create_time, update_time,
@ -161,9 +162,9 @@
case_total, case_status, case_passing_rate,
delete_time, delete_user_id, `order`,
ref_id, version_id, latest,
description, request, response,
remark)
VALUES (#{id,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
to_be_updated, description, request,
response, remark)
values (#{id,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
#{method,jdbcType=VARCHAR}, #{modulePath,jdbcType=VARCHAR}, #{environmentId,jdbcType=VARCHAR},
#{schedule,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{moduleId,jdbcType=VARCHAR},
#{userId,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT},
@ -172,8 +173,8 @@
#{caseTotal,jdbcType=VARCHAR}, #{caseStatus,jdbcType=VARCHAR}, #{casePassingRate,jdbcType=VARCHAR},
#{deleteTime,jdbcType=BIGINT}, #{deleteUserId,jdbcType=VARCHAR}, #{order,jdbcType=BIGINT},
#{refId,jdbcType=VARCHAR}, #{versionId,jdbcType=VARCHAR}, #{latest,jdbcType=BIT},
#{description,jdbcType=LONGVARCHAR}, #{request,jdbcType=LONGVARCHAR}, #{response,jdbcType=LONGVARCHAR},
#{remark,jdbcType=LONGVARCHAR})
#{toBeUpdated,jdbcType=BIT}, #{description,jdbcType=LONGVARCHAR}, #{request,jdbcType=LONGVARCHAR},
#{response,jdbcType=LONGVARCHAR}, #{remark,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.ApiDefinitionWithBLOBs">
insert into api_definition
@ -259,6 +260,9 @@
<if test="latest != null">
latest,
</if>
<if test="toBeUpdated != null">
to_be_updated,
</if>
<if test="description != null">
description,
</if>
@ -354,6 +358,9 @@
<if test="latest != null">
#{latest,jdbcType=BIT},
</if>
<if test="toBeUpdated != null">
#{toBeUpdated,jdbcType=BIT},
</if>
<if test="description != null">
#{description,jdbcType=LONGVARCHAR},
</if>
@ -458,6 +465,9 @@
<if test="record.latest != null">
latest = #{record.latest,jdbcType=BIT},
</if>
<if test="record.toBeUpdated != null">
to_be_updated = #{record.toBeUpdated,jdbcType=BIT},
</if>
<if test="record.description != null">
description = #{record.description,jdbcType=LONGVARCHAR},
</if>
@ -504,6 +514,7 @@
ref_id = #{record.refId,jdbcType=VARCHAR},
version_id = #{record.versionId,jdbcType=VARCHAR},
latest = #{record.latest,jdbcType=BIT},
to_be_updated = #{record.toBeUpdated,jdbcType=BIT},
description = #{record.description,jdbcType=LONGVARCHAR},
request = #{record.request,jdbcType=LONGVARCHAR},
response = #{record.response,jdbcType=LONGVARCHAR},
@ -540,7 +551,8 @@
`order` = #{record.order,jdbcType=BIGINT},
ref_id = #{record.refId,jdbcType=VARCHAR},
version_id = #{record.versionId,jdbcType=VARCHAR},
latest = #{record.latest,jdbcType=BIT}
latest = #{record.latest,jdbcType=BIT},
to_be_updated = #{record.toBeUpdated,jdbcType=BIT}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -626,6 +638,9 @@
<if test="latest != null">
latest = #{latest,jdbcType=BIT},
</if>
<if test="toBeUpdated != null">
to_be_updated = #{toBeUpdated,jdbcType=BIT},
</if>
<if test="description != null">
description = #{description,jdbcType=LONGVARCHAR},
</if>
@ -669,6 +684,7 @@
ref_id = #{refId,jdbcType=VARCHAR},
version_id = #{versionId,jdbcType=VARCHAR},
latest = #{latest,jdbcType=BIT},
to_be_updated = #{toBeUpdated,jdbcType=BIT},
description = #{description,jdbcType=LONGVARCHAR},
request = #{request,jdbcType=LONGVARCHAR},
response = #{response,jdbcType=LONGVARCHAR},
@ -702,7 +718,8 @@
`order` = #{order,jdbcType=BIGINT},
ref_id = #{refId,jdbcType=VARCHAR},
version_id = #{versionId,jdbcType=VARCHAR},
latest = #{latest,jdbcType=BIT}
latest = #{latest,jdbcType=BIT},
to_be_updated = #{toBeUpdated,jdbcType=BIT}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -22,6 +22,7 @@
<result column="order" jdbcType="BIGINT" property="order" />
<result column="case_status" jdbcType="VARCHAR" property="caseStatus" />
<result column="version_id" jdbcType="VARCHAR" property="versionId" />
<result column="to_be_updated" jdbcType="BIT" property="toBeUpdated" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.ApiTestCaseWithBLOBs">
<result column="description" jdbcType="LONGVARCHAR" property="description" />
@ -88,7 +89,7 @@
<sql id="Base_Column_List">
id, project_id, `name`, priority, api_definition_id, create_user_id, update_user_id,
create_time, update_time, num, tags, last_result_id, `status`, original_status, delete_time,
delete_user_id, version, `order`, case_status, version_id
delete_user_id, version, `order`, case_status, version_id, to_be_updated
</sql>
<sql id="Blob_Column_List">
description, request
@ -148,16 +149,16 @@
num, tags, last_result_id,
`status`, original_status, delete_time,
delete_user_id, version, `order`,
case_status, version_id, description,
request)
case_status, version_id, to_be_updated,
description, request)
values (#{id,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
#{priority,jdbcType=VARCHAR}, #{apiDefinitionId,jdbcType=VARCHAR}, #{createUserId,jdbcType=VARCHAR},
#{updateUserId,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT},
#{num,jdbcType=INTEGER}, #{tags,jdbcType=VARCHAR}, #{lastResultId,jdbcType=VARCHAR},
#{status,jdbcType=VARCHAR}, #{originalStatus,jdbcType=VARCHAR}, #{deleteTime,jdbcType=BIGINT},
#{deleteUserId,jdbcType=VARCHAR}, #{version,jdbcType=INTEGER}, #{order,jdbcType=BIGINT},
#{caseStatus,jdbcType=VARCHAR}, #{versionId,jdbcType=VARCHAR}, #{description,jdbcType=LONGVARCHAR},
#{request,jdbcType=LONGVARCHAR})
#{caseStatus,jdbcType=VARCHAR}, #{versionId,jdbcType=VARCHAR}, #{toBeUpdated,jdbcType=BIT},
#{description,jdbcType=LONGVARCHAR}, #{request,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.ApiTestCaseWithBLOBs">
insert into api_test_case
@ -222,6 +223,9 @@
<if test="versionId != null">
version_id,
</if>
<if test="toBeUpdated != null">
to_be_updated,
</if>
<if test="description != null">
description,
</if>
@ -290,6 +294,9 @@
<if test="versionId != null">
#{versionId,jdbcType=VARCHAR},
</if>
<if test="toBeUpdated != null">
#{toBeUpdated,jdbcType=BIT},
</if>
<if test="description != null">
#{description,jdbcType=LONGVARCHAR},
</if>
@ -367,6 +374,9 @@
<if test="record.versionId != null">
version_id = #{record.versionId,jdbcType=VARCHAR},
</if>
<if test="record.toBeUpdated != null">
to_be_updated = #{record.toBeUpdated,jdbcType=BIT},
</if>
<if test="record.description != null">
description = #{record.description,jdbcType=LONGVARCHAR},
</if>
@ -400,6 +410,7 @@
`order` = #{record.order,jdbcType=BIGINT},
case_status = #{record.caseStatus,jdbcType=VARCHAR},
version_id = #{record.versionId,jdbcType=VARCHAR},
to_be_updated = #{record.toBeUpdated,jdbcType=BIT},
description = #{record.description,jdbcType=LONGVARCHAR},
request = #{record.request,jdbcType=LONGVARCHAR}
<if test="_parameter != null">
@ -427,7 +438,8 @@
version = #{record.version,jdbcType=INTEGER},
`order` = #{record.order,jdbcType=BIGINT},
case_status = #{record.caseStatus,jdbcType=VARCHAR},
version_id = #{record.versionId,jdbcType=VARCHAR}
version_id = #{record.versionId,jdbcType=VARCHAR},
to_be_updated = #{record.toBeUpdated,jdbcType=BIT}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -492,6 +504,9 @@
<if test="versionId != null">
version_id = #{versionId,jdbcType=VARCHAR},
</if>
<if test="toBeUpdated != null">
to_be_updated = #{toBeUpdated,jdbcType=BIT},
</if>
<if test="description != null">
description = #{description,jdbcType=LONGVARCHAR},
</if>
@ -522,6 +537,7 @@
`order` = #{order,jdbcType=BIGINT},
case_status = #{caseStatus,jdbcType=VARCHAR},
version_id = #{versionId,jdbcType=VARCHAR},
to_be_updated = #{toBeUpdated,jdbcType=BIT},
description = #{description,jdbcType=LONGVARCHAR},
request = #{request,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=VARCHAR}
@ -546,7 +562,8 @@
version = #{version,jdbcType=INTEGER},
`order` = #{order,jdbcType=BIGINT},
case_status = #{caseStatus,jdbcType=VARCHAR},
version_id = #{versionId,jdbcType=VARCHAR}
version_id = #{versionId,jdbcType=VARCHAR},
to_be_updated = #{toBeUpdated,jdbcType=BIT}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -89,4 +89,7 @@ public interface ExtApiDefinitionMapper {
List<String> selectRefIdsForVersionChange(@Param("versionId") String versionId, @Param("projectId") String projectId);
String selectNameById(String testId);
int toBeUpdateApi(@Param("ids") List<String> ids,@Param("toBeUpdate") Boolean toBeUpdate);
}

View File

@ -698,6 +698,9 @@
<if test="request.moduleId != null">
AND api_definition.module_id = #{request.moduleId}
</if>
<if test="request.toBeUpdated != null">
AND api_definition.to_be_updated = #{request.toBeUpdated}
</if>
<if test="request.notInIds != null and request.notInIds.size() > 0">
and api_definition.id not in
<foreach collection="request.notInIds" item="id" separator="," open="(" close=")">
@ -929,6 +932,16 @@
WHERE ref_id = #{refId,jdbcType=VARCHAR}
</update>
<update id="toBeUpdateApi">
update api_definition
set
to_be_updated = #{toBeUpdate}
where id in
<foreach collection="ids" item="v" separator="," open="(" close=")">
#{v}
</foreach>
</update>
<select id="selectRefIdsForVersionChange" resultType="java.lang.String">
SELECT DISTINCT ref_id
FROM api_definition

View File

@ -76,4 +76,6 @@ public interface ExtApiTestCaseMapper {
void insertNewVersionCases(@Param("api") ApiDefinition apiDefinition, @Param("old") ApiDefinition old);
List<ApiTestCase> checkName(@Param("request") SaveApiTestCaseRequest request);
int toBeUpdateCase(@Param("ids") List<String> ids,@Param("toBeUpdate") Boolean toBeUpdate);
}

View File

@ -454,14 +454,16 @@
<if test="key=='status' and values.size == 0">
and (t1.status is null or t1.status != 'Trash')
</if>
</if>
</if>
</foreach>
</if>
<if test="request.filters == null || request.filters.size() == 0 ">
and (t1.status is null or t1.status != 'Trash')
</if>
<if test="request.toUpdate !=null and request.toUpdate == true">
and (t1.update_time >= #{request.updateTime} or t3.status = 'error')
<if test="request.toBeUpdated !=null">
and (t1.to_be_updated = #{request.toBeUpdated} or t3.status = 'error')
</if>
<include refid="queryVersionCondition">
<property name="versionTable" value="t1"/>
@ -821,6 +823,14 @@
#{v}
</foreach>
</update>
<update id="toBeUpdateCase">
update api_test_case
set to_be_updated = #{toBeUpdate}
where id IN
<foreach collection="ids" item="v" separator="," open="(" close=")">
#{v}
</foreach>
</update>
<sql id="queryVersionCondition">
<if test="request.versionId != null">

View File

@ -67,5 +67,15 @@ public enum ProjectApplicationType {
/**
* 接口分享链接有效期
*/
API_SHARE_REPORT_TIME
API_SHARE_REPORT_TIME,
/**
* 我的工作台-待更新时间限制
*/
OPEN_UPDATE_RULE_TIME,
/**
* 我的工作台-触发待更新规则
*/
TRIGGER_UPDATE
}

View File

@ -1,11 +1,10 @@
package io.metersphere.service;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.core.JsonProcessingException;
import io.metersphere.api.dto.DeleteAPITestRequest;
import io.metersphere.api.dto.QueryAPITestRequest;
import io.metersphere.api.service.APITestService;
import io.metersphere.api.service.ApiScenarioReportService;
import io.metersphere.api.service.ApiTestDelService;
import io.metersphere.api.service.*;
import io.metersphere.api.tcp.TCPPool;
import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.*;
@ -218,6 +217,16 @@ public class ProjectService {
projectApplication.setType(ProjectApplicationType.CASE_CUSTOM_NUM.toString());
projectApplication.setTypeValue(Boolean.FALSE.toString());
projectApplicationMapper.insert(projectApplication);
//xpack的项目都有同步设置规则
ProjectApplicationSyncService projectApplicationSyncService = CommonBeanFactory.getBean(ProjectApplicationSyncService.class);
if (projectApplicationSyncService != null) {
try {
projectApplication = projectApplicationSyncService.initProjectApplicationAboutWorkstation(projectApplication);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
projectApplicationMapper.insert(projectApplication);
}
}
public void checkThirdProjectExist(Project project) {

View File

@ -86,7 +86,7 @@
<!-- <ignoreColumn column="clean_load_report_expr"/>-->
<!-- <ignoreColumn column="repeatable"/>-->
<!-- </table>-->
<table tableName="test_plan_execution_queue"/>
<table tableName="api_test_case"/>
<!--<table tableName="enterprise_test_report_send_record"/>-->
<!--<table tableName="test_case_review_api_case"/>
<table tableName="test_case_review_load"/>

View File

@ -449,7 +449,9 @@ export default {
delete_all_version: 'All versions',
change_password_tips: 'Your password is the initial system password, please change it as soon as possible',
ui: 'UI TEST',
not_eligible_for_deletion:'Not Eligible For Deletion'
not_eligible_for_deletion:'Not Eligible For Deletion',
batch:'Batch',
change:'Change',
},
login: {
normal_Login: "Normal Login",
@ -472,6 +474,8 @@ export default {
expired: 'expired',
},
workstation: {
sync:'Synchronize',
ignore:'Ignore',
dash_board: 'My DashBoard',
upcoming: 'My Upcoming',
focus: 'My Focus',
@ -480,6 +484,7 @@ export default {
creation_issue: 'My Creation Issue',
creation_case_tip: 'No use case has been created yet, create it now',
creation_issue_tip: 'No defects have been created yet, create them now',
delNotSame:'Remove parameters in use cases that cannot correspond to API documentation',
table_name: {
track_case: 'Track Case',
track_plan: 'Track Plan',

View File

@ -451,7 +451,9 @@ export default {
delete_all_version: '全部版本',
change_password_tips: '您的密码是系统初始密码,请尽快修改密码',
ui: 'UI 测试',
not_eligible_for_deletion:'不符合删除条件'
not_eligible_for_deletion:'不符合删除条件',
batch:'批量',
change:'改变',
},
login: {
normal_Login: "普通登录",
@ -474,6 +476,8 @@ export default {
expired: '已过期',
},
workstation: {
sync:'同步',
ignore:'忽略',
dash_board: '我的仪表盘',
upcoming: '我的待办',
focus: '我的关注',
@ -482,6 +486,7 @@ export default {
creation_issue: '我创建的缺陷',
creation_case_tip: '暂时还没有创建用例,马上创建',
creation_issue_tip: '暂时还没有创建缺陷,马上创建',
delNotSame:'删除用例中无法与API文档对应的参数',
table_name: {
track_case: '功能用例',
track_plan: '测试计划',
@ -492,7 +497,10 @@ export default {
api_case: '接口用例',
performance: '性能测试',
scenario_case: '场景用例'
}
},
sync_case_tips: '注意: 忽略后,受影响的用例将不再有提醒,请谨慎操作',
batch_sync_api_tips: '注意: 批量同步,有可能部分不需要同步的用例参数也被覆盖,导致测试不通过,请谨慎操作',
batch_ignore_case_tips: '注意: 批量忽略后,受影响的用例将不再有提醒,请谨慎操作',
},
display: {
title: '显示设置',

View File

@ -451,7 +451,9 @@ export default {
delete_all_version: '全部版本',
change_password_tips: '您的密碼是系統初始密碼,請盡快修改密碼',
ui: 'UI 測試',
not_eligible_for_deletion:'不符合删除條件'
not_eligible_for_deletion:'不符合删除條件',
batch:'批量',
change:'改变',
},
login: {
normal_Login: "普通登錄",
@ -474,6 +476,8 @@ export default {
expired: '已過期',
},
workstation: {
sync:'同步',
ignore:'忽略',
dash_board: '我的儀表盤',
upcoming: '我的待辦',
focus: '我的關註',
@ -482,6 +486,7 @@ export default {
creation_issue: '我創建的缺陷',
creation_case_tip: '暫時還沒有創建用例,馬上創建',
creation_issue_tip: '暫時還沒有創建缺陷,馬上創建',
delNotSame:'刪除用例中無法與API文檔對應的參數',
table_name: {
track_case: '功能用例',
track_plan: '測試計劃',