Merge branch 'master' of github.com:fit2cloudrd/metersphere-server into master
This commit is contained in:
commit
4f83705378
|
@ -302,6 +302,24 @@
|
|||
<artifactId>commonmark</artifactId>
|
||||
<version>0.15.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>1.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-test</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -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> notice = noticeService.queryNotice(request.getId());
|
||||
mailService.sendHtml(reportId,notice,"api");
|
||||
}
|
||||
changeStatus(request.getId(), APITestStatus.Running);
|
||||
|
||||
jMeterService.run(request.getId(), null, is);
|
||||
return reportId;
|
||||
}
|
||||
|
|
|
@ -15,5 +15,9 @@ public class Notice implements Serializable {
|
|||
|
||||
private String enable;
|
||||
|
||||
private String[] names;
|
||||
|
||||
private String[] emails;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
|
@ -57,7 +57,16 @@
|
|||
</include>
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<select id="get" resultMap="BaseResultMap">
|
||||
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
|
||||
<where>
|
||||
r.id = #{id}
|
||||
</where>
|
||||
ORDER BY r.update_time DESC
|
||||
</select>
|
||||
<select id="list" resultMap="BaseResultMap">
|
||||
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>
|
||||
|
||||
<select id="get" resultMap="BaseResultMap">
|
||||
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
|
||||
<where>
|
||||
r.id = #{id}
|
||||
</where>
|
||||
ORDER BY r.update_time DESC
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectDashboardTests" resultType="io.metersphere.dto.DashboardTestDTO">
|
||||
SELECT min(create_time) AS date, count(api_test_report.id) AS count,
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package io.metersphere.base.mapper.ext;
|
||||
|
||||
public interface ExtSystemParameterMapper {
|
||||
String email();
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
<?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.ext.ExtSystemParameterMapper">
|
||||
|
||||
<select id="email" resultType="string">
|
||||
select param_value from system_parameter where param_key=#{smtp.account}
|
||||
</select>
|
||||
</mapper>
|
|
@ -16,4 +16,6 @@ public interface ExtUserMapper {
|
|||
|
||||
List<User> searchUser(String condition);
|
||||
|
||||
List<String> queryEmails(String[] names);
|
||||
|
||||
}
|
||||
|
|
|
@ -33,6 +33,18 @@
|
|||
</where>
|
||||
order by u.update_time desc
|
||||
</select>
|
||||
<!--查询邮箱-->
|
||||
<select id="queryEmails" parameterType="java.lang.String" resultType="java.lang.String">
|
||||
SELECT
|
||||
email
|
||||
from user
|
||||
WHERE name IN
|
||||
<foreach collection="array" item="id" index="index"
|
||||
open="(" close=")" separator=",">
|
||||
#{id}
|
||||
</foreach>
|
||||
|
||||
</select>
|
||||
|
||||
<!--修改密码-->
|
||||
<update id="updatePassword" parameterType="io.metersphere.base.domain.User">
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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<Notice> queryNotice(@PathVariable String testId) {
|
||||
return noticeService.queryNotice(testId);
|
||||
}
|
||||
|
||||
}
|
|
@ -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<Notice> notices;
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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> notice,String type) {
|
||||
JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl();
|
||||
List<SystemParameter> 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="<!DOCTYPE html>\n" +
|
||||
"<html lang=\"en\">\n" +
|
||||
"<head>\n" +
|
||||
" <meta charset=\"UTF-8\">\n" +
|
||||
" <title>MeterSphere</title>\n" +
|
||||
"</head>\n" +
|
||||
"<body style=\"text-align: left\">\n" +
|
||||
" <div>\n" +
|
||||
" <h3>"+type+"定时任务结果通知</h3>\n" +
|
||||
" <p> 尊敬的用户:您好,您所执行的"+testName+"运行失败,请点击报告链接查看</p>\n" +
|
||||
" </div>\n" +
|
||||
"</body>\n" +
|
||||
"</html>";
|
||||
String html2="<!DOCTYPE html>\n" +
|
||||
"<html lang=\"en\">\n" +
|
||||
"<head>\n" +
|
||||
" <meta charset=\"UTF-8\">\n" +
|
||||
" <title>MeterSphere</title>\n" +
|
||||
"</head>\n" +
|
||||
"<body style=\"text-align: left\">\n" +
|
||||
" <div>\n" +
|
||||
" <h3>"+type+"定时任务结果通知</h3>\n" +
|
||||
" <p> 尊敬的用户:您好,"+testName+"运行成功,请点击报告链接查看</p>\n" +
|
||||
" </div>\n" +
|
||||
"</body>\n" +
|
||||
"</html>";
|
||||
try {
|
||||
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true);
|
||||
helper.setFrom(javaMailSender.getUsername());
|
||||
helper.setSubject("MeterSphere定时任务结果通知");
|
||||
String users[] = {};
|
||||
List<String> successEmailList=new ArrayList<>();
|
||||
List<String> 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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<Notice> 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<Notice> queryNotice(String id) {
|
||||
NoticeExample example = new NoticeExample();
|
||||
example.createCriteria().andTestIdEqualTo(id);
|
||||
List<Notice> notices=noticeMapper.selectByExample(example);
|
||||
List<Notice> notice=new ArrayList<>();
|
||||
List<String> success=new ArrayList<>();
|
||||
List<String> 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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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<LoadTestDTO> 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> notice = noticeService.queryNotice(request.getId());
|
||||
mailService.sendHtml(engine.getReportId(),notice,"performance");
|
||||
}
|
||||
return engine.getReportId();
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -61,6 +61,9 @@ public class UserService {
|
|||
@Resource
|
||||
private WorkspaceService workspaceService;
|
||||
|
||||
public List<String> queryEmail(String[] names){
|
||||
return extUserMapper.queryEmails(names);
|
||||
}
|
||||
public UserDTO insert(UserRequest user) {
|
||||
checkUserParam(user);
|
||||
//
|
||||
|
|
|
@ -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<TapdUser> getTapdUsers(@PathVariable String caseId) {
|
||||
return issuesService.getTapdProjectUsers(caseId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<String> roleId;
|
||||
private String name;
|
||||
private String user;
|
||||
}
|
|
@ -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<String> tapdUsers;
|
||||
}
|
||||
|
|
|
@ -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<String> tapdUsers = issuesRequest.getTapdUsers();
|
||||
String usersStr = String.join(";", tapdUsers);
|
||||
|
||||
MultiValueMap<String, Object> 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<TapdUser> getTapdProjectUsers(String caseId) {
|
||||
List<TapdUser> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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定时任务结果通知
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -154,3 +154,5 @@ quota_duration_excess_organization=壓測時長超過組織限額
|
|||
license_valid_license_error=授權驗證失敗
|
||||
license_valid_license_code=授權碼已經存在
|
||||
|
||||
|
||||
email_subject=MeterSphere定時任務結果通知
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
<ms-api-report-dialog :test-id="id" ref="reportDialog"/>
|
||||
|
||||
<ms-schedule-config :schedule="test.schedule" :is-read-only="isReadOnly" :save="saveCronExpression"
|
||||
@scheduleChange="saveSchedule" :check-open="checkScheduleEdit"/>
|
||||
@scheduleChange="saveSchedule" :test-id="id" :check-open="checkScheduleEdit"/>
|
||||
</el-row>
|
||||
</el-header>
|
||||
<ms-api-scenario-config :debug-report-id="debugReportId" @runDebug="runDebug" :is-read-only="isReadOnly"
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<span class="character">SCHEDULER</span>
|
||||
</span>
|
||||
<el-switch :disabled="!schedule.value || isReadOnly" v-model="schedule.enable" @change="scheduleChange"/>
|
||||
<ms-schedule-edit :is-read-only="isReadOnly" :schedule="schedule" :save="save" :custom-validate="customValidate"
|
||||
<ms-schedule-edit :is-read-only="isReadOnly" :schedule="schedule" :test-id="testId" :save="save" :custom-validate="customValidate"
|
||||
ref="scheduleEdit"/>
|
||||
|
||||
</div>
|
||||
|
@ -38,6 +38,7 @@ export default {
|
|||
}
|
||||
},
|
||||
props: {
|
||||
testId:String,
|
||||
save: Function,
|
||||
schedule: {},
|
||||
checkOpen: {
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
<template>
|
||||
<div>
|
||||
<el-tabs v-model="activeName" @tab-click="handleClick">
|
||||
|
||||
<el-tab-pane :label="$t('schedule.edit_timer_task')" name="first">
|
||||
<el-form :model="form" :rules="rules" ref="from">
|
||||
<el-form-item
|
||||
|
@ -26,81 +27,50 @@
|
|||
</el-tab-pane>
|
||||
<el-tab-pane :label="$t('schedule.task_notification')" name="second">
|
||||
<template>
|
||||
<el-select v-model="value" :placeholder="$t('commons.please_select')">
|
||||
<el-option
|
||||
v-for="item in options"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
<el-table
|
||||
:data="tableData"
|
||||
style="width: 100%">
|
||||
<el-table-column
|
||||
prop="receiver"
|
||||
prop="event"
|
||||
:label="$t('schedule.event')"
|
||||
|
||||
>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="name"
|
||||
:label="$t('schedule.receiver')"
|
||||
width="200"
|
||||
>
|
||||
<template v-slot:default="{row}">
|
||||
<el-input
|
||||
size="mini"
|
||||
type="textarea"
|
||||
:rows="1"
|
||||
class="edit-input"
|
||||
v-model="row.receiver"
|
||||
:placeholder="$t('schedule.receiver')"
|
||||
clearable>
|
||||
</el-input>
|
||||
<el-select v-model="row.names" filterable multiple placeholder="请选择" @click.native="userList()">
|
||||
<el-option
|
||||
v-for="item in options"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.name">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="email"
|
||||
:label="$t('schedule.receiving_mode')"
|
||||
width="200"
|
||||
>
|
||||
<template v-slot:default="{row}">
|
||||
<el-input
|
||||
size="mini"
|
||||
type="textarea"
|
||||
:rows="1"
|
||||
class="edit-input"
|
||||
v-model="row.email"
|
||||
:placeholder="$t('schedule.input_email')"
|
||||
clearable>
|
||||
</el-input>
|
||||
</template>
|
||||
>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
align="center"
|
||||
prop="enable"
|
||||
:label="$t('test_resource_pool.enable_disable')"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
prop="enable"
|
||||
>
|
||||
<template v-slot:default="{row}">
|
||||
<el-switch
|
||||
v-model="scope.row.enable"
|
||||
:active-value="true"
|
||||
:inactive-value="false"
|
||||
active-color="#13ce66"
|
||||
v-model="row.enable"
|
||||
active-value="true"
|
||||
inactive-value="false"
|
||||
inactive-color="#ff4949"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('schedule.operation')">
|
||||
<template v-slot:default="scope">
|
||||
<el-button
|
||||
type="primary"
|
||||
icon="el-icon-plus"
|
||||
circle size="mini"
|
||||
@click="handleAddStep(scope.$index)"></el-button>
|
||||
<el-button
|
||||
type="danger"
|
||||
icon="el-icon-delete"
|
||||
circle size="mini"
|
||||
@click="handleDeleteStep(scope.$index)"></el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-button type="primary" @click="saveNotice">{{$t('commons.save')}}</el-button>
|
||||
</template>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
|
@ -111,19 +81,20 @@
|
|||
|
||||
<script>
|
||||
|
||||
import Crontab from "../cron/Crontab";
|
||||
import CrontabResult from "../cron/CrontabResult";
|
||||
import {cronValidate} from "@/common/js/cron";
|
||||
import {listenGoBack, removeGoBackListener} from "@/common/js/utils";
|
||||
import Crontab from "../cron/Crontab";
|
||||
import CrontabResult from "../cron/CrontabResult";
|
||||
import {cronValidate} from "@/common/js/cron";
|
||||
import {listenGoBack, removeGoBackListener} from "@/common/js/utils";
|
||||
|
||||
function defaultCustomValidate() {
|
||||
return {pass: true};
|
||||
}
|
||||
function defaultCustomValidate() {
|
||||
return {pass: true};
|
||||
}
|
||||
|
||||
export default {
|
||||
name: "MsScheduleEdit",
|
||||
components: {CrontabResult, Crontab},
|
||||
props: {
|
||||
testId: String,
|
||||
save: Function,
|
||||
schedule: {},
|
||||
customValidate: {
|
||||
|
@ -133,8 +104,10 @@ function defaultCustomValidate() {
|
|||
isReadOnly: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
watch: {
|
||||
'schedule.value'() {
|
||||
this.form.cronValue = this.schedule.value;
|
||||
|
@ -164,25 +137,22 @@ function defaultCustomValidate() {
|
|||
form: {
|
||||
cronValue: ""
|
||||
},
|
||||
options: [{
|
||||
value: 'success',
|
||||
label: '执行成功通知'
|
||||
}, {
|
||||
value: 'fail',
|
||||
label: '执行失败通知'
|
||||
}, {
|
||||
value: 'all',
|
||||
label: '全部通知'
|
||||
}],
|
||||
value: '',
|
||||
tableData: [
|
||||
{
|
||||
receiver: "",
|
||||
email: "",
|
||||
event: "执行成功",
|
||||
names: [],
|
||||
email: "邮箱",
|
||||
enable: false
|
||||
},
|
||||
{
|
||||
event: "执行失败",
|
||||
names: [],
|
||||
email: "邮箱",
|
||||
enable: false
|
||||
}
|
||||
],
|
||||
enable: false,
|
||||
options: [{}],
|
||||
enable: true,
|
||||
email: "",
|
||||
activeName: 'first',
|
||||
rules: {
|
||||
|
@ -191,37 +161,31 @@ function defaultCustomValidate() {
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
handleClick() {
|
||||
|
||||
userList() {
|
||||
this.result = this.$get('user/list', response => {
|
||||
this.options = response.data
|
||||
})
|
||||
},
|
||||
saveNotice(){
|
||||
let param = this.buildParam();
|
||||
/* this.result=this.$post("notice/save",param,()=>{
|
||||
|
||||
})*/
|
||||
|
||||
handleClick() {
|
||||
if (this.activeName == "second") {
|
||||
this.result = this.$get('notice/query/' + this.testId, response => {
|
||||
if (response.data.length > 0) {
|
||||
this.tableData = response.data
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
buildParam() {
|
||||
let param = {};
|
||||
param.form = this.tableData
|
||||
param.testId = ""
|
||||
param.event = this.value
|
||||
param.notices = this.tableData
|
||||
param.testId = this.testId
|
||||
return param;
|
||||
},
|
||||
handleAddStep(index) {
|
||||
let form = {}
|
||||
form.receiver = null;
|
||||
form.email = null;
|
||||
form.enable = null
|
||||
this.tableData.splice(index + 1, 0, form);
|
||||
},
|
||||
handleDeleteStep(index) {
|
||||
this.tableData.splice(index, 1);
|
||||
},
|
||||
open() {
|
||||
this.dialogVisible = true;
|
||||
this.form.cronValue = this.schedule.value;
|
||||
listenGoBack(this.close);
|
||||
this.handleClick()
|
||||
},
|
||||
crontabFill(value, resultList) {
|
||||
//确定后回传的值
|
||||
|
@ -242,6 +206,10 @@ function defaultCustomValidate() {
|
|||
return false;
|
||||
}
|
||||
});
|
||||
let param = this.buildParam();
|
||||
this.result = this.$post("notice/save", param, () => {
|
||||
|
||||
})
|
||||
},
|
||||
close() {
|
||||
this.dialogVisible = false;
|
||||
|
@ -274,13 +242,13 @@ function defaultCustomValidate() {
|
|||
|
||||
<style scoped>
|
||||
|
||||
.inp {
|
||||
width: 50%;
|
||||
margin-right: 20px;
|
||||
}
|
||||
.inp {
|
||||
width: 50%;
|
||||
margin-right: 20px;
|
||||
}
|
||||
|
||||
.el-form-item {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.el-form-item {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
</el-button>
|
||||
|
||||
<ms-schedule-config :schedule="testPlan.schedule" :save="saveCronExpression" @scheduleChange="saveSchedule"
|
||||
:check-open="checkScheduleEdit" :custom-validate="durationValidate"/>
|
||||
:check-open="checkScheduleEdit" :test-id="testId" :custom-validate="durationValidate"/>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
|
|
|
@ -218,6 +218,12 @@
|
|||
/>
|
||||
<ckeditor :editor="editor" :disabled="isReadOnly" :config="editorConfig"
|
||||
v-model="testCase.issues.content"/>
|
||||
<el-row v-if="hasTapdId">
|
||||
Tapd平台处理人:
|
||||
<el-select v-model="testCase.tapdUsers" placeholder="请选择处理人" style="width: 20%" multiple collapse-tags>
|
||||
<el-option v-for="(userInfo, index) in users" :key="index" :label="userInfo.user" :value="userInfo.user"/>
|
||||
</el-select>
|
||||
</el-row>
|
||||
<el-button type="primary" size="small" @click="saveIssues">{{$t('commons.save')}}</el-button>
|
||||
<el-button size="small" @click="issuesSwitch=false">{{$t('commons.cancel')}}</el-button>
|
||||
</el-col>
|
||||
|
@ -323,6 +329,8 @@
|
|||
test: {},
|
||||
activeTab: 'detail',
|
||||
isFailure: true,
|
||||
users: [],
|
||||
hasTapdId: false
|
||||
};
|
||||
},
|
||||
props: {
|
||||
|
@ -490,6 +498,17 @@
|
|||
executeResult += this.addPLabel(stepPrefix + (step.executeResult == undefined ? '' : step.executeResult));
|
||||
});
|
||||
this.testCase.issues.content = desc + this.addPLabel('') + result + this.addPLabel('') + executeResult + this.addPLabel('');
|
||||
|
||||
this.$get("/test/case/project/" + this.testCase.caseId, res => {
|
||||
const project = res.data;
|
||||
if (project.tapdId) {
|
||||
this.hasTapdId = true;
|
||||
this.result = this.$get("/issues/tapd/user/" + this.testCase.caseId, response => {
|
||||
let data = response.data;
|
||||
this.users = data;
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
addPLabel(str) {
|
||||
|
@ -515,6 +534,7 @@
|
|||
param.title = this.testCase.issues.title;
|
||||
param.content = this.testCase.issues.content;
|
||||
param.testCaseId = this.testCase.caseId;
|
||||
param.tapdUsers = this.testCase.tapdUsers;
|
||||
this.result = this.$post("/issues/add", param, () => {
|
||||
this.$success(this.$t('commons.save_success'));
|
||||
this.getIssues(param.testCaseId);
|
||||
|
@ -522,6 +542,7 @@
|
|||
this.issuesSwitch = false;
|
||||
this.testCase.issues.title = "";
|
||||
this.testCase.issues.content = "";
|
||||
this.testCase.tapdUsers = [];
|
||||
},
|
||||
getIssues(caseId) {
|
||||
this.result = this.$get("/issues/get/" + caseId, response => {
|
||||
|
|
|
@ -849,7 +849,7 @@ export default {
|
|||
schedule: {
|
||||
input_email: "请输入邮箱账号",
|
||||
event: "事件",
|
||||
receiving_mode: "邮箱",
|
||||
receiving_mode: "接收方式",
|
||||
receiver: "接收人",
|
||||
operation: "操作",
|
||||
task_notification: "任务通知",
|
||||
|
|
Loading…
Reference in New Issue