feat(工作台): 待更新列表数据条件修改

--user=郭雨琦
This commit is contained in:
guoyuqi 2022-08-15 18:58:09 +08:00 committed by xiaomeinvG
parent c12a7bc99f
commit a5a416dd35
6 changed files with 71 additions and 23 deletions

View File

@ -69,14 +69,7 @@ public class ApiTestCaseController {
@PostMapping("/list/{goPage}/{pageSize}")
public Pager<List<ApiTestCaseDTO>> listSimple(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiTestCaseRequest request) {
if (request.getToBeUpdated() != null && request.getToBeUpdated()) {
if (request.getProjectId() != null) {
Long toBeUpdatedTime = apiTestCaseService.getToBeUpdatedTime(request.getProjectId());
if (toBeUpdatedTime != null) {
request.setToBeUpdateTime(toBeUpdatedTime);
}
}
}
apiTestCaseService.initRequestBySearch(request);
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
request.setSelectEnvironment(true);
return PageUtils.setPageInfo(page, apiTestCaseService.listSimple(request));

View File

@ -40,12 +40,17 @@ public class ApiTestCaseRequest extends BaseQueryRequest {
/**
* 是否进入待更新列表
*/
private Boolean toBeUpdated;
private boolean toBeUpdated;
/**
* 当前时间减去进入待更新的时间
*/
private Long toBeUpdateTime;
/**
* 进入待更新列表用例状态集合
*/
private List<String> statusList;
/**
* 是否需要查询环境字段
*/

View File

@ -120,10 +120,14 @@ public class ApiTestCaseService {
private ProjectApplicationMapper projectApplicationMapper;
@Resource
private ApiCaseBatchSyncService apiCaseSyncService;
@Resource
private ApiTestCaseSyncService apiTestCaseSyncService;
private static final String BODY_FILE_DIR = FileUtils.BODY_FILE_DIR;
private static final String DEFAULT_TIME_DATE = "-3D";
//查询测试用例详情
public ApiTestCaseWithBLOBs getInfoJenkins(String id) {
ApiTestCaseWithBLOBs apiTest = apiTestCaseMapper.selectByPrimaryKey(id);
@ -162,20 +166,26 @@ public class ApiTestCaseService {
example.createCriteria().andTypeEqualTo(ProjectApplicationType.OPEN_UPDATE_TIME.name())
.andProjectIdEqualTo(projectId);
List<ProjectApplication> projectApplications = projectApplicationMapper.selectByExample(example);
if (projectApplications == null || projectApplications.size() == 0) {
return null;
if (CollectionUtils.isEmpty(projectApplications)) {
return getTimeMills(System.currentTimeMillis(), DEFAULT_TIME_DATE);
}
example = new ProjectApplicationExample();
example.createCriteria().andTypeEqualTo(ProjectApplicationType.TRIGGER_UPDATE.name())
.andProjectIdEqualTo(projectId);
List<ProjectApplication> projectApplicationRules = projectApplicationMapper.selectByExample(example);
ProjectApplication projectApplication = projectApplications.get(0);
String typeValue = projectApplication.getTypeValue();
if (typeValue.equals("false")) {
if (CollectionUtils.isEmpty(projectApplicationRules) && StringUtils.equals(typeValue, "false")) {
return getTimeMills(System.currentTimeMillis(), DEFAULT_TIME_DATE);
} else if (StringUtils.equals(typeValue, "false")) {
return null;
}
example = new ProjectApplicationExample();
example.createCriteria().andTypeEqualTo(ProjectApplicationType.OPEN_UPDATE_RULE_TIME.name())
.andProjectIdEqualTo(projectId);
List<ProjectApplication> projectApplicationTimes = projectApplicationMapper.selectByExample(example);
if (projectApplicationTimes == null || projectApplicationTimes.size() == 0) {
return null;
if (CollectionUtils.isEmpty(projectApplications)) {
return getTimeMills(System.currentTimeMillis(), DEFAULT_TIME_DATE);
}
ProjectApplication projectApplicationTime = projectApplicationTimes.get(0);
String time = projectApplicationTime.getTypeValue();
@ -452,6 +462,7 @@ public class ApiTestCaseService {
} else {
test.setTags(request.getTags());
}
apiTestCaseSyncService.setCaseUpdateValue(test);
apiTestCaseMapper.updateByPrimaryKeySelective(test);
saveFollows(test.getId(), request.getFollows());
}
@ -1272,4 +1283,20 @@ public class ApiTestCaseService {
public List<ExecuteResultCountDTO> selectExecuteResultByProjectId(String projectId) {
return extApiTestCaseMapper.selectExecuteResultByProjectId(projectId);
}
public void initRequestBySearch(ApiTestCaseRequest request) {
if (!request.isToBeUpdated() || StringUtils.isBlank(request.getProjectId())) {
return;
}
Long toBeUpdatedTime = this.getToBeUpdatedTime(request.getProjectId());
if (toBeUpdatedTime != null) {
request.setToBeUpdateTime(toBeUpdatedTime);
}
List<String> syncRuleCaseStatus = apiTestCaseSyncService.getSyncRuleCaseStatus(request.getProjectId());
if (CollectionUtils.isEmpty(syncRuleCaseStatus)) {
syncRuleCaseStatus = new ArrayList<>();
}
request.setStatusList(syncRuleCaseStatus);
}
}

View File

@ -2,9 +2,15 @@ package io.metersphere.api.service;
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
import java.util.List;
public interface ApiTestCaseSyncService {
void setApiCaseUpdate(ApiTestCaseWithBLOBs test);
void setCaseUpdateValue(ApiTestCaseWithBLOBs test);
List<String> getSyncRuleCaseStatus(String projectId);
}

View File

@ -502,11 +502,23 @@
<if test="request.filters == null || request.filters.size() == 0 ">
and (t1.status is null or t1.status != 'Trash')
</if>
<if test="request.toBeUpdated !=null and request.toBeUpdated == true">
and ( t1.to_be_updated = #{request.toBeUpdated} or t1.status = 'error')
<if test="request.toBeUpdated !=null and request.toBeUpdated == true and request.statusList.size() > 0">
and ( t1.to_be_updated = #{request.toBeUpdated} or t1.status
in <foreach collection="request.statusList" item="value" separator="," open="(" close=")">
#{value}
</foreach>)
</if>
<if test="request.toBeUpdated !=null and request.toBeUpdated == true and request.toBeUpdateTime !=null">
and (t1.to_be_update_time >= #{request.toBeUpdateTime} or t1.status = 'error')
<if test="request.toBeUpdated !=null and request.toBeUpdated == true and request.statusList.size() == 0">
and ( t1.to_be_updated = #{request.toBeUpdated}
</if>
<if test="request.toBeUpdated !=null and request.toBeUpdated == true and request.toBeUpdateTime !=null and request.statusList.size() > 0">
and (t1.to_be_update_time >= #{request.toBeUpdateTime} or t1.status in
<foreach collection="request.statusList" item="value" separator="," open="(" close=")">
#{value}
</foreach>)
</if>
<if test="request.toBeUpdated !=null and request.toBeUpdated == true and request.toBeUpdateTime !=null and request.statusList.size() == 0">
and (t1.to_be_update_time >= #{request.toBeUpdateTime}
</if>
<include refid="queryVersionCondition">
<property name="versionTable" value="t1"/>

View File

@ -462,8 +462,7 @@ export default {
this.startSaveData(params)
this.disabledRuleBtn = !this.disabledRuleBtn;
},
setSyncTime() {
let configs = [];
buildSyncTime(configs) {
if (this.config.openUpdateTime) {
if (!this.pastQuantity) {
this.$message.error("请选择时间");
@ -483,8 +482,13 @@ export default {
});
}
configs.push({projectId: this.projectId, typeValue: this.config.openUpdateTime, type: 'OPEN_UPDATE_TIME'});
return configs;
},
setSyncTime() {
let configs = [];
this.buildSyncTime(configs);
let params = {configs};
this.startSaveData(params)
this.startSaveData(params);
},
saveSync() {
let configs = [];
@ -493,9 +497,10 @@ export default {
typeValue: JSON.stringify(this.apiSyncCaseRequest),
type: 'TRIGGER_UPDATE'
});
this.buildSyncTime(configs);
let params = {configs};
this.startSaveData(params)
this.showRuleSetting = false
this.startSaveData(params);
this.showRuleSetting = false;
}
}
};