This commit is contained in:
chenjianxing 2021-01-28 14:10:59 +08:00
commit b87d046dca
6 changed files with 41 additions and 8 deletions

View File

@ -217,7 +217,7 @@ public class ApiAutomationService {
ids.add(scenarioId); ids.add(scenarioId);
deleteApiScenarioReport(ids); deleteApiScenarioReport(ids);
scheduleService.deleteByResourceId(scenarioId); scheduleService.deleteScheduleAndJobByResourceId(scenarioId,ScheduleGroup.API_SCENARIO_TEST.name());
TestPlanApiScenarioExample example = new TestPlanApiScenarioExample(); TestPlanApiScenarioExample example = new TestPlanApiScenarioExample();
example.createCriteria().andApiScenarioIdEqualTo(scenarioId); example.createCriteria().andApiScenarioIdEqualTo(scenarioId);
List<TestPlanApiScenario> testPlanApiScenarioList = testPlanApiScenarioMapper.selectByExample(example); List<TestPlanApiScenario> testPlanApiScenarioList = testPlanApiScenarioMapper.selectByExample(example);
@ -282,6 +282,10 @@ public class ApiAutomationService {
public void removeToGc(List<String> apiIds) { public void removeToGc(List<String> apiIds) {
extApiScenarioMapper.removeToGc(apiIds); extApiScenarioMapper.removeToGc(apiIds);
//将这些场景的定时任务删除掉
for (String id : apiIds) {
scheduleService.deleteScheduleAndJobByResourceId(id,ScheduleGroup.API_SCENARIO_TEST.name());
}
} }
public void reduction(List<SaveApiScenarioRequest> requests) { public void reduction(List<SaveApiScenarioRequest> requests) {

View File

@ -33,5 +33,4 @@ public interface ScheduleMapper {
int updateByPrimaryKeyWithBLOBs(Schedule record); int updateByPrimaryKeyWithBLOBs(Schedule record);
int updateByPrimaryKey(Schedule record); int updateByPrimaryKey(Schedule record);
} }

View File

@ -53,14 +53,14 @@ public class MailService {
props.put("mail.smtp.starttls.enable", result); props.put("mail.smtp.starttls.enable", result);
props.put("mail.smtp.starttls.required", result); props.put("mail.smtp.starttls.required", result);
break; break;
case "smtp.anon": /* case "smtp.anon":
boolean isAnon = BooleanUtils.toBoolean(p.getParamValue()); boolean isAnon = BooleanUtils.toBoolean(p.getParamValue());
if (isAnon) { if (isAnon) {
props.put("mail.smtp.auth", "false"); props.put("mail.smtp.auth", "false");
javaMailSender.setUsername(null); javaMailSender.setUsername(null);
javaMailSender.setPassword(null); javaMailSender.setPassword(null);
} }
break; break;*/
default: default:
break; break;
} }

View File

@ -18,10 +18,7 @@ import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.controller.request.OrderRequest; import io.metersphere.controller.request.OrderRequest;
import io.metersphere.controller.request.QueryScheduleRequest; import io.metersphere.controller.request.QueryScheduleRequest;
import io.metersphere.dto.ScheduleDao; import io.metersphere.dto.ScheduleDao;
import io.metersphere.job.sechedule.ApiScenarioTestJob; import io.metersphere.job.sechedule.*;
import io.metersphere.job.sechedule.ApiTestJob;
import io.metersphere.job.sechedule.ScheduleManager;
import io.metersphere.job.sechedule.TestPlanTestJob;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.quartz.JobKey; import org.quartz.JobKey;
import org.quartz.SchedulerException; import org.quartz.SchedulerException;
@ -98,6 +95,25 @@ public class ScheduleService {
return scheduleMapper.deleteByExample(scheduleExample); return scheduleMapper.deleteByExample(scheduleExample);
} }
public int deleteScheduleAndJobByResourceId(String resourceId,String group) {
ScheduleExample scheduleExample = new ScheduleExample();
scheduleExample.createCriteria().andResourceIdEqualTo(resourceId);
removeJob(resourceId,group);
return scheduleMapper.deleteByExample(scheduleExample);
}
public void removeJob(String resourceId,String group) {
if(StringUtils.equals(ScheduleGroup.API_SCENARIO_TEST.name(),group)){
scheduleManager.removeJob(ApiScenarioTestJob.getJobKey(resourceId), ApiScenarioTestJob.getTriggerKey(resourceId));
}else if(StringUtils.equals(ScheduleGroup.TEST_PLAN_TEST.name(),group)){
scheduleManager.removeJob(TestPlanTestJob.getJobKey(resourceId), TestPlanTestJob.getTriggerKey(resourceId));
}else if(StringUtils.equals(ScheduleGroup.SWAGGER_IMPORT.name(),group)){
scheduleManager.removeJob(SwaggerUrlImportJob.getJobKey(resourceId), SwaggerUrlImportJob.getTriggerKey(resourceId));
}else{
scheduleManager.removeJob(ApiTestJob.getJobKey(resourceId), ApiTestJob.getTriggerKey(resourceId));
}
}
public List<Schedule> listSchedule() { public List<Schedule> listSchedule() {
ScheduleExample example = new ScheduleExample(); ScheduleExample example = new ScheduleExample();
return scheduleMapper.selectByExample(example); return scheduleMapper.selectByExample(example);

View File

@ -28,6 +28,7 @@ import io.metersphere.dto.BaseSystemConfigDTO;
import io.metersphere.i18n.Translator; import io.metersphere.i18n.Translator;
import io.metersphere.notice.sender.NoticeModel; import io.metersphere.notice.sender.NoticeModel;
import io.metersphere.notice.service.NoticeSendService; import io.metersphere.notice.service.NoticeSendService;
import io.metersphere.service.ScheduleService;
import io.metersphere.service.SystemParameterService; import io.metersphere.service.SystemParameterService;
import io.metersphere.track.Factory.ReportComponentFactory; import io.metersphere.track.Factory.ReportComponentFactory;
import io.metersphere.track.domain.ReportComponent; import io.metersphere.track.domain.ReportComponent;
@ -62,6 +63,8 @@ public class TestPlanService {
@Resource @Resource
ExtTestPlanMapper extTestPlanMapper; ExtTestPlanMapper extTestPlanMapper;
@Resource @Resource
ScheduleService scheduleService;
@Resource
ExtTestPlanTestCaseMapper extTestPlanTestCaseMapper; ExtTestPlanTestCaseMapper extTestPlanTestCaseMapper;
@Resource @Resource
TestCaseMapper testCaseMapper; TestCaseMapper testCaseMapper;
@ -315,6 +318,10 @@ public class TestPlanService {
testPlanProjectService.deleteTestPlanProjectByPlanId(planId); testPlanProjectService.deleteTestPlanProjectByPlanId(planId);
testPlanApiCaseService.deleteByPlanId(planId); testPlanApiCaseService.deleteByPlanId(planId);
testPlanScenarioCaseService.deleteByPlanId(planId); testPlanScenarioCaseService.deleteByPlanId(planId);
//删除定时任务
scheduleService.deleteScheduleAndJobByResourceId(planId,ScheduleGroup.TEST_PLAN_TEST.name());
int num = testPlanMapper.deleteByPrimaryKey(planId); int num = testPlanMapper.deleteByPrimaryKey(planId);
List<String> relatedUsers = new ArrayList<>(); List<String> relatedUsers = new ArrayList<>();
AddTestPlanRequest testPlans = new AddTestPlanRequest(); AddTestPlanRequest testPlans = new AddTestPlanRequest();

View File

@ -235,15 +235,22 @@
this.$refs.environmentConfig.open(getCurrentProjectID()); this.$refs.environmentConfig.open(getCurrentProjectID());
}, },
initDataSource() { initDataSource() {
let flag = false;
for (let i in this.environments) { for (let i in this.environments) {
if (this.environments[i].id === this.request.environmentId) { if (this.environments[i].id === this.request.environmentId) {
this.databaseConfigsOptions = []; this.databaseConfigsOptions = [];
this.environments[i].config.databaseConfigs.forEach(item => { this.environments[i].config.databaseConfigs.forEach(item => {
if (item.id === this.request.dataSourceId) {
flag = true;
}
this.databaseConfigsOptions.push(item); this.databaseConfigsOptions.push(item);
}); });
break; break;
} }
} }
if (!flag) {
this.request.dataSourceId = undefined;
}
}, },
setDataSource() { setDataSource() {
for (let item of this.databaseConfigsOptions) { for (let item of this.databaseConfigsOptions) {