diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/ApiDefinitionRequest.java b/backend/src/main/java/io/metersphere/api/dto/definition/ApiDefinitionRequest.java index ca16e7a5c5..aa9a8c1504 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/ApiDefinitionRequest.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/ApiDefinitionRequest.java @@ -33,4 +33,7 @@ public class ApiDefinitionRequest extends BaseQueryRequest { private boolean repeatCase; //是否进入待更新列表 private Boolean toBeUpdated; + + //当前时间减去进入待更新的时间 + private Long toBeUpdateTime; } diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseRequest.java b/backend/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseRequest.java index d4b9ccc6ac..90b29e22a9 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseRequest.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/ApiTestCaseRequest.java @@ -41,6 +41,11 @@ public class ApiTestCaseRequest extends BaseQueryRequest { * 是否进入待更新列表 */ private Boolean toBeUpdated; + + /** + * 当前时间减去进入待更新的时间 + */ + private Long toBeUpdateTime; /** * 是否需要查询环境字段 */ @@ -50,7 +55,7 @@ public class ApiTestCaseRequest extends BaseQueryRequest { * 查询排除一些接口 */ private List notInIds; - + //页面跳转时附带的过滤条件 private String redirectFilter; } diff --git a/backend/src/main/java/io/metersphere/api/exec/api/ApiExecuteService.java b/backend/src/main/java/io/metersphere/api/exec/api/ApiExecuteService.java index b335d90d2a..a7dbf4bd93 100644 --- a/backend/src/main/java/io/metersphere/api/exec/api/ApiExecuteService.java +++ b/backend/src/main/java/io/metersphere/api/exec/api/ApiExecuteService.java @@ -85,7 +85,7 @@ public class ApiExecuteService { request.setEnvironmentId(extApiTestCaseMapper.getApiCaseEnvironment(request.getCaseId())); } //提前生成报告 - ApiDefinitionExecResultWithBLOBs report = ApiDefinitionExecResultUtil.add(caseWithBLOBs.getId(), APITestStatus.Running.name(), request.getReportId(),Objects.requireNonNull(SessionUtils.getUser()).getId()); + ApiDefinitionExecResultWithBLOBs report = ApiDefinitionExecResultUtil.add(caseWithBLOBs.getId(), APITestStatus.Running.name(), request.getReportId(), Objects.requireNonNull(SessionUtils.getUser()).getId()); report.setName(caseWithBLOBs.getName()); report.setTriggerMode(ApiRunMode.JENKINS.name()); report.setType(ApiRunMode.JENKINS.name()); @@ -135,6 +135,7 @@ public class ApiExecuteService { ApiDefinitionWithBLOBs apiDefinitionWithBLOBs = apiDefinitionMapper.selectByPrimaryKey(caseWithBLOBs.getApiDefinitionId()); if (apiDefinitionWithBLOBs.getProtocol().equals("HTTP")) { apiDefinitionWithBLOBs.setToBeUpdated(true); + apiDefinitionWithBLOBs.setToBeUpdateTime(System.currentTimeMillis()); apiDefinitionMapper.updateByPrimaryKey(apiDefinitionWithBLOBs); } } diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java index 80a9061035..0eae35fe2d 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -165,6 +165,12 @@ public class ApiDefinitionService { public List list(ApiDefinitionRequest request) { request = this.initRequest(request, true, true); + if (request.getToBeUpdated() != null && request.getToBeUpdated()) { + Long toBeUpdatedTime = apiTestCaseService.getToBeUpdatedTime(request.getProjectId()); + if (toBeUpdatedTime != null) { + request.setToBeUpdateTime(toBeUpdatedTime); + } + } List resList = extApiDefinitionMapper.list(request); buildUserInfo(resList); if (StringUtils.isNotBlank(request.getProjectId())) { @@ -610,6 +616,7 @@ public class ApiDefinitionService { test.setRemark(request.getRemark()); if (request.getToBeUpdated() != null && request.getToBeUpdated()) { test.setToBeUpdated(request.getToBeUpdated()); + test.setToBeUpdateTime(System.currentTimeMillis()); } if (StringUtils.isNotEmpty(request.getTags()) && !StringUtils.equals(request.getTags(), "[]")) { test.setTags(request.getTags()); @@ -872,6 +879,15 @@ public class ApiDefinitionService { if (apiTestCaseWithBLOBs.getNum() == null) { apiTestCaseWithBLOBs.setNum(testCaseService.getNextNum(apiDefinition.getId())); } + + if (apiDefinition.getToBeUpdated() != null) { + apiTestCaseWithBLOBs.setToBeUpdated(apiDefinition.getToBeUpdated()); + } + + if (apiDefinition.getToBeUpdateTime() != null) { + apiTestCaseWithBLOBs.setToBeUpdateTime(apiDefinition.getToBeUpdateTime()); + } + if (StringUtils.isNotBlank(apiTestCaseWithBLOBs.getId())) { apiTestCaseMapper.updateByPrimaryKeyWithBLOBs(apiTestCaseWithBLOBs); } else { @@ -992,6 +1008,8 @@ public class ApiDefinitionService { Boolean toChangeTime = checkIsSynchronize(existApi, apiDefinition); if (toChangeTime) { apiDefinition.setUpdateTime(System.currentTimeMillis()); + } else if (apiTestImportRequest.getCoverModule() != null && apiTestImportRequest.getCoverModule()) { + apiDefinition.setUpdateTime(System.currentTimeMillis()); } } else { apiDefinition.setUpdateTime(System.currentTimeMillis()); @@ -1039,24 +1057,50 @@ public class ApiDefinitionService { } catch (JsonProcessingException e) { e.printStackTrace(); } + ApiSyncCaseRequest apiSyncCaseRequest = new ApiSyncCaseRequest(); + ApiDefinitionSyncService apiDefinitionSyncService = CommonBeanFactory.getBean(ApiDefinitionSyncService.class); + if (apiDefinitionSyncService != null) { + apiSyncCaseRequest = apiDefinitionSyncService.getApiSyncCaseRequest(existApi.getProjectId()); + } + //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); + if (apiSyncCaseRequest.getMethod()) { + apiDefinition.setToBeUpdated(true); + apiDefinition.setToBeUpdateTime(System.currentTimeMillis()); + } return true; } if (!StringUtils.equals(apiDefinition.getProtocol(), existApi.getProtocol())) { - apiDefinition.setToBeUpdated(true); + if (apiSyncCaseRequest.getProtocol()) { + apiDefinition.setToBeUpdated(true); + apiDefinition.setToBeUpdateTime(System.currentTimeMillis()); + } return true; } if (!StringUtils.equals(apiDefinition.getPath(), existApi.getPath())) { - apiDefinition.setToBeUpdated(true); + if (apiSyncCaseRequest.getPath()) { + apiDefinition.setToBeUpdated(true); + apiDefinition.setToBeUpdateTime(System.currentTimeMillis()); + } return true; } + } + + if (!StringUtils.equals(apiDefinition.getCreateUser(), existApi.getCreateUser())) { + return true; + } + + if (!StringUtils.equals(apiDefinition.getStatus(), existApi.getStatus())) { + return true; + } + + if (!StringUtils.equals(apiDefinition.getTags(), existApi.getTags())) { return true; } @@ -1086,28 +1130,40 @@ public class ApiDefinitionService { } if (exApiRequest.get("headers") != null && apiRequest.get("headers") != null) { if (!StringUtils.equals(exApiRequest.get("headers").toString(), apiRequest.get("headers").toString())) { - apiDefinition.setToBeUpdated(true); + if (apiSyncCaseRequest.getHeaders()) { + apiDefinition.setToBeUpdated(true); + apiDefinition.setToBeUpdateTime(System.currentTimeMillis()); + } return true; } } if (exApiRequest.get("arguments") != null && apiRequest.get("arguments") != null) { if (!StringUtils.equals(exApiRequest.get("arguments").toString(), apiRequest.get("arguments").toString())) { - apiDefinition.setToBeUpdated(true); + if (apiSyncCaseRequest.getQuery()) { + apiDefinition.setToBeUpdated(true); + apiDefinition.setToBeUpdateTime(System.currentTimeMillis()); + } return true; } } if (exApiRequest.get("rest") != null && apiRequest.get("rest") != null) { if (!StringUtils.equals(exApiRequest.get("rest").toString(), apiRequest.get("rest").toString())) { - apiDefinition.setToBeUpdated(true); + if (apiSyncCaseRequest.getRest()) { + apiDefinition.setToBeUpdated(true); + apiDefinition.setToBeUpdateTime(System.currentTimeMillis()); + } return true; } } if (exApiRequest.get("body") != null && apiRequest.get("body") != null) { if (!StringUtils.equals(exApiRequest.get("body").toString(), apiRequest.get("body").toString())) { - apiDefinition.setToBeUpdated(true); + if (apiSyncCaseRequest.getBody()) { + apiDefinition.setToBeUpdated(true); + apiDefinition.setToBeUpdateTime(System.currentTimeMillis()); + } return true; } } diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionSyncService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionSyncService.java index 4d1b3ef109..cfb05c52fd 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionSyncService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionSyncService.java @@ -1,9 +1,12 @@ package io.metersphere.api.service; +import io.metersphere.api.dto.definition.ApiSyncCaseRequest; import io.metersphere.api.dto.definition.SaveApiDefinitionRequest; public interface ApiDefinitionSyncService { void syncApi(SaveApiDefinitionRequest request); + ApiSyncCaseRequest getApiSyncCaseRequest(String projectId); + } diff --git a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java index e2928db5cf..8a90fb21b7 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java @@ -19,10 +19,7 @@ import io.metersphere.api.dto.scenario.request.RequestType; import io.metersphere.base.domain.*; import io.metersphere.base.mapper.*; import io.metersphere.base.mapper.ext.*; -import io.metersphere.commons.constants.APITestStatus; -import io.metersphere.commons.constants.CommonConstants; -import io.metersphere.commons.constants.MsTestElementConstants; -import io.metersphere.commons.constants.TestPlanStatus; +import io.metersphere.commons.constants.*; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.*; import io.metersphere.controller.request.OrderRequest; @@ -59,6 +56,8 @@ import java.io.File; import java.util.*; import java.util.stream.Collectors; +import static io.metersphere.api.service.utils.ShareUtil.getTimeMills; + @Service @Transactional(rollbackFor = Exception.class) public class ApiTestCaseService { @@ -117,6 +116,9 @@ public class ApiTestCaseService { private ApiCaseExecutionInfoService apiCaseExecutionInfoService; @Resource private ExtApiDefinitionMapper extApiDefinitionMapper; + @Resource + private ProjectApplicationMapper projectApplicationMapper; + private static final String BODY_FILE_DIR = FileUtils.BODY_FILE_DIR; @@ -144,14 +146,51 @@ public class ApiTestCaseService { public List listSimple(ApiTestCaseRequest request) { request = this.initRequest(request, true, true); + if (request.getToBeUpdated() != null && request.getToBeUpdated()) { + Long toBeUpdatedTime = getToBeUpdatedTime(request.getProjectId()); + if (toBeUpdatedTime != null) { + request.setToBeUpdateTime(toBeUpdatedTime); + } + } List apiTestCases = extApiTestCaseMapper.listSimple(request); if (CollectionUtils.isEmpty(apiTestCases)) { return apiTestCases; } + buildUserInfo(apiTestCases, request.isSelectEnvironment()); return apiTestCases; } + public Long getToBeUpdatedTime(String projectId) { + ProjectApplicationExample example = new ProjectApplicationExample(); + example.createCriteria().andTypeEqualTo(ProjectApplicationType.OPEN_UPDATE_TIME.name()) + .andProjectIdEqualTo(projectId); + List projectApplications = projectApplicationMapper.selectByExample(example); + if (projectApplications == null || projectApplications.size() == 0) { + return null; + } + ProjectApplication projectApplication = projectApplications.get(0); + String typeValue = projectApplication.getTypeValue(); + if (typeValue.equals("false")) { + return null; + } + example = new ProjectApplicationExample(); + example.createCriteria().andTypeEqualTo(ProjectApplicationType.OPEN_UPDATE_RULE_TIME.name()) + .andProjectIdEqualTo(projectId); + List projectApplicationTimes = projectApplicationMapper.selectByExample(example); + if (projectApplicationTimes == null || projectApplicationTimes.size() == 0) { + return null; + } + ProjectApplication projectApplicationTime = projectApplicationTimes.get(0); + String time = projectApplicationTime.getTypeValue(); + if (StringUtils.isNotBlank(time)) { + time = "-" + time; + return getTimeMills(System.currentTimeMillis(), time); + } + return null; + } + + public void setCaseEnvironment(List apiTestCases) { for (ApiTestCaseDTO apiCase : apiTestCases) { ApiTestEnvironment environment = getApiCaseEnvironment(apiCase.getId()); @@ -826,6 +865,9 @@ public class ApiTestCaseService { apiTestCase.setRequest(requestStr); if (toBeUpdated != null) { apiTestCase.setToBeUpdated(toBeUpdated); + if (toBeUpdated) { + apiTestCase.setToBeUpdateTime(System.currentTimeMillis()); + } } batchMapper.updateByPrimaryKeySelective(apiTestCase); }); diff --git a/backend/src/main/java/io/metersphere/api/service/RemakeReportService.java b/backend/src/main/java/io/metersphere/api/service/RemakeReportService.java index 82cb84abe1..3e6e497e88 100644 --- a/backend/src/main/java/io/metersphere/api/service/RemakeReportService.java +++ b/backend/src/main/java/io/metersphere/api/service/RemakeReportService.java @@ -75,6 +75,7 @@ public class RemakeReportService { ApiDefinitionWithBLOBs apiDefinitionWithBLOBs = apiDefinitionMapper.selectByPrimaryKey(apiTestCase.getApiDefinitionId()); if (apiDefinitionWithBLOBs.getProtocol().equals("HTTP")) { apiDefinitionWithBLOBs.setToBeUpdated(true); + apiDefinitionWithBLOBs.setToBeUpdateTime(System.currentTimeMillis()); apiDefinitionMapper.updateByPrimaryKey(apiDefinitionWithBLOBs); } } @@ -117,7 +118,7 @@ public class RemakeReportService { } else if (StringUtils.equalsAny(request.getRunMode(), ApiRunMode.UI_SCENARIO_PLAN.name(), request.getRunMode(), ApiRunMode.UI_SCHEDULE_SCENARIO_PLAN.name(), ApiRunMode.UI_JENKINS_SCENARIO_PLAN.name())) { remarkUiScenarioPlan(request); - }else { + } else { ApiScenarioReportWithBLOBs report = apiScenarioReportMapper.selectByPrimaryKey(request.getReportId()); if (report != null) { report.setStatus(APITestStatus.Error.name()); diff --git a/backend/src/main/java/io/metersphere/api/service/ShareInfoService.java b/backend/src/main/java/io/metersphere/api/service/ShareInfoService.java index 42710f9f64..7a2bcce74d 100644 --- a/backend/src/main/java/io/metersphere/api/service/ShareInfoService.java +++ b/backend/src/main/java/io/metersphere/api/service/ShareInfoService.java @@ -1,6 +1,5 @@ package io.metersphere.api.service; -import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.parser.Feature; @@ -17,7 +16,6 @@ import io.metersphere.commons.json.JSONSchemaGenerator; 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 io.metersphere.i18n.Translator; import io.metersphere.service.ProjectApplicationService; import io.metersphere.track.service.TestPlanApiCaseService; @@ -33,7 +31,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.*; -import static io.metersphere.api.service.utils.ShareUtill.getTimeMills; +import static io.metersphere.api.service.utils.ShareUtil.getTimeMills; /** * @author song.tianyang @@ -211,12 +209,12 @@ public class ShareInfoService { } } JSONSchemaBodyDTO jsonSchemaBodyDTO = new JSONSchemaBodyDTO(); - if(isJsonSchema){ + if (isJsonSchema) { jsonSchemaBodyDTO.setJsonSchema(bodyObj.get("jsonSchema")); apiInfoDTO.setJsonSchemaBody(jsonSchemaBodyDTO); - String raw =JSONSchemaGenerator.getJson(JSONObject.toJSONString(bodyObj.get("jsonSchema"))); + String raw = JSONSchemaGenerator.getJson(JSONObject.toJSONString(bodyObj.get("jsonSchema"))); this.setPreviewData(previewJsonArray, raw); - }else { + } else { if (bodyObj.containsKey("raw")) { String raw = bodyObj.getString("raw"); jsonSchemaBodyDTO.setRaw(raw); @@ -405,9 +403,9 @@ public class ShareInfoService { apiInfoDTO.setRemark(apiModel.getRemark()); } if (!previewJsonArray.isEmpty()) { - if(previewJsonArray.size() == 1){ + if (previewJsonArray.size() == 1) { apiInfoDTO.setRequestPreviewData(previewJsonArray.get(0)); - }else { + } else { apiInfoDTO.setRequestPreviewData(previewJsonArray); } } diff --git a/backend/src/main/java/io/metersphere/api/service/utils/ShareUtill.java b/backend/src/main/java/io/metersphere/api/service/utils/ShareUtil.java similarity index 81% rename from backend/src/main/java/io/metersphere/api/service/utils/ShareUtill.java rename to backend/src/main/java/io/metersphere/api/service/utils/ShareUtil.java index 937f09fa5f..33f117cd73 100644 --- a/backend/src/main/java/io/metersphere/api/service/utils/ShareUtill.java +++ b/backend/src/main/java/io/metersphere/api/service/utils/ShareUtil.java @@ -2,16 +2,25 @@ package io.metersphere.api.service.utils; import org.apache.commons.lang3.StringUtils; -import java.time.*; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; -public class ShareUtill { +public class ShareUtil { private static final String UNIT_HOUR = "H"; private static final String UNIT_DAY = "D"; private static final String UNIT_MONTH = "M"; private static final String UNIT_YEAR = "Y"; - public static long getTimeMills(long time,String expr) { + /** + * return time + expr + * + * @param time + * @param expr + * @return + */ + public static long getTimeMills(long time, String expr) { Instant instant = Instant.ofEpochMilli(time); ZoneId zone = ZoneId.systemDefault(); LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, zone); @@ -27,7 +36,7 @@ public class ShareUtill { LocalDateTime date = null; String unit = expr.substring(expr.length() - 1); int quantity = Integer.parseInt(expr.substring(0, expr.length() - 1)); - if(StringUtils.equals(unit,UNIT_HOUR)){ + if (StringUtils.equals(unit, UNIT_HOUR)) { date = localDateTime.plusHours(quantity); } else if (StringUtils.equals(unit, UNIT_DAY)) { date = localDateTime.plusDays(quantity); diff --git a/backend/src/main/java/io/metersphere/base/domain/ApiDefinition.java b/backend/src/main/java/io/metersphere/base/domain/ApiDefinition.java index dded3ac9e8..1d27890327 100644 --- a/backend/src/main/java/io/metersphere/base/domain/ApiDefinition.java +++ b/backend/src/main/java/io/metersphere/base/domain/ApiDefinition.java @@ -61,5 +61,7 @@ public class ApiDefinition implements Serializable { private Boolean toBeUpdated; + private Long toBeUpdateTime; + private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/ApiDefinitionExample.java b/backend/src/main/java/io/metersphere/base/domain/ApiDefinitionExample.java index 7fd4f1648a..d854383485 100644 --- a/backend/src/main/java/io/metersphere/base/domain/ApiDefinitionExample.java +++ b/backend/src/main/java/io/metersphere/base/domain/ApiDefinitionExample.java @@ -1993,6 +1993,66 @@ public class ApiDefinitionExample { addCriterion("to_be_updated not between", value1, value2, "toBeUpdated"); return (Criteria) this; } + + public Criteria andToBeUpdateTimeIsNull() { + addCriterion("to_be_update_Time is null"); + return (Criteria) this; + } + + public Criteria andToBeUpdateTimeIsNotNull() { + addCriterion("to_be_update_Time is not null"); + return (Criteria) this; + } + + public Criteria andToBeUpdateTimeEqualTo(Long value) { + addCriterion("to_be_update_Time =", value, "toBeUpdateTime"); + return (Criteria) this; + } + + public Criteria andToBeUpdateTimeNotEqualTo(Long value) { + addCriterion("to_be_update_Time <>", value, "toBeUpdateTime"); + return (Criteria) this; + } + + public Criteria andToBeUpdateTimeGreaterThan(Long value) { + addCriterion("to_be_update_Time >", value, "toBeUpdateTime"); + return (Criteria) this; + } + + public Criteria andToBeUpdateTimeGreaterThanOrEqualTo(Long value) { + addCriterion("to_be_update_Time >=", value, "toBeUpdateTime"); + return (Criteria) this; + } + + public Criteria andToBeUpdateTimeLessThan(Long value) { + addCriterion("to_be_update_Time <", value, "toBeUpdateTime"); + return (Criteria) this; + } + + public Criteria andToBeUpdateTimeLessThanOrEqualTo(Long value) { + addCriterion("to_be_update_Time <=", value, "toBeUpdateTime"); + return (Criteria) this; + } + + public Criteria andToBeUpdateTimeIn(List values) { + addCriterion("to_be_update_Time in", values, "toBeUpdateTime"); + return (Criteria) this; + } + + public Criteria andToBeUpdateTimeNotIn(List values) { + addCriterion("to_be_update_Time not in", values, "toBeUpdateTime"); + return (Criteria) this; + } + + public Criteria andToBeUpdateTimeBetween(Long value1, Long value2) { + addCriterion("to_be_update_Time between", value1, value2, "toBeUpdateTime"); + return (Criteria) this; + } + + public Criteria andToBeUpdateTimeNotBetween(Long value1, Long value2) { + addCriterion("to_be_update_Time not between", value1, value2, "toBeUpdateTime"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/backend/src/main/java/io/metersphere/base/domain/ApiTestCase.java b/backend/src/main/java/io/metersphere/base/domain/ApiTestCase.java index 861f06d195..80357e4cd2 100644 --- a/backend/src/main/java/io/metersphere/base/domain/ApiTestCase.java +++ b/backend/src/main/java/io/metersphere/base/domain/ApiTestCase.java @@ -47,5 +47,7 @@ public class ApiTestCase implements Serializable { private Boolean toBeUpdated; + private Long toBeUpdateTime; + private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/ApiTestCaseExample.java b/backend/src/main/java/io/metersphere/base/domain/ApiTestCaseExample.java index b2cf29c7cf..a69f8fdaab 100644 --- a/backend/src/main/java/io/metersphere/base/domain/ApiTestCaseExample.java +++ b/backend/src/main/java/io/metersphere/base/domain/ApiTestCaseExample.java @@ -1503,6 +1503,66 @@ public class ApiTestCaseExample { addCriterion("to_be_updated not between", value1, value2, "toBeUpdated"); return (Criteria) this; } + + public Criteria andToBeUpdateTimeIsNull() { + addCriterion("to_be_update_Time is null"); + return (Criteria) this; + } + + public Criteria andToBeUpdateTimeIsNotNull() { + addCriterion("to_be_update_Time is not null"); + return (Criteria) this; + } + + public Criteria andToBeUpdateTimeEqualTo(Long value) { + addCriterion("to_be_update_Time =", value, "toBeUpdateTime"); + return (Criteria) this; + } + + public Criteria andToBeUpdateTimeNotEqualTo(Long value) { + addCriterion("to_be_update_Time <>", value, "toBeUpdateTime"); + return (Criteria) this; + } + + public Criteria andToBeUpdateTimeGreaterThan(Long value) { + addCriterion("to_be_update_Time >", value, "toBeUpdateTime"); + return (Criteria) this; + } + + public Criteria andToBeUpdateTimeGreaterThanOrEqualTo(Long value) { + addCriterion("to_be_update_Time >=", value, "toBeUpdateTime"); + return (Criteria) this; + } + + public Criteria andToBeUpdateTimeLessThan(Long value) { + addCriterion("to_be_update_Time <", value, "toBeUpdateTime"); + return (Criteria) this; + } + + public Criteria andToBeUpdateTimeLessThanOrEqualTo(Long value) { + addCriterion("to_be_update_Time <=", value, "toBeUpdateTime"); + return (Criteria) this; + } + + public Criteria andToBeUpdateTimeIn(List values) { + addCriterion("to_be_update_Time in", values, "toBeUpdateTime"); + return (Criteria) this; + } + + public Criteria andToBeUpdateTimeNotIn(List values) { + addCriterion("to_be_update_Time not in", values, "toBeUpdateTime"); + return (Criteria) this; + } + + public Criteria andToBeUpdateTimeBetween(Long value1, Long value2) { + addCriterion("to_be_update_Time between", value1, value2, "toBeUpdateTime"); + return (Criteria) this; + } + + public Criteria andToBeUpdateTimeNotBetween(Long value1, Long value2) { + addCriterion("to_be_update_Time not between", value1, value2, "toBeUpdateTime"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/backend/src/main/java/io/metersphere/base/mapper/ApiDefinitionMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ApiDefinitionMapper.xml index 35f80335de..5520dee447 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ApiDefinitionMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ApiDefinitionMapper.xml @@ -30,6 +30,7 @@ + @@ -99,7 +100,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, to_be_updated + `order`, ref_id, version_id, latest, to_be_updated, to_be_update_Time description, request, response, remark @@ -162,8 +163,9 @@ case_total, case_status, case_passing_rate, delete_time, delete_user_id, `order`, ref_id, version_id, latest, - to_be_updated, description, request, - response, remark) + to_be_updated, to_be_update_Time, 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}, @@ -173,8 +175,9 @@ #{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}, - #{toBeUpdated,jdbcType=BIT}, #{description,jdbcType=LONGVARCHAR}, #{request,jdbcType=LONGVARCHAR}, - #{response,jdbcType=LONGVARCHAR}, #{remark,jdbcType=LONGVARCHAR}) + #{toBeUpdated,jdbcType=BIT}, #{toBeUpdateTime,jdbcType=BIGINT}, #{description,jdbcType=LONGVARCHAR}, + #{request,jdbcType=LONGVARCHAR}, #{response,jdbcType=LONGVARCHAR}, #{remark,jdbcType=LONGVARCHAR} + ) insert into api_definition @@ -263,6 +266,9 @@ to_be_updated, + + to_be_update_Time, + description, @@ -361,6 +367,9 @@ #{toBeUpdated,jdbcType=BIT}, + + #{toBeUpdateTime,jdbcType=BIGINT}, + #{description,jdbcType=LONGVARCHAR}, @@ -468,6 +477,9 @@ to_be_updated = #{record.toBeUpdated,jdbcType=BIT}, + + to_be_update_Time = #{record.toBeUpdateTime,jdbcType=BIGINT}, + description = #{record.description,jdbcType=LONGVARCHAR}, @@ -515,6 +527,7 @@ version_id = #{record.versionId,jdbcType=VARCHAR}, latest = #{record.latest,jdbcType=BIT}, to_be_updated = #{record.toBeUpdated,jdbcType=BIT}, + to_be_update_Time = #{record.toBeUpdateTime,jdbcType=BIGINT}, description = #{record.description,jdbcType=LONGVARCHAR}, request = #{record.request,jdbcType=LONGVARCHAR}, response = #{record.response,jdbcType=LONGVARCHAR}, @@ -552,7 +565,8 @@ ref_id = #{record.refId,jdbcType=VARCHAR}, version_id = #{record.versionId,jdbcType=VARCHAR}, latest = #{record.latest,jdbcType=BIT}, - to_be_updated = #{record.toBeUpdated,jdbcType=BIT} + to_be_updated = #{record.toBeUpdated,jdbcType=BIT}, + to_be_update_Time = #{record.toBeUpdateTime,jdbcType=BIGINT} @@ -641,6 +655,9 @@ to_be_updated = #{toBeUpdated,jdbcType=BIT}, + + to_be_update_Time = #{toBeUpdateTime,jdbcType=BIGINT}, + description = #{description,jdbcType=LONGVARCHAR}, @@ -685,6 +702,7 @@ version_id = #{versionId,jdbcType=VARCHAR}, latest = #{latest,jdbcType=BIT}, to_be_updated = #{toBeUpdated,jdbcType=BIT}, + to_be_update_Time = #{toBeUpdateTime,jdbcType=BIGINT}, description = #{description,jdbcType=LONGVARCHAR}, request = #{request,jdbcType=LONGVARCHAR}, response = #{response,jdbcType=LONGVARCHAR}, @@ -719,7 +737,8 @@ ref_id = #{refId,jdbcType=VARCHAR}, version_id = #{versionId,jdbcType=VARCHAR}, latest = #{latest,jdbcType=BIT}, - to_be_updated = #{toBeUpdated,jdbcType=BIT} + to_be_updated = #{toBeUpdated,jdbcType=BIT}, + to_be_update_Time = #{toBeUpdateTime,jdbcType=BIGINT} where id = #{id,jdbcType=VARCHAR} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/ApiTestCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ApiTestCaseMapper.xml index 3a708b339b..cc1c5036cc 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ApiTestCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ApiTestCaseMapper.xml @@ -23,6 +23,7 @@ + @@ -89,7 +90,7 @@ 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, to_be_updated + delete_user_id, version, `order`, case_status, version_id, to_be_updated, to_be_update_Time description, request @@ -150,7 +151,8 @@ `status`, original_status, delete_time, delete_user_id, version, `order`, case_status, version_id, to_be_updated, - description, request) + to_be_update_Time, 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}, @@ -158,7 +160,8 @@ #{status,jdbcType=VARCHAR}, #{originalStatus,jdbcType=VARCHAR}, #{deleteTime,jdbcType=BIGINT}, #{deleteUserId,jdbcType=VARCHAR}, #{version,jdbcType=INTEGER}, #{order,jdbcType=BIGINT}, #{caseStatus,jdbcType=VARCHAR}, #{versionId,jdbcType=VARCHAR}, #{toBeUpdated,jdbcType=BIT}, - #{description,jdbcType=LONGVARCHAR}, #{request,jdbcType=LONGVARCHAR}) + #{toBeUpdateTime,jdbcType=BIGINT}, #{description,jdbcType=LONGVARCHAR}, #{request,jdbcType=LONGVARCHAR} + ) insert into api_test_case @@ -226,6 +229,9 @@ to_be_updated, + + to_be_update_Time, + description, @@ -297,6 +303,9 @@ #{toBeUpdated,jdbcType=BIT}, + + #{toBeUpdateTime,jdbcType=BIGINT}, + #{description,jdbcType=LONGVARCHAR}, @@ -377,6 +386,9 @@ to_be_updated = #{record.toBeUpdated,jdbcType=BIT}, + + to_be_update_Time = #{record.toBeUpdateTime,jdbcType=BIGINT}, + description = #{record.description,jdbcType=LONGVARCHAR}, @@ -411,6 +423,7 @@ case_status = #{record.caseStatus,jdbcType=VARCHAR}, version_id = #{record.versionId,jdbcType=VARCHAR}, to_be_updated = #{record.toBeUpdated,jdbcType=BIT}, + to_be_update_Time = #{record.toBeUpdateTime,jdbcType=BIGINT}, description = #{record.description,jdbcType=LONGVARCHAR}, request = #{record.request,jdbcType=LONGVARCHAR} @@ -439,7 +452,8 @@ `order` = #{record.order,jdbcType=BIGINT}, case_status = #{record.caseStatus,jdbcType=VARCHAR}, version_id = #{record.versionId,jdbcType=VARCHAR}, - to_be_updated = #{record.toBeUpdated,jdbcType=BIT} + to_be_updated = #{record.toBeUpdated,jdbcType=BIT}, + to_be_update_Time = #{record.toBeUpdateTime,jdbcType=BIGINT} @@ -507,6 +521,9 @@ to_be_updated = #{toBeUpdated,jdbcType=BIT}, + + to_be_update_Time = #{toBeUpdateTime,jdbcType=BIGINT}, + description = #{description,jdbcType=LONGVARCHAR}, @@ -538,6 +555,7 @@ case_status = #{caseStatus,jdbcType=VARCHAR}, version_id = #{versionId,jdbcType=VARCHAR}, to_be_updated = #{toBeUpdated,jdbcType=BIT}, + to_be_update_Time = #{toBeUpdateTime,jdbcType=BIGINT}, description = #{description,jdbcType=LONGVARCHAR}, request = #{request,jdbcType=LONGVARCHAR} where id = #{id,jdbcType=VARCHAR} @@ -563,7 +581,8 @@ `order` = #{order,jdbcType=BIGINT}, case_status = #{caseStatus,jdbcType=VARCHAR}, version_id = #{versionId,jdbcType=VARCHAR}, - to_be_updated = #{toBeUpdated,jdbcType=BIT} + to_be_updated = #{toBeUpdated,jdbcType=BIT}, + to_be_update_Time = #{toBeUpdateTime,jdbcType=BIGINT} where id = #{id,jdbcType=VARCHAR} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml index 0b721ff31e..ea3d2dc605 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml @@ -355,7 +355,7 @@ update api_definition set original_state=status, - status = 'Trash', delete_user_id = #{operator},delete_time = #{operationTime} + status = 'Trash', delete_user_id = #{operator},delete_time = #{operationTime}, to_be_updated = 'false' @@ -754,6 +754,9 @@ AND api_definition.to_be_updated = #{request.toBeUpdated} + + AND api_definition.to_be_update_time >= #{request.toBeUpdateTime} + and api_definition.id not in diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml index 555376f067..25dd7aab1c 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestCaseMapper.xml @@ -505,6 +505,9 @@ and (t1.to_be_updated = #{request.toBeUpdated} or t3.status = 'error') + + and (t1.to_be_update_time >= #{request.toBeUpdateTime}) + @@ -858,7 +861,7 @@ update api_test_case set original_status=status, - status = 'Trash',delete_time = #{deleteTime},delete_user_id = #{deleteUserId} + status = 'Trash',delete_time = #{deleteTime},delete_user_id = #{deleteUserId}, to_be_updated = 'false' where id IN #{v} diff --git a/frontend/src/business/components/project/menu/appmanage/AppManage.vue b/frontend/src/business/components/project/menu/appmanage/AppManage.vue index 79408e4004..cb078dd58b 100644 --- a/frontend/src/business/components/project/menu/appmanage/AppManage.vue +++ b/frontend/src/business/components/project/menu/appmanage/AppManage.vue @@ -392,6 +392,7 @@ export default { if (this.config.openUpdateRuleTime) { this.pastUnit = this.config.openUpdateRuleTime.substring(this.config.openUpdateRuleTime.length - 1); this.pastQuantity = this.config.openUpdateRuleTime.substring(0, this.config.openUpdateRuleTime.length - 1); + this.showSyncTimeSetting = true; } } });