diff --git a/backend/pom.xml b/backend/pom.xml index cfed174f33..749a7c346b 100644 --- a/backend/pom.xml +++ b/backend/pom.xml @@ -302,6 +302,24 @@ commonmark 0.15.2 + + org.jetbrains + annotations + 1.1 + compile + + + junit + junit + + + org.springframework + spring-test + + + org.springframework.boot + spring-boot-test + diff --git a/backend/src/main/java/io/metersphere/api/service/APITestService.java b/backend/src/main/java/io/metersphere/api/service/APITestService.java index 70c46f1f9e..003f7b213d 100644 --- a/backend/src/main/java/io/metersphere/api/service/APITestService.java +++ b/backend/src/main/java/io/metersphere/api/service/APITestService.java @@ -12,6 +12,7 @@ import io.metersphere.api.parse.JmeterDocumentParser; import io.metersphere.base.domain.*; import io.metersphere.base.mapper.ApiTestFileMapper; import io.metersphere.base.mapper.ApiTestMapper; +import io.metersphere.base.mapper.UserMapper; import io.metersphere.base.mapper.ext.ExtApiTestMapper; import io.metersphere.commons.constants.APITestStatus; import io.metersphere.commons.constants.FileType; @@ -23,9 +24,12 @@ import io.metersphere.controller.request.QueryScheduleRequest; import io.metersphere.dto.ScheduleDao; import io.metersphere.i18n.Translator; import io.metersphere.job.sechedule.ApiTestJob; +import io.metersphere.notice.service.MailService; +import io.metersphere.notice.service.NoticeService; import io.metersphere.service.FileService; import io.metersphere.service.QuotaService; import io.metersphere.service.ScheduleService; +import io.metersphere.service.UserService; import io.metersphere.track.service.TestCaseService; import org.apache.dubbo.common.URL; import org.apache.dubbo.common.constants.CommonConstants; @@ -44,7 +48,8 @@ import java.util.stream.Collectors; @Service @Transactional(rollbackFor = Exception.class) public class APITestService { - + @Resource + private UserService userService; @Resource private ApiTestMapper apiTestMapper; @Resource @@ -61,6 +66,10 @@ public class APITestService { private ScheduleService scheduleService; @Resource private TestCaseService testCaseService; + @Resource + private MailService mailService; + @Resource + private NoticeService noticeService; private static final String BODY_FILE_DIR = "/opt/metersphere/data/body"; @@ -214,8 +223,11 @@ public class APITestService { apiTest.setUserId(request.getUserId()); } String reportId = apiReportService.create(apiTest, request.getTriggerMode()); + if (request.getTriggerMode().equals("SCHEDULE")) { + List notice = noticeService.queryNotice(request.getId()); + mailService.sendHtml(reportId,notice,"api"); + } changeStatus(request.getId(), APITestStatus.Running); - jMeterService.run(request.getId(), null, is); return reportId; } diff --git a/backend/src/main/java/io/metersphere/base/domain/Notice.java b/backend/src/main/java/io/metersphere/base/domain/Notice.java index 3096905b54..7d00dd04e0 100644 --- a/backend/src/main/java/io/metersphere/base/domain/Notice.java +++ b/backend/src/main/java/io/metersphere/base/domain/Notice.java @@ -15,5 +15,9 @@ public class Notice implements Serializable { private String enable; + private String[] names; + + private String[] emails; + private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestReportMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestReportMapper.xml index 8b539e9659..13d49c2f48 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestReportMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestReportMapper.xml @@ -57,7 +57,16 @@ - + + SELECT r.*, t.name AS test_name, project.name AS project_name, user.name AS user_name + FROM api_test_report r JOIN api_test t ON r.test_id = t.id + LEFT JOIN project ON project.id = t.project_id + LEFT JOIN user ON user.id = r.user_id + + r.id = #{id} + + ORDER BY r.update_time DESC + SELECT t.name AS test_name, r.name, r.description, r.id, r.test_id, r.create_time, r.update_time, r.status, r.trigger_mode, @@ -125,16 +134,7 @@ ORDER BY r.update_time DESC - - SELECT r.*, t.name AS test_name, project.name AS project_name, user.name AS user_name - FROM api_test_report r JOIN api_test t ON r.test_id = t.id - LEFT JOIN project ON project.id = t.project_id - LEFT JOIN user ON user.id = r.user_id - - r.id = #{id} - - ORDER BY r.update_time DESC - + SELECT min(create_time) AS date, count(api_test_report.id) AS count, diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtSystemParameterMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtSystemParameterMapper.java new file mode 100644 index 0000000000..7fd5f72e47 --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtSystemParameterMapper.java @@ -0,0 +1,5 @@ +package io.metersphere.base.mapper.ext; + +public interface ExtSystemParameterMapper { + String email(); +} diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtSystemParameterMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtSystemParameterMapper.xml new file mode 100644 index 0000000000..db788581c5 --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtSystemParameterMapper.xml @@ -0,0 +1,8 @@ + + + + + + select param_value from system_parameter where param_key=#{smtp.account} + + \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtUserMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtUserMapper.java index 504860cc92..2a87ace5af 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtUserMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtUserMapper.java @@ -16,4 +16,6 @@ public interface ExtUserMapper { List searchUser(String condition); + List queryEmails(String[] names); + } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtUserMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtUserMapper.xml index 7fd23b5be4..c65b4abb7c 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtUserMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtUserMapper.xml @@ -33,6 +33,18 @@ order by u.update_time desc + + + SELECT + email + from user + WHERE name IN + + #{id} + + + diff --git a/backend/src/main/java/io/metersphere/job/sechedule/ApiTestJob.java b/backend/src/main/java/io/metersphere/job/sechedule/ApiTestJob.java index bb4ce5bcb0..bb855d77e7 100644 --- a/backend/src/main/java/io/metersphere/job/sechedule/ApiTestJob.java +++ b/backend/src/main/java/io/metersphere/job/sechedule/ApiTestJob.java @@ -2,6 +2,7 @@ package io.metersphere.job.sechedule; import io.metersphere.api.dto.SaveAPITestRequest; import io.metersphere.api.service.APITestService; +import io.metersphere.notice.service.MailService; import io.metersphere.commons.constants.ReportTriggerMode; import io.metersphere.commons.constants.ScheduleGroup; import io.metersphere.commons.utils.CommonBeanFactory; @@ -13,7 +14,7 @@ import org.quartz.TriggerKey; public class ApiTestJob extends MsScheduleJob { private APITestService apiTestService; - + private MailService mailService; public ApiTestJob() { apiTestService = (APITestService) CommonBeanFactory.getBean(APITestService.class); } diff --git a/backend/src/main/java/io/metersphere/notice/controller/NoticeController.java b/backend/src/main/java/io/metersphere/notice/controller/NoticeController.java new file mode 100644 index 0000000000..34b210f703 --- /dev/null +++ b/backend/src/main/java/io/metersphere/notice/controller/NoticeController.java @@ -0,0 +1,28 @@ +package io.metersphere.notice.controller; + +import io.metersphere.base.domain.Notice; +import io.metersphere.notice.controller.request.NoticeRequest; +import io.metersphere.notice.service.MailService; +import io.metersphere.notice.service.NoticeService; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.List; + +@RestController +@RequestMapping("notice") +public class NoticeController { + @Resource + private NoticeService noticeService; + + @PostMapping("/save") + public void saveNotice(@RequestBody NoticeRequest noticeRequest) { + noticeService.saveNotice(noticeRequest); + } + + @GetMapping("/query/{testId}") + public List queryNotice(@PathVariable String testId) { + return noticeService.queryNotice(testId); + } + +} diff --git a/backend/src/main/java/io/metersphere/notice/controller/request/NoticeRequest.java b/backend/src/main/java/io/metersphere/notice/controller/request/NoticeRequest.java new file mode 100644 index 0000000000..9206cfe465 --- /dev/null +++ b/backend/src/main/java/io/metersphere/notice/controller/request/NoticeRequest.java @@ -0,0 +1,12 @@ +package io.metersphere.notice.controller.request; + +import io.metersphere.base.domain.Notice; +import lombok.Data; + +import java.util.List; + +@Data +public class NoticeRequest extends Notice { + private String testId; + private List notices; +} diff --git a/backend/src/main/java/io/metersphere/notice/domain/Mail.java b/backend/src/main/java/io/metersphere/notice/domain/Mail.java new file mode 100644 index 0000000000..126e903e93 --- /dev/null +++ b/backend/src/main/java/io/metersphere/notice/domain/Mail.java @@ -0,0 +1,18 @@ +package io.metersphere.notice.domain; + +import lombok.Data; + +@Data +public class Mail { + // 发送给谁 + private String to; + + // 发送主题 + private String subject; + + // 发送内容 + private String content; + + // 附件地址 + private String filePath; +} diff --git a/backend/src/main/java/io/metersphere/notice/service/MailService.java b/backend/src/main/java/io/metersphere/notice/service/MailService.java new file mode 100644 index 0000000000..5c5d9130fa --- /dev/null +++ b/backend/src/main/java/io/metersphere/notice/service/MailService.java @@ -0,0 +1,138 @@ +package io.metersphere.notice.service; + +import io.metersphere.api.dto.APIReportResult; +import io.metersphere.api.service.APIReportService; +import io.metersphere.base.domain.Notice; +import io.metersphere.base.domain.SystemParameter; +import io.metersphere.commons.constants.ParamConstants; +import io.metersphere.commons.utils.EncryptUtils; +import io.metersphere.commons.utils.LogUtil; +import io.metersphere.dto.LoadTestDTO; +import io.metersphere.performance.service.PerformanceTestService; +import io.metersphere.service.SystemParameterService; +import io.metersphere.service.UserService; +import org.apache.commons.lang3.BooleanUtils; +import org.springframework.mail.javamail.JavaMailSenderImpl; +import org.springframework.mail.javamail.MimeMessageHelper; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import javax.mail.MessagingException; +import javax.mail.internet.MimeMessage; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; + +@Service +public class MailService { + @Resource + private APIReportService apiReportService; + @Resource + private PerformanceTestService performanceTestService; + @Resource + private UserService userService; + @Resource + private SystemParameterService systemParameterService; + + public void sendHtml(String id, List notice,String type) { + JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl(); + List paramList=systemParameterService.getParamList(ParamConstants.Classify.MAIL.getValue()); + javaMailSender.setDefaultEncoding("UTF-8"); + javaMailSender.setProtocol("smtps"); + for(SystemParameter p:paramList){ + if(p.getParamKey().equals("smtp.host")){ + javaMailSender.setHost(p.getParamValue()); + } + if(p.getParamKey().equals("smtp.port")){ + javaMailSender.setPort(Integer.parseInt(p.getParamValue())); + } + if(p.getParamKey().equals("smtp.account")){ + javaMailSender.setUsername(p.getParamValue()); + } + if(p.getParamKey().equals("smtp.password")){ + javaMailSender.setPassword(EncryptUtils.aesDecrypt(p.getParamValue()).toString()); + } + } + Properties props = new Properties(); + props.put("mail.smtp.auth", "true"); + props.put("mail.smtp.starttls.enable","true"); + props.put("mail.smtp.starttls.required","true"); + props.put("mail.smtp.timeout", "30000"); + props.put("mail.smtp.connectiontimeout", "5000"); + javaMailSender.setJavaMailProperties(props); + MimeMessage mimeMessage = javaMailSender.createMimeMessage(); + String testName=""; + String state=""; + if(type.equals("api")){ + APIReportResult reportResult=apiReportService.get(id); + testName=reportResult.getTestName(); + state=reportResult.getStatus(); + }else if(type.equals("performance")){ + LoadTestDTO performanceResult=performanceTestService.get(id); + testName=performanceResult.getName(); + state=performanceResult.getStatus(); + } + String html1="\n" + + "\n" + + "\n" + + " \n" + + " MeterSphere\n" + + "\n" + + "\n" + + " \n" + + " "+type+"定时任务结果通知\n" + + " 尊敬的用户:您好,您所执行的"+testName+"运行失败,请点击报告链接查看\n" + + " \n" + + "\n" + + ""; + String html2="\n" + + "\n" + + "\n" + + " \n" + + " MeterSphere\n" + + "\n" + + "\n" + + " \n" + + " "+type+"定时任务结果通知\n" + + " 尊敬的用户:您好,"+testName+"运行成功,请点击报告链接查看\n" + + " \n" + + "\n" + + ""; + try { + MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true); + helper.setFrom(javaMailSender.getUsername()); + helper.setSubject("MeterSphere定时任务结果通知"); + String users[] = {}; + List successEmailList=new ArrayList<>(); + List failEmailList=new ArrayList<>(); + if(notice.size()>0){ + for(Notice n:notice){ + if (n.getEnable().equals("true")&&n.getEvent().equals("执行成功")) { + successEmailList=userService.queryEmail(n.getNames()); + } + if (n.getEnable().equals("true")&&n.getEvent().equals("执行失败")) { + failEmailList=userService.queryEmail(n.getNames()); + } + + } + }else{ + LogUtil.error("Recipient information is empty"); + } + + if(state.equals("success")){ + users=successEmailList.toArray(new String[successEmailList.size()]); + helper.setText(html2,true); + }else{ + users=failEmailList.toArray(new String[failEmailList.size()]); + helper.setText(html1,true); + + } + helper.setTo(users); + javaMailSender.send(mimeMessage); + + } catch (MessagingException e) { + e.printStackTrace(); + } + } +} + diff --git a/backend/src/main/java/io/metersphere/notice/service/NoticeService.java b/backend/src/main/java/io/metersphere/notice/service/NoticeService.java new file mode 100644 index 0000000000..cbac52e361 --- /dev/null +++ b/backend/src/main/java/io/metersphere/notice/service/NoticeService.java @@ -0,0 +1,83 @@ +package io.metersphere.notice.service; + +import io.metersphere.base.domain.Notice; +import io.metersphere.base.domain.NoticeExample; +import io.metersphere.base.mapper.NoticeMapper; +import io.metersphere.notice.controller.request.NoticeRequest; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +@Service +public class NoticeService { + @Resource + private NoticeMapper noticeMapper; + public void saveNotice(NoticeRequest noticeRequest) { + NoticeExample example = new NoticeExample(); + example.createCriteria().andTestIdEqualTo(noticeRequest.getTestId()); + List notices = noticeMapper.selectByExample(example); + if (notices != null) { + noticeMapper.deleteByExample(example); + noticeRequest.getNotices().forEach(notice -> { + for(String x:notice.getNames()){ + notice.setEvent(notice.getEvent()); + notice.setEmail(notice.getEmail()); + notice.setEnable(notice.getEnable()); + notice.setTestId(noticeRequest.getTestId()); + notice.setName(x); + noticeMapper.insert(notice); + } + }); + } else { + noticeRequest.getNotices().forEach(notice -> { + notice.setEvent(noticeRequest.getEvent()); + notice.setTestId(noticeRequest.getTestId()); + noticeMapper.insert(notice); + }); + } + + } + + public List queryNotice(String id) { + NoticeExample example = new NoticeExample(); + example.createCriteria().andTestIdEqualTo(id); + List notices=noticeMapper.selectByExample(example); + List notice=new ArrayList<>(); + List success=new ArrayList<>(); + List fail=new ArrayList<>(); + String[] successArray=new String[success.size()]; + String[] failArray=new String[fail.size()]; + Notice notice1=new Notice(); + Notice notice2=new Notice(); + if(notices.size()>0){ + for(Notice n:notices){ + if(n.getEvent().equals("执行成功")){ + success.add(n.getName()); + notice1.setEnable(n.getEnable()); + notice1.setTestId(id); + notice1.setEvent(n.getEvent()); + notice1.setEmail(n.getEmail()); + } + if(n.getEvent().equals("执行失败")){ + fail.add(n.getName()); + notice2.setEnable(n.getEnable()); + notice2.setTestId(id); + notice2.setEvent(n.getEvent()); + notice2.setEmail(n.getEmail()); + } + } + successArray=success.toArray(new String[success.size()]); + failArray=fail.toArray(new String[fail.size()]); + notice1.setNames(successArray); + notice2.setNames(failArray); + notice.add(notice1); + notice.add(notice2); + } + return notice; + } + +} diff --git a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java index 64e71fa08a..97b73d1b87 100644 --- a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java +++ b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java @@ -19,6 +19,8 @@ import io.metersphere.dto.LoadTestDTO; import io.metersphere.dto.ScheduleDao; import io.metersphere.i18n.Translator; import io.metersphere.job.sechedule.PerformanceTestJob; +import io.metersphere.notice.service.MailService; +import io.metersphere.notice.service.NoticeService; import io.metersphere.performance.engine.Engine; import io.metersphere.performance.engine.EngineFactory; import io.metersphere.service.FileService; @@ -80,6 +82,10 @@ public class PerformanceTestService { private TestCaseMapper testCaseMapper; @Resource private TestCaseService testCaseService; + @Resource + private NoticeService noticeService; + @Resource + private MailService mailService; public List list(QueryTestPlanRequest request) { request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders())); @@ -231,7 +237,10 @@ public class PerformanceTestService { } startEngine(loadTest, engine, request.getTriggerMode()); - + if (request.getTriggerMode().equals("SCHEDULE")) { + List notice = noticeService.queryNotice(request.getId()); + mailService.sendHtml(engine.getReportId(),notice,"performance"); + } return engine.getReportId(); } diff --git a/backend/src/main/java/io/metersphere/service/SystemParameterService.java b/backend/src/main/java/io/metersphere/service/SystemParameterService.java index 3fdc9e461f..4042a65832 100644 --- a/backend/src/main/java/io/metersphere/service/SystemParameterService.java +++ b/backend/src/main/java/io/metersphere/service/SystemParameterService.java @@ -3,6 +3,7 @@ package io.metersphere.service; import io.metersphere.base.domain.SystemParameter; import io.metersphere.base.domain.SystemParameterExample; import io.metersphere.base.mapper.SystemParameterMapper; +import io.metersphere.base.mapper.ext.ExtSystemParameterMapper; import io.metersphere.commons.constants.ParamConstants; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.EncryptUtils; @@ -24,7 +25,12 @@ public class SystemParameterService { @Resource private SystemParameterMapper systemParameterMapper; + @Resource + private ExtSystemParameterMapper extSystemParameterMapper; + public String searchEmail(){ + return extSystemParameterMapper.email(); + } public String getSystemLanguage() { String result = StringUtils.EMPTY; SystemParameterExample example = new SystemParameterExample(); diff --git a/backend/src/main/java/io/metersphere/service/UserService.java b/backend/src/main/java/io/metersphere/service/UserService.java index ebeb4155b9..98312d541a 100644 --- a/backend/src/main/java/io/metersphere/service/UserService.java +++ b/backend/src/main/java/io/metersphere/service/UserService.java @@ -61,6 +61,9 @@ public class UserService { @Resource private WorkspaceService workspaceService; + public List queryEmail(String[] names){ + return extUserMapper.queryEmails(names); + } public UserDTO insert(UserRequest user) { checkUserParam(user); // diff --git a/backend/src/main/java/io/metersphere/track/controller/TestCaseIssuesController.java b/backend/src/main/java/io/metersphere/track/controller/TestCaseIssuesController.java index 79a51257f5..905b408b5e 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestCaseIssuesController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestCaseIssuesController.java @@ -1,6 +1,7 @@ package io.metersphere.track.controller; import io.metersphere.base.domain.Issues; +import io.metersphere.track.domain.TapdUser; import io.metersphere.track.service.IssuesService; import io.metersphere.track.request.testcase.IssuesRequest; import org.springframework.web.bind.annotation.*; @@ -35,4 +36,9 @@ public class TestCaseIssuesController { issuesService.closeLocalIssue(id); } + @GetMapping("/tapd/user/{caseId}") + public List getTapdUsers(@PathVariable String caseId) { + return issuesService.getTapdProjectUsers(caseId); + } + } diff --git a/backend/src/main/java/io/metersphere/track/domain/TapdUser.java b/backend/src/main/java/io/metersphere/track/domain/TapdUser.java new file mode 100644 index 0000000000..53d193c088 --- /dev/null +++ b/backend/src/main/java/io/metersphere/track/domain/TapdUser.java @@ -0,0 +1,12 @@ +package io.metersphere.track.domain; + +import lombok.Data; +import java.io.Serializable; +import java.util.List; + +@Data +public class TapdUser implements Serializable { + private List roleId; + private String name; + private String user; +} diff --git a/backend/src/main/java/io/metersphere/track/request/testcase/IssuesRequest.java b/backend/src/main/java/io/metersphere/track/request/testcase/IssuesRequest.java index e5658e3684..88fb097185 100644 --- a/backend/src/main/java/io/metersphere/track/request/testcase/IssuesRequest.java +++ b/backend/src/main/java/io/metersphere/track/request/testcase/IssuesRequest.java @@ -3,6 +3,8 @@ package io.metersphere.track.request.testcase; import lombok.Getter; import lombok.Setter; +import java.util.List; + @Getter @Setter public class IssuesRequest { @@ -10,4 +12,5 @@ public class IssuesRequest { private String content; private String projectId; private String testCaseId; + private List tapdUsers; } diff --git a/backend/src/main/java/io/metersphere/track/service/IssuesService.java b/backend/src/main/java/io/metersphere/track/service/IssuesService.java index 3426bd6084..9febb2149b 100644 --- a/backend/src/main/java/io/metersphere/track/service/IssuesService.java +++ b/backend/src/main/java/io/metersphere/track/service/IssuesService.java @@ -1,6 +1,7 @@ package io.metersphere.track.service; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import io.metersphere.base.domain.*; import io.metersphere.base.mapper.IssuesMapper; @@ -17,6 +18,7 @@ import io.metersphere.controller.ResultHolder; import io.metersphere.controller.request.IntegrationRequest; import io.metersphere.service.IntegrationService; import io.metersphere.service.ProjectService; +import io.metersphere.track.domain.TapdUser; import io.metersphere.track.request.testcase.IssuesRequest; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; @@ -188,10 +190,14 @@ public class IssuesService { MSException.throwException("未关联Tapd 项目ID"); } + List tapdUsers = issuesRequest.getTapdUsers(); + String usersStr = String.join(";", tapdUsers); + MultiValueMap paramMap = new LinkedMultiValueMap<>(); paramMap.add("title", issuesRequest.getTitle()); paramMap.add("workspace_id", tapdId); paramMap.add("description", issuesRequest.getContent()); + paramMap.add("current_owner", usersStr); ResultHolder result = call(url, HttpMethod.POST, paramMap); @@ -535,4 +541,19 @@ public class IssuesService { issuesMapper.updateByPrimaryKeySelective(issues); } + public List getTapdProjectUsers(String caseId) { + List users = new ArrayList<>(); + String projectId = getTapdProjectId(caseId); + String url = "https://api.tapd.cn/workspaces/users?workspace_id=" + projectId; + ResultHolder call = call(url); + String listJson = JSON.toJSONString(call.getData()); + JSONArray jsonArray = JSON.parseArray(listJson); + for (int i = 0; i < jsonArray.size(); i++) { + JSONObject o = jsonArray.getJSONObject(i); + TapdUser user = o.getObject("UserWorkspace", TapdUser.class); + users.add(user); + } + return users; + } + } diff --git a/backend/src/main/resources/application.properties b/backend/src/main/resources/application.properties index e94db0ae4d..a3a405615e 100644 --- a/backend/src/main/resources/application.properties +++ b/backend/src/main/resources/application.properties @@ -69,13 +69,13 @@ jmeter.home=/opt/jmeter # quartz quartz.enabled=true quartz.scheduler-name=msServerJob - # file upload spring.servlet.multipart.max-file-size=500MB spring.servlet.multipart.max-request-size=500MB - # actuator management.server.port=8083 management.endpoints.web.exposure.include=* +#spring.freemarker.checkTemplateLocation=false + + -spring.freemarker.checkTemplateLocation=false diff --git a/backend/src/main/resources/i18n/messages_en_US.properties b/backend/src/main/resources/i18n/messages_en_US.properties index ee6353c9f8..6cbce8b777 100644 --- a/backend/src/main/resources/i18n/messages_en_US.properties +++ b/backend/src/main/resources/i18n/messages_en_US.properties @@ -22,7 +22,7 @@ user_already_exists=The user already exists in the current member list cannot_remove_current=Unable to remove the currently logged in user password_is_incorrect=Incorrect password user_not_exist=user does not exist: -user_has_been_disabled=the user has been disabled. +user_has_been_disabled=the user has been disabled. excessive_attempts=Excessive attempts user_locked=the user has been locked. user_expires=user expires. @@ -151,5 +151,5 @@ quota_max_threads_excess_workspace=The maximum number of concurrent threads exce quota_max_threads_excess_organization=The maximum number of concurrent threads exceeds the organization quota quota_duration_excess_workspace=The stress test duration exceeds the work space quota quota_duration_excess_organization=The stress test duration exceeds the organization quota -license_valid_license_error=valid license error -license_valid_license_code=The authorization code already exists + +email_subject=Metersphere timing task result notification diff --git a/backend/src/main/resources/i18n/messages_zh_CN.properties b/backend/src/main/resources/i18n/messages_zh_CN.properties index b30883829a..dba0ab0432 100644 --- a/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -151,7 +151,7 @@ quota_max_threads_excess_workspace=最大并发数超过工作空间限额 quota_max_threads_excess_organization=最大并发数超过组织限额 quota_duration_excess_workspace=压测时长超过工作空间限额 quota_duration_excess_organization=压测时长超过组织限额 -license_valid_license_error=授权验证失败 -license_valid_license_code=授权码已经存在 +email_subject=MeterSphere定时任务结果通知 + diff --git a/backend/src/main/resources/i18n/messages_zh_TW.properties b/backend/src/main/resources/i18n/messages_zh_TW.properties index 985bb05a70..1ba3befebc 100644 --- a/backend/src/main/resources/i18n/messages_zh_TW.properties +++ b/backend/src/main/resources/i18n/messages_zh_TW.properties @@ -154,3 +154,5 @@ quota_duration_excess_organization=壓測時長超過組織限額 license_valid_license_error=授權驗證失敗 license_valid_license_code=授權碼已經存在 + +email_subject=MeterSphere定時任務結果通知 diff --git a/frontend/src/business/components/api/test/ApiTestConfig.vue b/frontend/src/business/components/api/test/ApiTestConfig.vue index e0e7ec9c20..d937b9e94d 100644 --- a/frontend/src/business/components/api/test/ApiTestConfig.vue +++ b/frontend/src/business/components/api/test/ApiTestConfig.vue @@ -53,7 +53,7 @@ + @scheduleChange="saveSchedule" :test-id="id" :check-open="checkScheduleEdit"/> SCHEDULER - @@ -38,6 +38,7 @@ export default { } }, props: { + testId:String, save: Function, schedule: {}, checkOpen: { diff --git a/frontend/src/business/components/common/components/MsScheduleEdit.vue b/frontend/src/business/components/common/components/MsScheduleEdit.vue index b7b0f1d542..4da1b2c248 100644 --- a/frontend/src/business/components/common/components/MsScheduleEdit.vue +++ b/frontend/src/business/components/common/components/MsScheduleEdit.vue @@ -4,6 +4,7 @@ + - - - - + + - - + + + + - - - - + > - + prop="enable" + > + - - - - - - - {{$t('commons.save')}} @@ -111,19 +81,20 @@
尊敬的用户:您好,您所执行的"+testName+"运行失败,请点击报告链接查看
尊敬的用户:您好,"+testName+"运行成功,请点击报告链接查看