parent
5a3fb68149
commit
e095baa4c3
|
@ -69,14 +69,7 @@ public class ApiTestCaseController {
|
||||||
|
|
||||||
@PostMapping("/list/{goPage}/{pageSize}")
|
@PostMapping("/list/{goPage}/{pageSize}")
|
||||||
public Pager<List<ApiTestCaseDTO>> listSimple(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiTestCaseRequest request) {
|
public Pager<List<ApiTestCaseDTO>> listSimple(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ApiTestCaseRequest request) {
|
||||||
if (request.getToBeUpdated() != null && request.getToBeUpdated()) {
|
apiTestCaseService.initRequestBySearch(request);
|
||||||
if (request.getProjectId() != null) {
|
|
||||||
Long toBeUpdatedTime = apiTestCaseService.getToBeUpdatedTime(request.getProjectId());
|
|
||||||
if (toBeUpdatedTime != null) {
|
|
||||||
request.setToBeUpdateTime(toBeUpdatedTime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
||||||
request.setSelectEnvironment(true);
|
request.setSelectEnvironment(true);
|
||||||
return PageUtils.setPageInfo(page, apiTestCaseService.listSimple(request));
|
return PageUtils.setPageInfo(page, apiTestCaseService.listSimple(request));
|
||||||
|
|
|
@ -40,12 +40,17 @@ public class ApiTestCaseRequest extends BaseQueryRequest {
|
||||||
/**
|
/**
|
||||||
* 是否进入待更新列表
|
* 是否进入待更新列表
|
||||||
*/
|
*/
|
||||||
private Boolean toBeUpdated;
|
private boolean toBeUpdated;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当前时间减去进入待更新的时间
|
* 当前时间减去进入待更新的时间
|
||||||
*/
|
*/
|
||||||
private Long toBeUpdateTime;
|
private Long toBeUpdateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 进入待更新列表用例状态集合
|
||||||
|
*/
|
||||||
|
private List<String> statusList;
|
||||||
/**
|
/**
|
||||||
* 是否需要查询环境字段
|
* 是否需要查询环境字段
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -120,10 +120,14 @@ public class ApiTestCaseService {
|
||||||
private ProjectApplicationMapper projectApplicationMapper;
|
private ProjectApplicationMapper projectApplicationMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private ApiCaseBatchSyncService apiCaseSyncService;
|
private ApiCaseBatchSyncService apiCaseSyncService;
|
||||||
|
@Resource
|
||||||
|
private ApiTestCaseSyncService apiTestCaseSyncService;
|
||||||
|
|
||||||
|
|
||||||
private static final String BODY_FILE_DIR = FileUtils.BODY_FILE_DIR;
|
private static final String BODY_FILE_DIR = FileUtils.BODY_FILE_DIR;
|
||||||
|
|
||||||
|
private static final String DEFAULT_TIME_DATE = "-3D";
|
||||||
|
|
||||||
//查询测试用例详情
|
//查询测试用例详情
|
||||||
public ApiTestCaseWithBLOBs getInfoJenkins(String id) {
|
public ApiTestCaseWithBLOBs getInfoJenkins(String id) {
|
||||||
ApiTestCaseWithBLOBs apiTest = apiTestCaseMapper.selectByPrimaryKey(id);
|
ApiTestCaseWithBLOBs apiTest = apiTestCaseMapper.selectByPrimaryKey(id);
|
||||||
|
@ -162,20 +166,26 @@ public class ApiTestCaseService {
|
||||||
example.createCriteria().andTypeEqualTo(ProjectApplicationType.OPEN_UPDATE_TIME.name())
|
example.createCriteria().andTypeEqualTo(ProjectApplicationType.OPEN_UPDATE_TIME.name())
|
||||||
.andProjectIdEqualTo(projectId);
|
.andProjectIdEqualTo(projectId);
|
||||||
List<ProjectApplication> projectApplications = projectApplicationMapper.selectByExample(example);
|
List<ProjectApplication> projectApplications = projectApplicationMapper.selectByExample(example);
|
||||||
if (projectApplications == null || projectApplications.size() == 0) {
|
if (CollectionUtils.isEmpty(projectApplications)) {
|
||||||
return null;
|
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);
|
ProjectApplication projectApplication = projectApplications.get(0);
|
||||||
String typeValue = projectApplication.getTypeValue();
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
example = new ProjectApplicationExample();
|
example = new ProjectApplicationExample();
|
||||||
example.createCriteria().andTypeEqualTo(ProjectApplicationType.OPEN_UPDATE_RULE_TIME.name())
|
example.createCriteria().andTypeEqualTo(ProjectApplicationType.OPEN_UPDATE_RULE_TIME.name())
|
||||||
.andProjectIdEqualTo(projectId);
|
.andProjectIdEqualTo(projectId);
|
||||||
List<ProjectApplication> projectApplicationTimes = projectApplicationMapper.selectByExample(example);
|
List<ProjectApplication> projectApplicationTimes = projectApplicationMapper.selectByExample(example);
|
||||||
if (projectApplicationTimes == null || projectApplicationTimes.size() == 0) {
|
if (CollectionUtils.isEmpty(projectApplications)) {
|
||||||
return null;
|
return getTimeMills(System.currentTimeMillis(), DEFAULT_TIME_DATE);
|
||||||
}
|
}
|
||||||
ProjectApplication projectApplicationTime = projectApplicationTimes.get(0);
|
ProjectApplication projectApplicationTime = projectApplicationTimes.get(0);
|
||||||
String time = projectApplicationTime.getTypeValue();
|
String time = projectApplicationTime.getTypeValue();
|
||||||
|
@ -452,6 +462,7 @@ public class ApiTestCaseService {
|
||||||
} else {
|
} else {
|
||||||
test.setTags(request.getTags());
|
test.setTags(request.getTags());
|
||||||
}
|
}
|
||||||
|
apiTestCaseSyncService.setCaseUpdateValue(test);
|
||||||
apiTestCaseMapper.updateByPrimaryKeySelective(test);
|
apiTestCaseMapper.updateByPrimaryKeySelective(test);
|
||||||
saveFollows(test.getId(), request.getFollows());
|
saveFollows(test.getId(), request.getFollows());
|
||||||
}
|
}
|
||||||
|
@ -1272,4 +1283,20 @@ public class ApiTestCaseService {
|
||||||
public List<ExecuteResultCountDTO> selectExecuteResultByProjectId(String projectId) {
|
public List<ExecuteResultCountDTO> selectExecuteResultByProjectId(String projectId) {
|
||||||
return extApiTestCaseMapper.selectExecuteResultByProjectId(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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,15 @@ package io.metersphere.api.service;
|
||||||
|
|
||||||
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
|
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
public interface ApiTestCaseSyncService {
|
public interface ApiTestCaseSyncService {
|
||||||
|
|
||||||
void setApiCaseUpdate(ApiTestCaseWithBLOBs test);
|
void setApiCaseUpdate(ApiTestCaseWithBLOBs test);
|
||||||
|
|
||||||
|
void setCaseUpdateValue(ApiTestCaseWithBLOBs test);
|
||||||
|
|
||||||
|
List<String> getSyncRuleCaseStatus(String projectId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -502,11 +502,23 @@
|
||||||
<if test="request.filters == null || request.filters.size() == 0 ">
|
<if test="request.filters == null || request.filters.size() == 0 ">
|
||||||
and (t1.status is null or t1.status != 'Trash')
|
and (t1.status is null or t1.status != 'Trash')
|
||||||
</if>
|
</if>
|
||||||
<if test="request.toBeUpdated !=null and request.toBeUpdated == true">
|
<if test="request.toBeUpdated !=null and request.toBeUpdated == true and request.statusList.size() > 0">
|
||||||
and ( t1.to_be_updated = #{request.toBeUpdated} or t1.status = 'error')
|
and ( t1.to_be_updated = #{request.toBeUpdated} or t1.status
|
||||||
|
in <foreach collection="request.statusList" item="value" separator="," open="(" close=")">
|
||||||
|
#{value}
|
||||||
|
</foreach>)
|
||||||
</if>
|
</if>
|
||||||
<if test="request.toBeUpdated !=null and request.toBeUpdated == true and request.toBeUpdateTime !=null">
|
<if test="request.toBeUpdated !=null and request.toBeUpdated == true and request.statusList.size() == 0">
|
||||||
and (t1.to_be_update_time >= #{request.toBeUpdateTime} or t1.status = 'error')
|
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>
|
</if>
|
||||||
<include refid="queryVersionCondition">
|
<include refid="queryVersionCondition">
|
||||||
<property name="versionTable" value="t1"/>
|
<property name="versionTable" value="t1"/>
|
||||||
|
|
|
@ -462,8 +462,7 @@ export default {
|
||||||
this.startSaveData(params)
|
this.startSaveData(params)
|
||||||
this.disabledRuleBtn = !this.disabledRuleBtn;
|
this.disabledRuleBtn = !this.disabledRuleBtn;
|
||||||
},
|
},
|
||||||
setSyncTime() {
|
buildSyncTime(configs) {
|
||||||
let configs = [];
|
|
||||||
if (this.config.openUpdateTime) {
|
if (this.config.openUpdateTime) {
|
||||||
if (!this.pastQuantity) {
|
if (!this.pastQuantity) {
|
||||||
this.$message.error("请选择时间");
|
this.$message.error("请选择时间");
|
||||||
|
@ -483,8 +482,13 @@ export default {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
configs.push({projectId: this.projectId, typeValue: this.config.openUpdateTime, type: 'OPEN_UPDATE_TIME'});
|
configs.push({projectId: this.projectId, typeValue: this.config.openUpdateTime, type: 'OPEN_UPDATE_TIME'});
|
||||||
|
return configs;
|
||||||
|
},
|
||||||
|
setSyncTime() {
|
||||||
|
let configs = [];
|
||||||
|
this.buildSyncTime(configs);
|
||||||
let params = {configs};
|
let params = {configs};
|
||||||
this.startSaveData(params)
|
this.startSaveData(params);
|
||||||
},
|
},
|
||||||
saveSync() {
|
saveSync() {
|
||||||
let configs = [];
|
let configs = [];
|
||||||
|
@ -493,9 +497,10 @@ export default {
|
||||||
typeValue: JSON.stringify(this.apiSyncCaseRequest),
|
typeValue: JSON.stringify(this.apiSyncCaseRequest),
|
||||||
type: 'TRIGGER_UPDATE'
|
type: 'TRIGGER_UPDATE'
|
||||||
});
|
});
|
||||||
|
this.buildSyncTime(configs);
|
||||||
let params = {configs};
|
let params = {configs};
|
||||||
this.startSaveData(params)
|
this.startSaveData(params);
|
||||||
this.showRuleSetting = false
|
this.showRuleSetting = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue