接口测试-定时任务
This commit is contained in:
parent
4f30ba5fb1
commit
2afce7f966
|
@ -8,7 +8,7 @@ import io.metersphere.api.dto.QueryAPITestRequest;
|
|||
import io.metersphere.api.dto.SaveAPITestRequest;
|
||||
import io.metersphere.api.service.APITestService;
|
||||
import io.metersphere.base.domain.ApiTest;
|
||||
import io.metersphere.base.domain.ApiTestWithBLOBs;
|
||||
import io.metersphere.base.domain.Schedule;
|
||||
import io.metersphere.commons.constants.RoleConstants;
|
||||
import io.metersphere.commons.utils.PageUtils;
|
||||
import io.metersphere.commons.utils.Pager;
|
||||
|
@ -51,10 +51,15 @@ public class APITestController {
|
|||
}
|
||||
|
||||
@PostMapping(value = "/schedule/update")
|
||||
public void updateSchedule(@RequestBody SaveAPITestRequest request) {
|
||||
public void updateSchedule(@RequestBody Schedule request) {
|
||||
apiTestService.updateSchedule(request);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/schedule/create")
|
||||
public void createSchedule(@RequestBody Schedule request) {
|
||||
apiTestService.createSchedule(request);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/create", consumes = {"multipart/form-data"})
|
||||
public void create(@RequestPart("request") SaveAPITestRequest request, @RequestPart(value = "files") List<MultipartFile> files) {
|
||||
apiTestService.create(request, files);
|
||||
|
@ -71,7 +76,7 @@ public class APITestController {
|
|||
}
|
||||
|
||||
@GetMapping("/get/{testId}")
|
||||
public ApiTestWithBLOBs get(@PathVariable String testId) {
|
||||
public APITestResult get(@PathVariable String testId) {
|
||||
return apiTestService.get(testId);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
package io.metersphere.api.dto;
|
||||
|
||||
import io.metersphere.base.domain.ApiTestWithBLOBs;
|
||||
import io.metersphere.base.domain.ApiTest;
|
||||
import io.metersphere.base.domain.Schedule;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public class APITestResult extends ApiTestWithBLOBs {
|
||||
public class APITestResult extends ApiTest {
|
||||
|
||||
private String projectName;
|
||||
|
||||
private String userName;
|
||||
|
||||
private Schedule schedule;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package io.metersphere.api.dto;
|
||||
|
||||
import io.metersphere.api.dto.scenario.Scenario;
|
||||
import io.metersphere.dto.ScheduleDTO;
|
||||
import io.metersphere.base.domain.Schedule;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
|
@ -19,5 +19,5 @@ public class SaveAPITestRequest {
|
|||
|
||||
private List<Scenario> scenarioDefinition;
|
||||
|
||||
private ScheduleDTO schedule;
|
||||
private Schedule schedule;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,10 @@ import io.metersphere.base.mapper.ApiTestFileMapper;
|
|||
import io.metersphere.base.mapper.ApiTestMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtApiTestMapper;
|
||||
import io.metersphere.commons.constants.APITestStatus;
|
||||
import io.metersphere.commons.constants.ScheduleGroup;
|
||||
import io.metersphere.commons.constants.ScheduleType;
|
||||
import io.metersphere.commons.exception.MSException;
|
||||
import io.metersphere.commons.utils.BeanUtils;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import io.metersphere.commons.utils.ServiceUtils;
|
||||
import io.metersphere.commons.utils.SessionUtils;
|
||||
|
@ -18,6 +21,7 @@ import io.metersphere.i18n.Translator;
|
|||
import io.metersphere.job.QuartzManager;
|
||||
import io.metersphere.job.sechedule.ApiTestJob;
|
||||
import io.metersphere.service.FileService;
|
||||
import io.metersphere.service.ScheduleService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.quartz.JobDataMap;
|
||||
import org.quartz.JobKey;
|
||||
|
@ -54,6 +58,8 @@ public class APITestService {
|
|||
private JMeterService jMeterService;
|
||||
@Resource
|
||||
private APIReportService apiReportService;
|
||||
@Resource
|
||||
private ScheduleService scheduleService;
|
||||
|
||||
public List<APITestResult> list(QueryAPITestRequest request) {
|
||||
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
|
||||
|
@ -69,7 +75,7 @@ public class APITestService {
|
|||
if (files == null || files.isEmpty()) {
|
||||
throw new IllegalArgumentException(Translator.get("file_cannot_be_null"));
|
||||
}
|
||||
ApiTestWithBLOBs test = createTest(request);
|
||||
ApiTest test = createTest(request);
|
||||
saveFile(test.getId(), files);
|
||||
}
|
||||
|
||||
|
@ -78,7 +84,7 @@ public class APITestService {
|
|||
throw new IllegalArgumentException(Translator.get("file_cannot_be_null"));
|
||||
}
|
||||
deleteFileByTestId(request.getId());
|
||||
ApiTestWithBLOBs test = updateTest(request);
|
||||
ApiTest test = updateTest(request);
|
||||
saveFile(test.getId(), files);
|
||||
}
|
||||
|
||||
|
@ -91,7 +97,7 @@ public class APITestService {
|
|||
}
|
||||
|
||||
// copy test
|
||||
ApiTestWithBLOBs copy = get(request.getId());
|
||||
ApiTest copy = get(request.getId());
|
||||
copy.setId(UUID.randomUUID().toString());
|
||||
copy.setName(request.getName());
|
||||
copy.setCreateTime(System.currentTimeMillis());
|
||||
|
@ -109,8 +115,12 @@ public class APITestService {
|
|||
}
|
||||
}
|
||||
|
||||
public ApiTestWithBLOBs get(String id) {
|
||||
return apiTestMapper.selectByPrimaryKey(id);
|
||||
public APITestResult get(String id) {
|
||||
APITestResult apiTest = new APITestResult();
|
||||
BeanUtils.copyBean(apiTest, apiTestMapper.selectByPrimaryKey(id));
|
||||
Schedule schedule = scheduleService.getScheduleByResource(id, ScheduleGroup.API_TEST.name());
|
||||
apiTest.setSchedule(schedule);
|
||||
return apiTest;
|
||||
}
|
||||
|
||||
public List<ApiTest> getApiTestByProjectId(String projectId) {
|
||||
|
@ -139,7 +149,7 @@ public class APITestService {
|
|||
}
|
||||
|
||||
public void changeStatus(String id, APITestStatus status) {
|
||||
ApiTestWithBLOBs apiTest = new ApiTestWithBLOBs();
|
||||
ApiTest apiTest = new ApiTest();
|
||||
apiTest.setId(id);
|
||||
apiTest.setStatus(status.name());
|
||||
apiTestMapper.updateByPrimaryKeySelective(apiTest);
|
||||
|
@ -153,9 +163,9 @@ public class APITestService {
|
|||
}
|
||||
}
|
||||
|
||||
private ApiTestWithBLOBs updateTest(SaveAPITestRequest request) {
|
||||
private ApiTest updateTest(SaveAPITestRequest request) {
|
||||
checkNameExist(request);
|
||||
final ApiTestWithBLOBs test = new ApiTestWithBLOBs();
|
||||
final ApiTest test = new ApiTest();
|
||||
test.setId(request.getId());
|
||||
test.setName(request.getName());
|
||||
test.setProjectId(request.getProjectId());
|
||||
|
@ -166,9 +176,9 @@ public class APITestService {
|
|||
return test;
|
||||
}
|
||||
|
||||
private ApiTestWithBLOBs createTest(SaveAPITestRequest request) {
|
||||
private ApiTest createTest(SaveAPITestRequest request) {
|
||||
checkNameExist(request);
|
||||
final ApiTestWithBLOBs test = new ApiTestWithBLOBs();
|
||||
final ApiTest test = new ApiTest();
|
||||
test.setId(request.getId());
|
||||
test.setName(request.getName());
|
||||
test.setProjectId(request.getProjectId());
|
||||
|
@ -215,34 +225,44 @@ public class APITestService {
|
|||
}
|
||||
}
|
||||
|
||||
public void updateSchedule(SaveAPITestRequest request) {
|
||||
public void updateSchedule(Schedule request) {
|
||||
scheduleService.editSchedule(request);
|
||||
updateApiTestCronJob(request);
|
||||
}
|
||||
|
||||
ApiTestWithBLOBs apiTest = new ApiTestWithBLOBs();
|
||||
apiTest.setId(request.getId());
|
||||
apiTest.setSchedule(JSONObject.toJSONString(request.getSchedule()));
|
||||
apiTest.setUpdateTime(System.currentTimeMillis());
|
||||
apiTestMapper.updateByPrimaryKeySelective(apiTest);
|
||||
public void createSchedule(Schedule request) {
|
||||
scheduleService.addSchedule(buildApiTestSchedule(request));
|
||||
updateApiTestCronJob(request);
|
||||
}
|
||||
|
||||
Boolean enable = request.getSchedule().getEnable();
|
||||
String cronExpression = request.getSchedule().getCronExpression();
|
||||
private Schedule buildApiTestSchedule(Schedule request) {
|
||||
Schedule schedule = new Schedule();
|
||||
schedule.setResourceId(request.getResourceId());
|
||||
schedule.setEnable(request.getEnable());
|
||||
schedule.setValue(request.getValue().trim());
|
||||
schedule.setGroup(ScheduleGroup.API_TEST.name());
|
||||
schedule.setKey(request.getResourceId());
|
||||
schedule.setType(ScheduleType.CRON.name());
|
||||
return schedule;
|
||||
}
|
||||
|
||||
private void updateApiTestCronJob(Schedule request) {
|
||||
Boolean enable = request.getEnable();
|
||||
String cronExpression = request.getValue();
|
||||
if (enable != null && enable && StringUtils.isNotBlank(cronExpression)) {
|
||||
try {
|
||||
JobDataMap jobDataMap = new JobDataMap();
|
||||
jobDataMap.put("testId", request.getId());
|
||||
jobDataMap.put("cronExpression", cronExpression);
|
||||
QuartzManager.addOrUpdateCronJob(new JobKey(request.getId()), new TriggerKey(request.getId()), ApiTestJob.class, cronExpression, jobDataMap);
|
||||
QuartzManager.addOrUpdateCronJob(ApiTestJob.getJobKey(request.getResourceId()),
|
||||
ApiTestJob.getTriggerKey(request.getResourceId()), ApiTestJob.class, cronExpression, QuartzManager.getDefaultJobDataMap(request.getResourceId(), cronExpression));
|
||||
} catch (SchedulerException e) {
|
||||
LogUtil.error(e.getMessage(), e);
|
||||
MSException.throwException("定时任务开启异常");
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
QuartzManager.removeJob(new JobKey(request.getId()), new TriggerKey(request.getId()));
|
||||
QuartzManager.removeJob(ApiTestJob.getJobKey(request.getResourceId()), ApiTestJob.getTriggerKey(request.getResourceId()));
|
||||
} catch (Exception e) {
|
||||
MSException.throwException("定时任务关闭异常");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,5 +21,7 @@ public class ApiTest implements Serializable {
|
|||
|
||||
private Long updateTime;
|
||||
|
||||
private String scenarioDefinition;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package io.metersphere.base.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ApiTestWithBLOBs extends ApiTest implements Serializable {
|
||||
private String scenarioDefinition;
|
||||
|
||||
private String schedule;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package io.metersphere.base.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Schedule implements Serializable {
|
||||
private String id;
|
||||
|
||||
private String key;
|
||||
|
||||
private String type;
|
||||
|
||||
private String value;
|
||||
|
||||
private String group;
|
||||
|
||||
private Boolean enable;
|
||||
|
||||
private String resourceId;
|
||||
|
||||
private String customData;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
|
@ -0,0 +1,680 @@
|
|||
package io.metersphere.base.domain;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ScheduleExample {
|
||||
protected String orderByClause;
|
||||
|
||||
protected boolean distinct;
|
||||
|
||||
protected List<Criteria> oredCriteria;
|
||||
|
||||
public ScheduleExample() {
|
||||
oredCriteria = new ArrayList<Criteria>();
|
||||
}
|
||||
|
||||
public void setOrderByClause(String orderByClause) {
|
||||
this.orderByClause = orderByClause;
|
||||
}
|
||||
|
||||
public String getOrderByClause() {
|
||||
return orderByClause;
|
||||
}
|
||||
|
||||
public void setDistinct(boolean distinct) {
|
||||
this.distinct = distinct;
|
||||
}
|
||||
|
||||
public boolean isDistinct() {
|
||||
return distinct;
|
||||
}
|
||||
|
||||
public List<Criteria> getOredCriteria() {
|
||||
return oredCriteria;
|
||||
}
|
||||
|
||||
public void or(Criteria criteria) {
|
||||
oredCriteria.add(criteria);
|
||||
}
|
||||
|
||||
public Criteria or() {
|
||||
Criteria criteria = createCriteriaInternal();
|
||||
oredCriteria.add(criteria);
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public Criteria createCriteria() {
|
||||
Criteria criteria = createCriteriaInternal();
|
||||
if (oredCriteria.size() == 0) {
|
||||
oredCriteria.add(criteria);
|
||||
}
|
||||
return criteria;
|
||||
}
|
||||
|
||||
protected Criteria createCriteriaInternal() {
|
||||
Criteria criteria = new Criteria();
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
oredCriteria.clear();
|
||||
orderByClause = null;
|
||||
distinct = false;
|
||||
}
|
||||
|
||||
protected abstract static class GeneratedCriteria {
|
||||
protected List<Criterion> criteria;
|
||||
|
||||
protected GeneratedCriteria() {
|
||||
super();
|
||||
criteria = new ArrayList<Criterion>();
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return criteria.size() > 0;
|
||||
}
|
||||
|
||||
public List<Criterion> getAllCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
public List<Criterion> getCriteria() {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition) {
|
||||
if (condition == null) {
|
||||
throw new RuntimeException("Value for condition cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition));
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition, Object value, String property) {
|
||||
if (value == null) {
|
||||
throw new RuntimeException("Value for " + property + " cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition, value));
|
||||
}
|
||||
|
||||
protected void addCriterion(String condition, Object value1, Object value2, String property) {
|
||||
if (value1 == null || value2 == null) {
|
||||
throw new RuntimeException("Between values for " + property + " cannot be null");
|
||||
}
|
||||
criteria.add(new Criterion(condition, value1, value2));
|
||||
}
|
||||
|
||||
public Criteria andIdIsNull() {
|
||||
addCriterion("id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdIsNotNull() {
|
||||
addCriterion("id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdEqualTo(String value) {
|
||||
addCriterion("id =", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotEqualTo(String value) {
|
||||
addCriterion("id <>", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdGreaterThan(String value) {
|
||||
addCriterion("id >", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("id >=", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLessThan(String value) {
|
||||
addCriterion("id <", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("id <=", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdLike(String value) {
|
||||
addCriterion("id like", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotLike(String value) {
|
||||
addCriterion("id not like", value, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdIn(List<String> values) {
|
||||
addCriterion("id in", values, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotIn(List<String> values) {
|
||||
addCriterion("id not in", values, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdBetween(String value1, String value2) {
|
||||
addCriterion("id between", value1, value2, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andIdNotBetween(String value1, String value2) {
|
||||
addCriterion("id not between", value1, value2, "id");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andKeyIsNull() {
|
||||
addCriterion("`key` is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andKeyIsNotNull() {
|
||||
addCriterion("`key` is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andKeyEqualTo(String value) {
|
||||
addCriterion("`key` =", value, "key");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andKeyNotEqualTo(String value) {
|
||||
addCriterion("`key` <>", value, "key");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andKeyGreaterThan(String value) {
|
||||
addCriterion("`key` >", value, "key");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andKeyGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("`key` >=", value, "key");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andKeyLessThan(String value) {
|
||||
addCriterion("`key` <", value, "key");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andKeyLessThanOrEqualTo(String value) {
|
||||
addCriterion("`key` <=", value, "key");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andKeyLike(String value) {
|
||||
addCriterion("`key` like", value, "key");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andKeyNotLike(String value) {
|
||||
addCriterion("`key` not like", value, "key");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andKeyIn(List<String> values) {
|
||||
addCriterion("`key` in", values, "key");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andKeyNotIn(List<String> values) {
|
||||
addCriterion("`key` not in", values, "key");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andKeyBetween(String value1, String value2) {
|
||||
addCriterion("`key` between", value1, value2, "key");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andKeyNotBetween(String value1, String value2) {
|
||||
addCriterion("`key` not between", value1, value2, "key");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTypeIsNull() {
|
||||
addCriterion("`type` is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTypeIsNotNull() {
|
||||
addCriterion("`type` is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTypeEqualTo(String value) {
|
||||
addCriterion("`type` =", value, "type");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTypeNotEqualTo(String value) {
|
||||
addCriterion("`type` <>", value, "type");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTypeGreaterThan(String value) {
|
||||
addCriterion("`type` >", value, "type");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTypeGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("`type` >=", value, "type");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTypeLessThan(String value) {
|
||||
addCriterion("`type` <", value, "type");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTypeLessThanOrEqualTo(String value) {
|
||||
addCriterion("`type` <=", value, "type");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTypeLike(String value) {
|
||||
addCriterion("`type` like", value, "type");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTypeNotLike(String value) {
|
||||
addCriterion("`type` not like", value, "type");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTypeIn(List<String> values) {
|
||||
addCriterion("`type` in", values, "type");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTypeNotIn(List<String> values) {
|
||||
addCriterion("`type` not in", values, "type");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTypeBetween(String value1, String value2) {
|
||||
addCriterion("`type` between", value1, value2, "type");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andTypeNotBetween(String value1, String value2) {
|
||||
addCriterion("`type` not between", value1, value2, "type");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andValueIsNull() {
|
||||
addCriterion("`value` is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andValueIsNotNull() {
|
||||
addCriterion("`value` is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andValueEqualTo(String value) {
|
||||
addCriterion("`value` =", value, "value");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andValueNotEqualTo(String value) {
|
||||
addCriterion("`value` <>", value, "value");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andValueGreaterThan(String value) {
|
||||
addCriterion("`value` >", value, "value");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andValueGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("`value` >=", value, "value");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andValueLessThan(String value) {
|
||||
addCriterion("`value` <", value, "value");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andValueLessThanOrEqualTo(String value) {
|
||||
addCriterion("`value` <=", value, "value");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andValueLike(String value) {
|
||||
addCriterion("`value` like", value, "value");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andValueNotLike(String value) {
|
||||
addCriterion("`value` not like", value, "value");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andValueIn(List<String> values) {
|
||||
addCriterion("`value` in", values, "value");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andValueNotIn(List<String> values) {
|
||||
addCriterion("`value` not in", values, "value");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andValueBetween(String value1, String value2) {
|
||||
addCriterion("`value` between", value1, value2, "value");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andValueNotBetween(String value1, String value2) {
|
||||
addCriterion("`value` not between", value1, value2, "value");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andGroupIsNull() {
|
||||
addCriterion("`group` is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andGroupIsNotNull() {
|
||||
addCriterion("`group` is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andGroupEqualTo(String value) {
|
||||
addCriterion("`group` =", value, "group");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andGroupNotEqualTo(String value) {
|
||||
addCriterion("`group` <>", value, "group");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andGroupGreaterThan(String value) {
|
||||
addCriterion("`group` >", value, "group");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andGroupGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("`group` >=", value, "group");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andGroupLessThan(String value) {
|
||||
addCriterion("`group` <", value, "group");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andGroupLessThanOrEqualTo(String value) {
|
||||
addCriterion("`group` <=", value, "group");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andGroupLike(String value) {
|
||||
addCriterion("`group` like", value, "group");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andGroupNotLike(String value) {
|
||||
addCriterion("`group` not like", value, "group");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andGroupIn(List<String> values) {
|
||||
addCriterion("`group` in", values, "group");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andGroupNotIn(List<String> values) {
|
||||
addCriterion("`group` not in", values, "group");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andGroupBetween(String value1, String value2) {
|
||||
addCriterion("`group` between", value1, value2, "group");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andGroupNotBetween(String value1, String value2) {
|
||||
addCriterion("`group` not between", value1, value2, "group");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEnableIsNull() {
|
||||
addCriterion("`enable` is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEnableIsNotNull() {
|
||||
addCriterion("`enable` is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEnableEqualTo(Boolean value) {
|
||||
addCriterion("`enable` =", value, "enable");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEnableNotEqualTo(Boolean value) {
|
||||
addCriterion("`enable` <>", value, "enable");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEnableGreaterThan(Boolean value) {
|
||||
addCriterion("`enable` >", value, "enable");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEnableGreaterThanOrEqualTo(Boolean value) {
|
||||
addCriterion("`enable` >=", value, "enable");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEnableLessThan(Boolean value) {
|
||||
addCriterion("`enable` <", value, "enable");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEnableLessThanOrEqualTo(Boolean value) {
|
||||
addCriterion("`enable` <=", value, "enable");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEnableIn(List<Boolean> values) {
|
||||
addCriterion("`enable` in", values, "enable");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEnableNotIn(List<Boolean> values) {
|
||||
addCriterion("`enable` not in", values, "enable");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEnableBetween(Boolean value1, Boolean value2) {
|
||||
addCriterion("`enable` between", value1, value2, "enable");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andEnableNotBetween(Boolean value1, Boolean value2) {
|
||||
addCriterion("`enable` not between", value1, value2, "enable");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceIdIsNull() {
|
||||
addCriterion("resource_id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceIdIsNotNull() {
|
||||
addCriterion("resource_id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceIdEqualTo(String value) {
|
||||
addCriterion("resource_id =", value, "resourceId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceIdNotEqualTo(String value) {
|
||||
addCriterion("resource_id <>", value, "resourceId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceIdGreaterThan(String value) {
|
||||
addCriterion("resource_id >", value, "resourceId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("resource_id >=", value, "resourceId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceIdLessThan(String value) {
|
||||
addCriterion("resource_id <", value, "resourceId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("resource_id <=", value, "resourceId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceIdLike(String value) {
|
||||
addCriterion("resource_id like", value, "resourceId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceIdNotLike(String value) {
|
||||
addCriterion("resource_id not like", value, "resourceId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceIdIn(List<String> values) {
|
||||
addCriterion("resource_id in", values, "resourceId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceIdNotIn(List<String> values) {
|
||||
addCriterion("resource_id not in", values, "resourceId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceIdBetween(String value1, String value2) {
|
||||
addCriterion("resource_id between", value1, value2, "resourceId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andResourceIdNotBetween(String value1, String value2) {
|
||||
addCriterion("resource_id not between", value1, value2, "resourceId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Criteria extends GeneratedCriteria {
|
||||
|
||||
protected Criteria() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
public static class Criterion {
|
||||
private String condition;
|
||||
|
||||
private Object value;
|
||||
|
||||
private Object secondValue;
|
||||
|
||||
private boolean noValue;
|
||||
|
||||
private boolean singleValue;
|
||||
|
||||
private boolean betweenValue;
|
||||
|
||||
private boolean listValue;
|
||||
|
||||
private String typeHandler;
|
||||
|
||||
public String getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Object getSecondValue() {
|
||||
return secondValue;
|
||||
}
|
||||
|
||||
public boolean isNoValue() {
|
||||
return noValue;
|
||||
}
|
||||
|
||||
public boolean isSingleValue() {
|
||||
return singleValue;
|
||||
}
|
||||
|
||||
public boolean isBetweenValue() {
|
||||
return betweenValue;
|
||||
}
|
||||
|
||||
public boolean isListValue() {
|
||||
return listValue;
|
||||
}
|
||||
|
||||
public String getTypeHandler() {
|
||||
return typeHandler;
|
||||
}
|
||||
|
||||
protected Criterion(String condition) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.typeHandler = null;
|
||||
this.noValue = true;
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, String typeHandler) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.value = value;
|
||||
this.typeHandler = typeHandler;
|
||||
if (value instanceof List<?>) {
|
||||
this.listValue = true;
|
||||
} else {
|
||||
this.singleValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value) {
|
||||
this(condition, value, null);
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
|
||||
super();
|
||||
this.condition = condition;
|
||||
this.value = value;
|
||||
this.secondValue = secondValue;
|
||||
this.typeHandler = typeHandler;
|
||||
this.betweenValue = true;
|
||||
}
|
||||
|
||||
protected Criterion(String condition, Object value, Object secondValue) {
|
||||
this(condition, value, secondValue, null);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,7 +2,6 @@ package io.metersphere.base.mapper;
|
|||
|
||||
import io.metersphere.base.domain.ApiTest;
|
||||
import io.metersphere.base.domain.ApiTestExample;
|
||||
import io.metersphere.base.domain.ApiTestWithBLOBs;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
|
@ -13,25 +12,25 @@ public interface ApiTestMapper {
|
|||
|
||||
int deleteByPrimaryKey(String id);
|
||||
|
||||
int insert(ApiTestWithBLOBs record);
|
||||
int insert(ApiTest record);
|
||||
|
||||
int insertSelective(ApiTestWithBLOBs record);
|
||||
int insertSelective(ApiTest record);
|
||||
|
||||
List<ApiTestWithBLOBs> selectByExampleWithBLOBs(ApiTestExample example);
|
||||
List<ApiTest> selectByExampleWithBLOBs(ApiTestExample example);
|
||||
|
||||
List<ApiTest> selectByExample(ApiTestExample example);
|
||||
|
||||
ApiTestWithBLOBs selectByPrimaryKey(String id);
|
||||
ApiTest selectByPrimaryKey(String id);
|
||||
|
||||
int updateByExampleSelective(@Param("record") ApiTestWithBLOBs record, @Param("example") ApiTestExample example);
|
||||
int updateByExampleSelective(@Param("record") ApiTest record, @Param("example") ApiTestExample example);
|
||||
|
||||
int updateByExampleWithBLOBs(@Param("record") ApiTestWithBLOBs record, @Param("example") ApiTestExample example);
|
||||
int updateByExampleWithBLOBs(@Param("record") ApiTest record, @Param("example") ApiTestExample example);
|
||||
|
||||
int updateByExample(@Param("record") ApiTest record, @Param("example") ApiTestExample example);
|
||||
|
||||
int updateByPrimaryKeySelective(ApiTestWithBLOBs record);
|
||||
int updateByPrimaryKeySelective(ApiTest record);
|
||||
|
||||
int updateByPrimaryKeyWithBLOBs(ApiTestWithBLOBs record);
|
||||
int updateByPrimaryKeyWithBLOBs(ApiTest record);
|
||||
|
||||
int updateByPrimaryKey(ApiTest record);
|
||||
}
|
|
@ -11,9 +11,8 @@
|
|||
<result column="create_time" jdbcType="BIGINT" property="createTime" />
|
||||
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
|
||||
</resultMap>
|
||||
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.ApiTestWithBLOBs">
|
||||
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.ApiTest">
|
||||
<result column="scenario_definition" jdbcType="LONGVARCHAR" property="scenarioDefinition" />
|
||||
<result column="schedule" jdbcType="LONGVARCHAR" property="schedule" />
|
||||
</resultMap>
|
||||
<sql id="Example_Where_Clause">
|
||||
<where>
|
||||
|
@ -77,7 +76,7 @@
|
|||
id, project_id, name, description, status, user_id, create_time, update_time
|
||||
</sql>
|
||||
<sql id="Blob_Column_List">
|
||||
scenario_definition, schedule
|
||||
scenario_definition
|
||||
</sql>
|
||||
<select id="selectByExampleWithBLOBs" parameterType="io.metersphere.base.domain.ApiTestExample" resultMap="ResultMapWithBLOBs">
|
||||
select
|
||||
|
@ -127,17 +126,17 @@
|
|||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</delete>
|
||||
<insert id="insert" parameterType="io.metersphere.base.domain.ApiTestWithBLOBs">
|
||||
<insert id="insert" parameterType="io.metersphere.base.domain.ApiTest">
|
||||
insert into api_test (id, project_id, name,
|
||||
description, status, user_id,
|
||||
create_time, update_time, scenario_definition,
|
||||
schedule)
|
||||
create_time, update_time, scenario_definition
|
||||
)
|
||||
values (#{id,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
|
||||
#{description,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR},
|
||||
#{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{scenarioDefinition,jdbcType=LONGVARCHAR},
|
||||
#{schedule,jdbcType=LONGVARCHAR})
|
||||
#{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{scenarioDefinition,jdbcType=LONGVARCHAR}
|
||||
)
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="io.metersphere.base.domain.ApiTestWithBLOBs">
|
||||
<insert id="insertSelective" parameterType="io.metersphere.base.domain.ApiTest">
|
||||
insert into api_test
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
|
@ -167,9 +166,6 @@
|
|||
<if test="scenarioDefinition != null">
|
||||
scenario_definition,
|
||||
</if>
|
||||
<if test="schedule != null">
|
||||
schedule,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
|
@ -199,9 +195,6 @@
|
|||
<if test="scenarioDefinition != null">
|
||||
#{scenarioDefinition,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
<if test="schedule != null">
|
||||
#{schedule,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<select id="countByExample" parameterType="io.metersphere.base.domain.ApiTestExample" resultType="java.lang.Long">
|
||||
|
@ -240,9 +233,6 @@
|
|||
<if test="record.scenarioDefinition != null">
|
||||
scenario_definition = #{record.scenarioDefinition,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
<if test="record.schedule != null">
|
||||
schedule = #{record.schedule,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
|
@ -258,8 +248,7 @@
|
|||
user_id = #{record.userId,jdbcType=VARCHAR},
|
||||
create_time = #{record.createTime,jdbcType=BIGINT},
|
||||
update_time = #{record.updateTime,jdbcType=BIGINT},
|
||||
scenario_definition = #{record.scenarioDefinition,jdbcType=LONGVARCHAR},
|
||||
schedule = #{record.schedule,jdbcType=LONGVARCHAR}
|
||||
scenario_definition = #{record.scenarioDefinition,jdbcType=LONGVARCHAR}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
|
@ -278,7 +267,7 @@
|
|||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.base.domain.ApiTestWithBLOBs">
|
||||
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.base.domain.ApiTest">
|
||||
update api_test
|
||||
<set>
|
||||
<if test="projectId != null">
|
||||
|
@ -305,13 +294,10 @@
|
|||
<if test="scenarioDefinition != null">
|
||||
scenario_definition = #{scenarioDefinition,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
<if test="schedule != null">
|
||||
schedule = #{schedule,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
<update id="updateByPrimaryKeyWithBLOBs" parameterType="io.metersphere.base.domain.ApiTestWithBLOBs">
|
||||
<update id="updateByPrimaryKeyWithBLOBs" parameterType="io.metersphere.base.domain.ApiTest">
|
||||
update api_test
|
||||
set project_id = #{projectId,jdbcType=VARCHAR},
|
||||
name = #{name,jdbcType=VARCHAR},
|
||||
|
@ -320,8 +306,7 @@
|
|||
user_id = #{userId,jdbcType=VARCHAR},
|
||||
create_time = #{createTime,jdbcType=BIGINT},
|
||||
update_time = #{updateTime,jdbcType=BIGINT},
|
||||
scenario_definition = #{scenarioDefinition,jdbcType=LONGVARCHAR},
|
||||
schedule = #{schedule,jdbcType=LONGVARCHAR}
|
||||
scenario_definition = #{scenarioDefinition,jdbcType=LONGVARCHAR}
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.ApiTest">
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
package io.metersphere.base.mapper;
|
||||
|
||||
import io.metersphere.base.domain.Schedule;
|
||||
import io.metersphere.base.domain.ScheduleExample;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
public interface ScheduleMapper {
|
||||
long countByExample(ScheduleExample example);
|
||||
|
||||
int deleteByExample(ScheduleExample example);
|
||||
|
||||
int deleteByPrimaryKey(String id);
|
||||
|
||||
int insert(Schedule record);
|
||||
|
||||
int insertSelective(Schedule record);
|
||||
|
||||
List<Schedule> selectByExampleWithBLOBs(ScheduleExample example);
|
||||
|
||||
List<Schedule> selectByExample(ScheduleExample example);
|
||||
|
||||
Schedule selectByPrimaryKey(String id);
|
||||
|
||||
int updateByExampleSelective(@Param("record") Schedule record, @Param("example") ScheduleExample example);
|
||||
|
||||
int updateByExampleWithBLOBs(@Param("record") Schedule record, @Param("example") ScheduleExample example);
|
||||
|
||||
int updateByExample(@Param("record") Schedule record, @Param("example") ScheduleExample example);
|
||||
|
||||
int updateByPrimaryKeySelective(Schedule record);
|
||||
|
||||
int updateByPrimaryKeyWithBLOBs(Schedule record);
|
||||
|
||||
int updateByPrimaryKey(Schedule record);
|
||||
}
|
|
@ -0,0 +1,304 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="io.metersphere.base.mapper.ScheduleMapper">
|
||||
<resultMap id="BaseResultMap" type="io.metersphere.base.domain.Schedule">
|
||||
<id column="id" jdbcType="VARCHAR" property="id" />
|
||||
<result column="key" jdbcType="VARCHAR" property="key" />
|
||||
<result column="type" jdbcType="VARCHAR" property="type" />
|
||||
<result column="value" jdbcType="VARCHAR" property="value" />
|
||||
<result column="group" jdbcType="VARCHAR" property="group" />
|
||||
<result column="enable" jdbcType="BIT" property="enable" />
|
||||
<result column="resource_id" jdbcType="VARCHAR" property="resourceId" />
|
||||
</resultMap>
|
||||
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.Schedule">
|
||||
<result column="custom_data" jdbcType="LONGVARCHAR" property="customData" />
|
||||
</resultMap>
|
||||
<sql id="Example_Where_Clause">
|
||||
<where>
|
||||
<foreach collection="oredCriteria" item="criteria" separator="or">
|
||||
<if test="criteria.valid">
|
||||
<trim prefix="(" prefixOverrides="and" suffix=")">
|
||||
<foreach collection="criteria.criteria" item="criterion">
|
||||
<choose>
|
||||
<when test="criterion.noValue">
|
||||
and ${criterion.condition}
|
||||
</when>
|
||||
<when test="criterion.singleValue">
|
||||
and ${criterion.condition} #{criterion.value}
|
||||
</when>
|
||||
<when test="criterion.betweenValue">
|
||||
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
|
||||
</when>
|
||||
<when test="criterion.listValue">
|
||||
and ${criterion.condition}
|
||||
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
|
||||
#{listItem}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
</foreach>
|
||||
</trim>
|
||||
</if>
|
||||
</foreach>
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Update_By_Example_Where_Clause">
|
||||
<where>
|
||||
<foreach collection="example.oredCriteria" item="criteria" separator="or">
|
||||
<if test="criteria.valid">
|
||||
<trim prefix="(" prefixOverrides="and" suffix=")">
|
||||
<foreach collection="criteria.criteria" item="criterion">
|
||||
<choose>
|
||||
<when test="criterion.noValue">
|
||||
and ${criterion.condition}
|
||||
</when>
|
||||
<when test="criterion.singleValue">
|
||||
and ${criterion.condition} #{criterion.value}
|
||||
</when>
|
||||
<when test="criterion.betweenValue">
|
||||
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
|
||||
</when>
|
||||
<when test="criterion.listValue">
|
||||
and ${criterion.condition}
|
||||
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
|
||||
#{listItem}
|
||||
</foreach>
|
||||
</when>
|
||||
</choose>
|
||||
</foreach>
|
||||
</trim>
|
||||
</if>
|
||||
</foreach>
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
id, `key`, `type`, `value`, `group`, `enable`, resource_id
|
||||
</sql>
|
||||
<sql id="Blob_Column_List">
|
||||
custom_data
|
||||
</sql>
|
||||
<select id="selectByExampleWithBLOBs" parameterType="io.metersphere.base.domain.ScheduleExample" resultMap="ResultMapWithBLOBs">
|
||||
select
|
||||
<if test="distinct">
|
||||
distinct
|
||||
</if>
|
||||
<include refid="Base_Column_List" />
|
||||
,
|
||||
<include refid="Blob_Column_List" />
|
||||
from schedule
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
<if test="orderByClause != null">
|
||||
order by ${orderByClause}
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectByExample" parameterType="io.metersphere.base.domain.ScheduleExample" resultMap="BaseResultMap">
|
||||
select
|
||||
<if test="distinct">
|
||||
distinct
|
||||
</if>
|
||||
<include refid="Base_Column_List" />
|
||||
from schedule
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
<if test="orderByClause != null">
|
||||
order by ${orderByClause}
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="ResultMapWithBLOBs">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
,
|
||||
<include refid="Blob_Column_List" />
|
||||
from schedule
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
|
||||
delete from schedule
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</delete>
|
||||
<delete id="deleteByExample" parameterType="io.metersphere.base.domain.ScheduleExample">
|
||||
delete from schedule
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</delete>
|
||||
<insert id="insert" parameterType="io.metersphere.base.domain.Schedule">
|
||||
insert into schedule (id, `key`, `type`,
|
||||
`value`, `group`, `enable`, resource_id,
|
||||
custom_data)
|
||||
values (#{id,jdbcType=VARCHAR}, #{key,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR},
|
||||
#{value,jdbcType=VARCHAR}, #{group,jdbcType=VARCHAR}, #{enable,jdbcType=BIT}, #{resourceId,jdbcType=VARCHAR},
|
||||
#{customData,jdbcType=LONGVARCHAR})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="io.metersphere.base.domain.Schedule">
|
||||
insert into schedule
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
id,
|
||||
</if>
|
||||
<if test="key != null">
|
||||
`key`,
|
||||
</if>
|
||||
<if test="type != null">
|
||||
`type`,
|
||||
</if>
|
||||
<if test="value != null">
|
||||
`value`,
|
||||
</if>
|
||||
<if test="group != null">
|
||||
`group`,
|
||||
</if>
|
||||
<if test="enable != null">
|
||||
`enable`,
|
||||
</if>
|
||||
<if test="resourceId != null">
|
||||
resource_id,
|
||||
</if>
|
||||
<if test="customData != null">
|
||||
custom_data,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
#{id,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="key != null">
|
||||
#{key,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="type != null">
|
||||
#{type,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="value != null">
|
||||
#{value,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="group != null">
|
||||
#{group,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="enable != null">
|
||||
#{enable,jdbcType=BIT},
|
||||
</if>
|
||||
<if test="resourceId != null">
|
||||
#{resourceId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="customData != null">
|
||||
#{customData,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<select id="countByExample" parameterType="io.metersphere.base.domain.ScheduleExample" resultType="java.lang.Long">
|
||||
select count(*) from schedule
|
||||
<if test="_parameter != null">
|
||||
<include refid="Example_Where_Clause" />
|
||||
</if>
|
||||
</select>
|
||||
<update id="updateByExampleSelective" parameterType="map">
|
||||
update schedule
|
||||
<set>
|
||||
<if test="record.id != null">
|
||||
id = #{record.id,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.key != null">
|
||||
`key` = #{record.key,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.type != null">
|
||||
`type` = #{record.type,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.value != null">
|
||||
`value` = #{record.value,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.group != null">
|
||||
`group` = #{record.group,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.enable != null">
|
||||
`enable` = #{record.enable,jdbcType=BIT},
|
||||
</if>
|
||||
<if test="record.resourceId != null">
|
||||
resource_id = #{record.resourceId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.customData != null">
|
||||
custom_data = #{record.customData,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByExampleWithBLOBs" parameterType="map">
|
||||
update schedule
|
||||
set id = #{record.id,jdbcType=VARCHAR},
|
||||
`key` = #{record.key,jdbcType=VARCHAR},
|
||||
`type` = #{record.type,jdbcType=VARCHAR},
|
||||
`value` = #{record.value,jdbcType=VARCHAR},
|
||||
`group` = #{record.group,jdbcType=VARCHAR},
|
||||
`enable` = #{record.enable,jdbcType=BIT},
|
||||
resource_id = #{record.resourceId,jdbcType=VARCHAR},
|
||||
custom_data = #{record.customData,jdbcType=LONGVARCHAR}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByExample" parameterType="map">
|
||||
update schedule
|
||||
set id = #{record.id,jdbcType=VARCHAR},
|
||||
`key` = #{record.key,jdbcType=VARCHAR},
|
||||
`type` = #{record.type,jdbcType=VARCHAR},
|
||||
`value` = #{record.value,jdbcType=VARCHAR},
|
||||
`group` = #{record.group,jdbcType=VARCHAR},
|
||||
`enable` = #{record.enable,jdbcType=BIT},
|
||||
resource_id = #{record.resourceId,jdbcType=VARCHAR}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
</update>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="io.metersphere.base.domain.Schedule">
|
||||
update schedule
|
||||
<set>
|
||||
<if test="key != null">
|
||||
`key` = #{key,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="type != null">
|
||||
`type` = #{type,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="value != null">
|
||||
`value` = #{value,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="group != null">
|
||||
`group` = #{group,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="enable != null">
|
||||
`enable` = #{enable,jdbcType=BIT},
|
||||
</if>
|
||||
<if test="resourceId != null">
|
||||
resource_id = #{resourceId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="customData != null">
|
||||
custom_data = #{customData,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
<update id="updateByPrimaryKeyWithBLOBs" parameterType="io.metersphere.base.domain.Schedule">
|
||||
update schedule
|
||||
set `key` = #{key,jdbcType=VARCHAR},
|
||||
`type` = #{type,jdbcType=VARCHAR},
|
||||
`value` = #{value,jdbcType=VARCHAR},
|
||||
`group` = #{group,jdbcType=VARCHAR},
|
||||
`enable` = #{enable,jdbcType=BIT},
|
||||
resource_id = #{resourceId,jdbcType=VARCHAR},
|
||||
custom_data = #{customData,jdbcType=LONGVARCHAR}
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="io.metersphere.base.domain.Schedule">
|
||||
update schedule
|
||||
set `key` = #{key,jdbcType=VARCHAR},
|
||||
`type` = #{type,jdbcType=VARCHAR},
|
||||
`value` = #{value,jdbcType=VARCHAR},
|
||||
`group` = #{group,jdbcType=VARCHAR},
|
||||
`enable` = #{enable,jdbcType=BIT},
|
||||
resource_id = #{resourceId,jdbcType=VARCHAR}
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
</mapper>
|
|
@ -0,0 +1,5 @@
|
|||
package io.metersphere.commons.constants;
|
||||
|
||||
public enum ScheduleGroup {
|
||||
API_TEST, PERFORMANCE_TEST
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package io.metersphere.commons.constants;
|
||||
|
||||
public enum ScheduleType {
|
||||
CRON, SIMPLE
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package io.metersphere.controller;
|
||||
|
||||
import io.metersphere.service.ScheduleService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RequestMapping("schedule")
|
||||
@RestController
|
||||
public class ScheduleController {
|
||||
@Resource
|
||||
private ScheduleService scheduleService;
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
package io.metersphere.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class ScheduleDTO {
|
||||
private Boolean enable;
|
||||
private String cronExpression;
|
||||
}
|
|
@ -101,7 +101,7 @@ public class QuartzManager {
|
|||
|
||||
Scheduler sched = sf.getScheduler();
|
||||
|
||||
LogUtil.info("modifyCronJobTime: " + triggerKey.getName());
|
||||
LogUtil.info("modifyCronJobTime: " + triggerKey.getName() + "," + triggerKey.getGroup());
|
||||
|
||||
try {
|
||||
CronTrigger trigger = (CronTrigger) sched.getTrigger(triggerKey);
|
||||
|
@ -152,7 +152,7 @@ public class QuartzManager {
|
|||
|
||||
try {
|
||||
|
||||
LogUtil.info("modifySimpleJobTime: " + triggerKey.getName());
|
||||
LogUtil.info("modifySimpleJobTime: " + triggerKey.getName() + "," + triggerKey.getGroup());
|
||||
|
||||
SimpleTrigger trigger = (SimpleTrigger) sched.getTrigger(triggerKey);
|
||||
|
||||
|
@ -205,7 +205,7 @@ public class QuartzManager {
|
|||
|
||||
try {
|
||||
|
||||
LogUtil.info("RemoveJob: " + jobKey.getName());
|
||||
LogUtil.info("RemoveJob: " + jobKey.getName() + "," + jobKey.getGroup());
|
||||
|
||||
Scheduler sched = sf.getScheduler();
|
||||
|
||||
|
@ -282,7 +282,7 @@ public class QuartzManager {
|
|||
public static void addOrUpdateCronJob(JobKey jobKey, TriggerKey triggerKey, Class jobClass, String cron, JobDataMap jobDataMap) throws SchedulerException {
|
||||
Scheduler sched = sf.getScheduler();
|
||||
|
||||
LogUtil.info("AddOrUpdateCronJob: " + jobKey.getName());
|
||||
LogUtil.info("AddOrUpdateCronJob: " + jobKey.getName() + "," + triggerKey.getGroup());
|
||||
|
||||
if (sched.checkExists(triggerKey)) {
|
||||
modifyCronJobTime(triggerKey, cron);
|
||||
|
@ -294,4 +294,11 @@ public class QuartzManager {
|
|||
public static void addOrUpdateCronJob(JobKey jobKey, TriggerKey triggerKey, Class jobClass, String cron) throws SchedulerException {
|
||||
addOrUpdateCronJob(jobKey, triggerKey, jobClass, cron, null);
|
||||
}
|
||||
|
||||
public static JobDataMap getDefaultJobDataMap(String resourceId, String expression) {
|
||||
JobDataMap jobDataMap = new JobDataMap();
|
||||
jobDataMap.put("resourceId", resourceId);
|
||||
jobDataMap.put("expression", expression);
|
||||
return jobDataMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,41 +2,38 @@ package io.metersphere.job.sechedule;
|
|||
|
||||
import io.metersphere.api.dto.SaveAPITestRequest;
|
||||
import io.metersphere.api.service.APITestService;
|
||||
import io.metersphere.commons.constants.ScheduleGroup;
|
||||
import io.metersphere.commons.utils.CommonBeanFactory;
|
||||
import io.metersphere.commons.utils.LogUtil;
|
||||
import io.metersphere.job.QuartzManager;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.quartz.*;
|
||||
|
||||
public class ApiTestJob implements Job {
|
||||
public class ApiTestJob extends MsScheduleJob {
|
||||
|
||||
private APITestService apiTestService;
|
||||
|
||||
private String testId;
|
||||
|
||||
private String cronExpression;
|
||||
|
||||
public void setTestId(String testId) {
|
||||
this.testId = testId;
|
||||
}
|
||||
|
||||
public void setCronExpression(String cronExpression) {
|
||||
this.cronExpression = cronExpression;
|
||||
}
|
||||
|
||||
public ApiTestJob() {
|
||||
apiTestService = (APITestService) CommonBeanFactory.getBean(APITestService.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
if (StringUtils.isBlank(testId)) {
|
||||
QuartzManager.removeJob(new JobKey(testId), new TriggerKey(testId));
|
||||
if (StringUtils.isBlank(resourceId)) {
|
||||
QuartzManager.removeJob(new JobKey(resourceId), new TriggerKey(resourceId));
|
||||
}
|
||||
LogUtil.info("ApiTestSchedule Running: " + testId);
|
||||
LogUtil.info("CronExpression: " + cronExpression);
|
||||
LogUtil.info("ApiTestSchedule Running: " + resourceId);
|
||||
LogUtil.info("CronExpression: " + expression);
|
||||
SaveAPITestRequest request = new SaveAPITestRequest();
|
||||
request.setId(testId);
|
||||
request.setId(resourceId);
|
||||
apiTestService.run(request);
|
||||
}
|
||||
|
||||
public static JobKey getJobKey(String testId) {
|
||||
return new JobKey(testId, ScheduleGroup.API_TEST.name());
|
||||
}
|
||||
|
||||
public static TriggerKey getTriggerKey(String testId) {
|
||||
return new TriggerKey(testId, ScheduleGroup.API_TEST.name());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package io.metersphere.job.sechedule;
|
||||
|
||||
import org.quartz.Job;
|
||||
|
||||
public abstract class MsScheduleJob implements Job{
|
||||
|
||||
protected String resourceId;
|
||||
|
||||
protected String expression;
|
||||
|
||||
public void setResourceId(String resourceId) {
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
|
||||
public void setExpression(String expression) {
|
||||
this.expression = expression;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package io.metersphere.job.sechedule;
|
||||
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
public class PerformanceTestJob extends MsScheduleJob {
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package io.metersphere.service;
|
||||
|
||||
import io.metersphere.base.domain.Schedule;
|
||||
import io.metersphere.base.domain.ScheduleExample;
|
||||
import io.metersphere.base.mapper.ScheduleMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class ScheduleService {
|
||||
|
||||
@Resource
|
||||
private ScheduleMapper scheduleMapper;
|
||||
|
||||
public void addSchedule(Schedule schedule) {
|
||||
schedule.setId(UUID.randomUUID().toString());
|
||||
scheduleMapper.insert(schedule);
|
||||
}
|
||||
|
||||
public Schedule getSchedule(String ScheduleId) {
|
||||
return scheduleMapper.selectByPrimaryKey(ScheduleId);
|
||||
}
|
||||
|
||||
public int editSchedule(Schedule schedule) {
|
||||
return scheduleMapper.updateByPrimaryKeySelective(schedule);
|
||||
}
|
||||
|
||||
public Schedule getScheduleByResource(String resourceId, String group) {
|
||||
ScheduleExample example = new ScheduleExample();
|
||||
example.createCriteria().andResourceIdEqualTo(resourceId).andGroupEqualTo(group);
|
||||
List<Schedule> schedules = scheduleMapper.selectByExample(example);
|
||||
if (schedules.size() > 0) {
|
||||
return schedules.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int deleteSchedule(String scheduleId) {
|
||||
return scheduleMapper.deleteByPrimaryKey(scheduleId);
|
||||
}
|
||||
|
||||
public List<Schedule> listSchedule() {
|
||||
ScheduleExample example = new ScheduleExample();
|
||||
return scheduleMapper.selectByExample(example);
|
||||
}
|
||||
}
|
|
@ -8,6 +8,11 @@
|
|||
<!--<classPathEntry location="/Users/liuruibin/.m2/repository/mysql/mysql-connector-java/5.1.34/mysql-connector-java-5.1.34.jar"/>-->
|
||||
<!-- 此处指定生成针对MyBatis3的DAO -->
|
||||
<context id="mysql" targetRuntime="MyBatis3">
|
||||
<!-- 字段带`,解决列表跟关键字冲突问题 -->
|
||||
<property name="autoDelimitKeywords" value="true" />
|
||||
<property name="beginningDelimiter" value="`" />
|
||||
<property name="endingDelimiter" value="`" />
|
||||
|
||||
<plugin type="org.mybatis.generator.plugins.SerializablePlugin"/>
|
||||
<plugin type="org.mybatis.generator.plugins.UnmergeableXmlMappersPlugin" />
|
||||
<!-- Lombok插件 -->
|
||||
|
@ -59,8 +64,8 @@
|
|||
|
||||
<!--要生成的数据库表 -->
|
||||
|
||||
<table tableName="test_plan_test_case"/>
|
||||
<table tableName="test_case"/>
|
||||
<table tableName="schedule"/>
|
||||
|
||||
|
||||
</context>
|
||||
</generatorConfiguration>
|
|
@ -129,7 +129,7 @@
|
|||
name: item.name,
|
||||
status: item.status,
|
||||
scenarioDefinition: JSON.parse(item.scenarioDefinition),
|
||||
schedule: item.schedule ? JSON.parse(item.schedule) : {},
|
||||
schedule: item.schedule ? item.schedule : {},
|
||||
});
|
||||
this.$refs.config.reset();
|
||||
}
|
||||
|
@ -215,7 +215,7 @@
|
|||
},
|
||||
saveCronExpression(cronExpression) {
|
||||
this.test.schedule.enable = true;
|
||||
this.test.schedule.cronExpression = cronExpression;
|
||||
this.test.schedule.value = cronExpression;
|
||||
this.saveSchedule();
|
||||
},
|
||||
saveSchedule() {
|
||||
|
@ -224,9 +224,13 @@
|
|||
return;
|
||||
}
|
||||
let param = {};
|
||||
param.id = this.test.id;
|
||||
param.schedule = this.test.schedule;
|
||||
this.$post('/api/schedule/update', param, response => {
|
||||
param = this.test.schedule;
|
||||
param.resourceId = this.test.id;
|
||||
let url = '/api/schedule/create';
|
||||
if (param.id) {
|
||||
url = '/api/schedule/update';
|
||||
}
|
||||
this.$post(url, param, response => {
|
||||
this.$success('保存成功');
|
||||
this.getTest(this.test.id);
|
||||
});
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
<i class="el-icon-date" size="small"></i>
|
||||
<span class="character" @click="scheduleEdit">SCHEDULER</span>
|
||||
</span>
|
||||
<el-switch :disabled="!schedule.cronExpression" v-model="schedule.enable" @change="scheduleChange"/>
|
||||
<el-switch :disabled="!schedule.value" v-model="schedule.enable" @change="scheduleChange"/>
|
||||
<ms-schedule-edit :schedule="schedule" :save="save" ref="scheduleEdit"/>
|
||||
<crontab-result v-show="false" :ex="schedule.cronExpression" ref="crontabResult" @resultListChange="recentListChange"/>
|
||||
<crontab-result v-show="false" :ex="schedule.value" ref="crontabResult" @resultListChange="recentListChange"/>
|
||||
</div>
|
||||
<div>
|
||||
<span :class="{'disable-character': !schedule.enable}"> 下次执行时间:{{this.recentList.length > 0 ? this.recentList[0] : ''}} </span>
|
||||
|
@ -36,20 +36,6 @@
|
|||
}
|
||||
},
|
||||
},
|
||||
// mounted() {
|
||||
// console.log(this.schedule);
|
||||
// // this.recentList = this.$refs.crontabResult.resultList;
|
||||
// // console.log(this.recentList);
|
||||
// console.log(this.recentList+ "====");
|
||||
// },
|
||||
// watch: {
|
||||
// 'schedule.cronExpression'() {
|
||||
// console.log(this.schedule);
|
||||
// this.$refs.crontabResult.expressionChange();
|
||||
// this.recentList = this.$refs.crontabResult.resultList;
|
||||
// console.log(this.recentList);
|
||||
// }
|
||||
// },
|
||||
methods: {
|
||||
scheduleEdit() {
|
||||
if (!this.checkOpen()) {
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
<el-button type="primary" @click="showCronDialog">生成 Cron</el-button>
|
||||
<el-button type="primary" @click="saveCron">保存</el-button>
|
||||
</el-form-item>
|
||||
<crontab-result :ex="schedule.cronExpression" ref="crontabResult"/>
|
||||
<crontab-result :ex="schedule.value" ref="crontabResult"/>
|
||||
</el-form>
|
||||
<el-dialog title="生成 cron" :visible.sync="showCron" :modal="false">
|
||||
<crontab @hide="showCron=false" @fill="crontabFill" :expression="schedule.cronExpression"/>
|
||||
<crontab @hide="showCron=false" @fill="crontabFill" :expression="schedule.value"/>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
@ -32,8 +32,8 @@
|
|||
schedule: {},
|
||||
},
|
||||
watch: {
|
||||
'schedule.cronExpression'() {
|
||||
this.form.cronValue = this.schedule.cronExpression;
|
||||
'schedule.value'() {
|
||||
this.form.cronValue = this.schedule.value;
|
||||
}
|
||||
},
|
||||
data() {
|
||||
|
@ -41,7 +41,7 @@
|
|||
if (!cronValidate(cronValue)) {
|
||||
callback(new Error('Cron 表达式格式错误'));
|
||||
} else {
|
||||
this.schedule.cronExpression = cronValue;
|
||||
this.schedule.value = cronValue;
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
@ -62,7 +62,7 @@
|
|||
},
|
||||
crontabFill(value) {
|
||||
//确定后回传的值
|
||||
this.schedule.cronExpression = value;
|
||||
this.schedule.value = value;
|
||||
this.form.cronValue = value;
|
||||
this.$refs['from'].validate();
|
||||
},
|
||||
|
|
|
@ -5,6 +5,10 @@
|
|||
* @return True is expression is valid
|
||||
*/
|
||||
export function cronValidate(cronExpression ){
|
||||
|
||||
if (!cronExpression) {
|
||||
return false;
|
||||
}
|
||||
//alert("校验函数的开始!");
|
||||
var cronParams = cronExpression.split(" ");
|
||||
|
||||
|
|
Loading…
Reference in New Issue