fix:修改互相调用
This commit is contained in:
parent
64a731bb57
commit
8dca4bce9a
|
@ -0,0 +1,54 @@
|
||||||
|
package io.metersphere.notice.service;
|
||||||
|
|
||||||
|
import io.metersphere.api.dto.APIReportResult;
|
||||||
|
import io.metersphere.base.domain.ApiTestReportDetail;
|
||||||
|
import io.metersphere.base.domain.Schedule;
|
||||||
|
import io.metersphere.base.mapper.ApiTestReportDetailMapper;
|
||||||
|
import io.metersphere.base.mapper.ext.ExtApiTestReportMapper;
|
||||||
|
import io.metersphere.base.mapper.ext.ExtLoadTestMapper;
|
||||||
|
import io.metersphere.commons.constants.ScheduleGroup;
|
||||||
|
import io.metersphere.dto.LoadTestDTO;
|
||||||
|
import io.metersphere.service.ScheduleService;
|
||||||
|
import io.metersphere.track.request.testplan.QueryTestPlanRequest;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ApiAndPerformanceHelper {
|
||||||
|
@Resource
|
||||||
|
private ExtLoadTestMapper extLoadTestMapper;
|
||||||
|
@Resource
|
||||||
|
private ExtApiTestReportMapper extApiTestReportMapper;
|
||||||
|
@Resource
|
||||||
|
private ApiTestReportDetailMapper apiTestReportDetailMapper;
|
||||||
|
@Resource
|
||||||
|
private ScheduleService scheduleService;
|
||||||
|
|
||||||
|
public APIReportResult getApi(String reportId) {
|
||||||
|
APIReportResult result = extApiTestReportMapper.get(reportId);
|
||||||
|
ApiTestReportDetail detail = apiTestReportDetailMapper.selectByPrimaryKey(reportId);
|
||||||
|
if (detail != null) {
|
||||||
|
result.setContent(new String(detail.getContent(), StandardCharsets.UTF_8));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LoadTestDTO getPerformance(String testId) {
|
||||||
|
QueryTestPlanRequest request = new QueryTestPlanRequest();
|
||||||
|
request.setId(testId);
|
||||||
|
List<LoadTestDTO> testDTOS = extLoadTestMapper.list(request);
|
||||||
|
if (!CollectionUtils.isEmpty(testDTOS)) {
|
||||||
|
LoadTestDTO loadTestDTO = testDTOS.get(0);
|
||||||
|
Schedule schedule = scheduleService.getScheduleByResource(loadTestDTO.getId(), ScheduleGroup.PERFORMANCE_TEST.name());
|
||||||
|
loadTestDTO.setSchedule(schedule);
|
||||||
|
return loadTestDTO;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,21 +1,19 @@
|
||||||
package io.metersphere.notice.service;
|
package io.metersphere.notice.service;
|
||||||
|
|
||||||
import io.metersphere.api.dto.APIReportResult;
|
import io.metersphere.api.dto.APIReportResult;
|
||||||
import io.metersphere.api.service.APIReportService;
|
|
||||||
import io.metersphere.base.domain.Notice;
|
import io.metersphere.base.domain.Notice;
|
||||||
import io.metersphere.base.domain.SystemParameter;
|
import io.metersphere.base.domain.SystemParameter;
|
||||||
import io.metersphere.commons.constants.ParamConstants;
|
import io.metersphere.commons.constants.ParamConstants;
|
||||||
import io.metersphere.commons.utils.EncryptUtils;
|
import io.metersphere.commons.utils.EncryptUtils;
|
||||||
import io.metersphere.commons.utils.LogUtil;
|
import io.metersphere.commons.utils.LogUtil;
|
||||||
import io.metersphere.dto.LoadTestDTO;
|
import io.metersphere.dto.LoadTestDTO;
|
||||||
import io.metersphere.performance.service.PerformanceTestService;
|
|
||||||
import io.metersphere.service.SystemParameterService;
|
import io.metersphere.service.SystemParameterService;
|
||||||
import io.metersphere.service.UserService;
|
import io.metersphere.service.UserService;
|
||||||
import org.apache.commons.lang3.BooleanUtils;
|
|
||||||
import org.springframework.mail.javamail.JavaMailSenderImpl;
|
import org.springframework.mail.javamail.JavaMailSenderImpl;
|
||||||
import org.springframework.mail.javamail.MimeMessageHelper;
|
import org.springframework.mail.javamail.MimeMessageHelper;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.mail.MessagingException;
|
import javax.mail.MessagingException;
|
||||||
import javax.mail.internet.MimeMessage;
|
import javax.mail.internet.MimeMessage;
|
||||||
|
@ -25,10 +23,8 @@ import java.util.Properties;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class MailService {
|
public class MailService {
|
||||||
/* @Resource
|
|
||||||
private APIReportService apiReportService;
|
|
||||||
@Resource
|
@Resource
|
||||||
private PerformanceTestService performanceTestService;*/
|
private ApiAndPerformanceHelper apiAndPerformanceHelper;
|
||||||
@Resource
|
@Resource
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
@Resource
|
@Resource
|
||||||
|
@ -63,15 +59,15 @@ public class MailService {
|
||||||
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
|
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
|
||||||
String testName = "";
|
String testName = "";
|
||||||
String state = "";
|
String state = "";
|
||||||
/* if(type.equals("api")){
|
if (type.equals("api")) {
|
||||||
APIReportResult reportResult=apiReportService.get(id);
|
APIReportResult reportResult = apiAndPerformanceHelper.getApi(id);
|
||||||
testName = reportResult.getTestName();
|
testName = reportResult.getTestName();
|
||||||
state = reportResult.getStatus();
|
state = reportResult.getStatus();
|
||||||
} else if (type.equals("performance")) {
|
} else if (type.equals("performance")) {
|
||||||
LoadTestDTO performanceResult=performanceTestService.get(id);
|
LoadTestDTO performanceResult = apiAndPerformanceHelper.getPerformance(id);
|
||||||
testName = performanceResult.getName();
|
testName = performanceResult.getName();
|
||||||
state = performanceResult.getStatus();
|
state = performanceResult.getStatus();
|
||||||
}*/
|
}
|
||||||
String html1 = "<!DOCTYPE html>\n" +
|
String html1 = "<!DOCTYPE html>\n" +
|
||||||
"<html lang=\"en\">\n" +
|
"<html lang=\"en\">\n" +
|
||||||
"<head>\n" +
|
"<head>\n" +
|
||||||
|
@ -134,5 +130,7 @@ public class MailService {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue