fix: 任务通知设置
This commit is contained in:
parent
3e14fd3d6b
commit
788f60b7b8
|
@ -23,7 +23,6 @@ import io.metersphere.controller.request.QueryScheduleRequest;
|
||||||
import io.metersphere.dto.ScheduleDao;
|
import io.metersphere.dto.ScheduleDao;
|
||||||
import io.metersphere.i18n.Translator;
|
import io.metersphere.i18n.Translator;
|
||||||
import io.metersphere.job.sechedule.ApiTestJob;
|
import io.metersphere.job.sechedule.ApiTestJob;
|
||||||
import io.metersphere.notice.service.MailService;
|
|
||||||
import io.metersphere.service.FileService;
|
import io.metersphere.service.FileService;
|
||||||
import io.metersphere.service.QuotaService;
|
import io.metersphere.service.QuotaService;
|
||||||
import io.metersphere.service.ScheduleService;
|
import io.metersphere.service.ScheduleService;
|
||||||
|
@ -62,8 +61,6 @@ public class APITestService {
|
||||||
private ScheduleService scheduleService;
|
private ScheduleService scheduleService;
|
||||||
@Resource
|
@Resource
|
||||||
private TestCaseService testCaseService;
|
private TestCaseService testCaseService;
|
||||||
@Resource
|
|
||||||
private MailService mailService;
|
|
||||||
|
|
||||||
private static final String BODY_FILE_DIR = "/opt/metersphere/data/body";
|
private static final String BODY_FILE_DIR = "/opt/metersphere/data/body";
|
||||||
|
|
||||||
|
@ -228,7 +225,6 @@ public class APITestService {
|
||||||
apiTest.setUserId(request.getUserId());
|
apiTest.setUserId(request.getUserId());
|
||||||
}
|
}
|
||||||
String reportId = apiReportService.create(apiTest, request.getTriggerMode());
|
String reportId = apiReportService.create(apiTest, request.getTriggerMode());
|
||||||
mailService.sendMail(reportId);
|
|
||||||
changeStatus(request.getId(), APITestStatus.Running);
|
changeStatus(request.getId(), APITestStatus.Running);
|
||||||
|
|
||||||
jMeterService.run(request.getId(), null, is);
|
jMeterService.run(request.getId(), null, is);
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
package io.metersphere.notice.controller;
|
|
||||||
|
|
||||||
import io.metersphere.notice.controller.request.NoticeRequest;
|
|
||||||
import io.metersphere.notice.service.NoticeService;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("notice")
|
|
||||||
public class NoticeController {
|
|
||||||
@Resource
|
|
||||||
private NoticeService noticeService;
|
|
||||||
@PostMapping("/save")
|
|
||||||
public void saveNotice(NoticeRequest noticeRequest){
|
|
||||||
noticeService.saveNotice(noticeRequest);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
package io.metersphere.notice.controller.request;
|
|
||||||
|
|
||||||
import io.metersphere.base.domain.Notice;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class NoticeRequest extends Notice {
|
|
||||||
private String testId;
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
package io.metersphere.notice.domain;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class Mail {
|
|
||||||
// 发送给谁
|
|
||||||
private String to;
|
|
||||||
|
|
||||||
// 发送主题
|
|
||||||
private String subject;
|
|
||||||
|
|
||||||
// 发送内容
|
|
||||||
private String content;
|
|
||||||
|
|
||||||
// 附件地址
|
|
||||||
private String filePath;
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
package io.metersphere.notice.service;
|
|
||||||
|
|
||||||
public interface MailService {
|
|
||||||
public void sendMail(String reportId);
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
package io.metersphere.notice.service;
|
|
||||||
|
|
||||||
import io.metersphere.notice.service.MailService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.mail.SimpleMailMessage;
|
|
||||||
import org.springframework.mail.javamail.JavaMailSender;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class MailServiceImpl implements MailService {
|
|
||||||
@Autowired
|
|
||||||
private JavaMailSender mailSender;
|
|
||||||
@Value("${mail.fromMail.addr}")
|
|
||||||
private String mailFrom;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendMail(String reportId) {
|
|
||||||
SimpleMailMessage message = new SimpleMailMessage();
|
|
||||||
message.setFrom(mailFrom);
|
|
||||||
message.setTo("15135125273@163.com", "wenyan.yang@fit2cloud.com");
|
|
||||||
message.setSubject("automatic");
|
|
||||||
message.setText("自动邮件发布");
|
|
||||||
try {
|
|
||||||
mailSender.send(message);
|
|
||||||
System.out.println("发送简单邮件");
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
System.out.println("发送简单邮件失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
package io.metersphere.notice.service;
|
|
||||||
|
|
||||||
import io.metersphere.base.domain.Notice;
|
|
||||||
import io.metersphere.base.mapper.NoticeMapper;
|
|
||||||
import io.metersphere.notice.controller.request.NoticeRequest;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class NoticeService {
|
|
||||||
@Resource
|
|
||||||
private NoticeMapper noticeMapper;
|
|
||||||
public void saveNotice(NoticeRequest noticeRequest){
|
|
||||||
Notice notice=new Notice();
|
|
||||||
noticeMapper.insert(notice);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -78,3 +78,4 @@ spring.servlet.multipart.max-request-size=500MB
|
||||||
management.server.port=8083
|
management.server.port=8083
|
||||||
management.endpoints.web.exposure.include=*
|
management.endpoints.web.exposure.include=*
|
||||||
|
|
||||||
|
spring.freemarker.checkTemplateLocation=false
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
server:
|
|
||||||
port: 9002
|
|
||||||
|
|
||||||
spring:
|
|
||||||
mail:
|
|
||||||
host: smtp.qq.com
|
|
||||||
username: 2363807763@qq.com
|
|
||||||
password: rerdbyjyqfbtdifb
|
|
||||||
resources:
|
|
||||||
static-locations: classpath:/resources/, classpath:/static/ ,classpath:/templates/
|
|
||||||
|
|
||||||
mail:
|
|
||||||
fromMail:
|
|
||||||
addr: 2363807763@qq.com # 发邮件者
|
|
||||||
|
|
||||||
#日志级别
|
|
||||||
logging:
|
|
||||||
level:
|
|
||||||
root: warn
|
|
||||||
com.scaffold.test.mapper: trace
|
|
||||||
com.scaffold.test.task: trace
|
|
Loading…
Reference in New Issue