Merge branch 'master' into v1.4

This commit is contained in:
Captain.B 2020-10-21 09:26:06 +08:00
commit 869a4a315e
42 changed files with 742 additions and 248 deletions

View File

@ -10,4 +10,5 @@ public class ExtractCommon extends ExtractType {
private String value; // value: ${variable}
private String expression;
private String description;
private Boolean multipleMatching;
}

View File

@ -13,10 +13,13 @@ import io.metersphere.notice.service.MailService;
import io.metersphere.notice.service.NoticeService;
import io.metersphere.track.service.TestPlanTestCaseService;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.protocol.HTTP;
import org.apache.jmeter.assertions.AssertionResult;
import org.apache.jmeter.samplers.SampleResult;
import org.apache.jmeter.visualizers.backend.AbstractBackendListenerClient;
import org.apache.jmeter.visualizers.backend.BackendListenerContext;
import org.pac4j.core.context.HttpConstants;
import org.springframework.http.HttpMethod;
import java.io.Serializable;
import java.util.*;
@ -204,7 +207,13 @@ public class APIBackendListenerClient extends AbstractBackendListenerClient impl
return StringUtils.substringBetween(body, start, end).toUpperCase();
} else {
// Http Method
return StringUtils.substringBefore(body, " ");
String method = StringUtils.substringBefore(body, " ");
for (HttpMethod value : HttpMethod.values()) {
if (StringUtils.equals(method, value.name())) {
return method;
}
}
return "Request";
}
}

View File

@ -19,5 +19,7 @@ public class MessageTask implements Serializable {
private String identification;
private Boolean isSet;
private static final long serialVersionUID = 1L;
}

View File

@ -593,6 +593,66 @@ public class MessageTaskExample {
addCriterion("identification not between", value1, value2, "identification");
return (Criteria) this;
}
public Criteria andIsSetIsNull() {
addCriterion("is_Set is null");
return (Criteria) this;
}
public Criteria andIsSetIsNotNull() {
addCriterion("is_Set is not null");
return (Criteria) this;
}
public Criteria andIsSetEqualTo(Boolean value) {
addCriterion("is_Set =", value, "isSet");
return (Criteria) this;
}
public Criteria andIsSetNotEqualTo(Boolean value) {
addCriterion("is_Set <>", value, "isSet");
return (Criteria) this;
}
public Criteria andIsSetGreaterThan(Boolean value) {
addCriterion("is_Set >", value, "isSet");
return (Criteria) this;
}
public Criteria andIsSetGreaterThanOrEqualTo(Boolean value) {
addCriterion("is_Set >=", value, "isSet");
return (Criteria) this;
}
public Criteria andIsSetLessThan(Boolean value) {
addCriterion("is_Set <", value, "isSet");
return (Criteria) this;
}
public Criteria andIsSetLessThanOrEqualTo(Boolean value) {
addCriterion("is_Set <=", value, "isSet");
return (Criteria) this;
}
public Criteria andIsSetIn(List<Boolean> values) {
addCriterion("is_Set in", values, "isSet");
return (Criteria) this;
}
public Criteria andIsSetNotIn(List<Boolean> values) {
addCriterion("is_Set not in", values, "isSet");
return (Criteria) this;
}
public Criteria andIsSetBetween(Boolean value1, Boolean value2) {
addCriterion("is_Set between", value1, value2, "isSet");
return (Criteria) this;
}
public Criteria andIsSetNotBetween(Boolean value1, Boolean value2) {
addCriterion("is_Set not between", value1, value2, "isSet");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {

View File

@ -9,6 +9,7 @@
<result column="task_type" jdbcType="VARCHAR" property="taskType" />
<result column="webhook" jdbcType="VARCHAR" property="webhook" />
<result column="identification" jdbcType="VARCHAR" property="identification" />
<result column="is_Set" jdbcType="BIT" property="isSet" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
@ -69,7 +70,7 @@
</where>
</sql>
<sql id="Base_Column_List">
id, `type`, event, user_id, task_type, webhook, identification
id, `type`, event, user_id, task_type, webhook, identification, is_Set
</sql>
<select id="selectByExample" parameterType="io.metersphere.base.domain.MessageTaskExample" resultMap="BaseResultMap">
select
@ -104,10 +105,10 @@
<insert id="insert" parameterType="io.metersphere.base.domain.MessageTask">
insert into message_task (id, `type`, event,
user_id, task_type, webhook,
identification)
identification, is_Set)
values (#{id,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{event,jdbcType=VARCHAR},
#{userId,jdbcType=VARCHAR}, #{taskType,jdbcType=VARCHAR}, #{webhook,jdbcType=VARCHAR},
#{identification,jdbcType=VARCHAR})
#{identification,jdbcType=VARCHAR}, #{isSet,jdbcType=BIT})
</insert>
<insert id="insertSelective" parameterType="io.metersphere.base.domain.MessageTask">
insert into message_task
@ -133,6 +134,9 @@
<if test="identification != null">
identification,
</if>
<if test="isSet != null">
is_Set,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
@ -156,6 +160,9 @@
<if test="identification != null">
#{identification,jdbcType=VARCHAR},
</if>
<if test="isSet != null">
#{isSet,jdbcType=BIT},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.metersphere.base.domain.MessageTaskExample" resultType="java.lang.Long">
@ -188,6 +195,9 @@
<if test="record.identification != null">
identification = #{record.identification,jdbcType=VARCHAR},
</if>
<if test="record.isSet != null">
is_Set = #{record.isSet,jdbcType=BIT},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -201,7 +211,8 @@
user_id = #{record.userId,jdbcType=VARCHAR},
task_type = #{record.taskType,jdbcType=VARCHAR},
webhook = #{record.webhook,jdbcType=VARCHAR},
identification = #{record.identification,jdbcType=VARCHAR}
identification = #{record.identification,jdbcType=VARCHAR},
is_Set = #{record.isSet,jdbcType=BIT}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -227,6 +238,9 @@
<if test="identification != null">
identification = #{identification,jdbcType=VARCHAR},
</if>
<if test="isSet != null">
is_Set = #{isSet,jdbcType=BIT},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
@ -237,7 +251,8 @@
user_id = #{userId,jdbcType=VARCHAR},
task_type = #{taskType,jdbcType=VARCHAR},
webhook = #{webhook,jdbcType=VARCHAR},
identification = #{identification,jdbcType=VARCHAR}
identification = #{identification,jdbcType=VARCHAR},
is_Set = #{isSet,jdbcType=BIT}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -11,5 +11,5 @@ public interface ExtTestReviewCaseMapper {
List<TestReviewCaseDTO> list(@Param("request") QueryCaseReviewRequest request);
List<String> getStatusByReviewId(String reviewId);
List<String> findRelateTestReviewId(String userId, String workspaceId);
List<String> findRelateTestReviewId(@Param("userId") String userId, @Param("workspaceId") String workspaceId);
}

View File

@ -2,6 +2,7 @@ package io.metersphere.base.mapper.ext;
import io.metersphere.base.domain.User;
import io.metersphere.controller.request.UserRequest;
import io.metersphere.notice.domain.UserDetail;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -16,6 +17,6 @@ public interface ExtUserMapper {
List<User> searchUser(String condition);
List<String> queryEmailByIds(List<String> userIds);
List<UserDetail> queryTypeByIds(List<String> userIds);
}

View File

@ -33,9 +33,9 @@
</where>
order by u.update_time desc
</select>
<select id="queryEmailByIds" parameterType="java.lang.String" resultType="java.lang.String">
<select id="queryTypeByIds" parameterType="java.lang.String" resultType="io.metersphere.notice.domain.UserDetail">
SELECT
email
email,phone
from user
WHERE id IN
<foreach collection="list" item="id" index="index"

View File

@ -9,9 +9,13 @@ public interface NoticeConstants {
String CREATE = "CREATE";
String UPDATE = "CREATE";
String DELETE = "DELETE";
String JENKINS_TASK = "jenkinsTask";
String TEST_PLAN_TASK = "testPlanTask";
String REVIEW_TASK = "reviewTask";
String DEFECT_TASK = "defectTask";
String JENKINS_TASK = "JENKINS_TASK";
String TEST_PLAN_TASK = "TEST_PLAN_TASK";
String REVIEW_TASK = "REVIEW_TASK";
String DEFECT_TASK = "DEFECT_TASK";
String FOUNDER="FOUNDER";
String EXECUTOR="EXECUTOR";
String MAINTAINER="MAINTAINER";
}

View File

@ -36,9 +36,9 @@ public class NoticeController {
return noticeService.searchMessage();
}
@GetMapping("/delete/message")
public void deleteMessage() {
@GetMapping("/delete/message/{identification}")
public int deleteMessage(@PathVariable String identification) {
return noticeService.delMessage(identification);
}
}

View File

@ -7,10 +7,12 @@ import java.util.ArrayList;
import java.util.List;
@Data
public class MessageDetail extends MessageTask {
public class MessageDetail {
private List<String> userIds = new ArrayList<>();
private List<String> events = new ArrayList<>();
private String taskType;
private String webhook;
private String type;
private String identification;
private Boolean isSet;
}

View File

@ -0,0 +1,9 @@
package io.metersphere.notice.domain;
import lombok.Data;
@Data
public class UserDetail {
private String email;
private String phone;
}

View File

@ -5,22 +5,53 @@ import com.dingtalk.api.DingTalkClient;
import com.dingtalk.api.request.OapiRobotSendRequest;
import com.dingtalk.api.response.OapiRobotSendResponse;
import com.taobao.api.ApiException;
import io.metersphere.commons.constants.NoticeConstants;
import io.metersphere.notice.domain.MessageDetail;
import io.metersphere.notice.domain.UserDetail;
import io.metersphere.service.UserService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@Service
public class DingTaskService {
public void sendDingTask(String context, List<String> userIds) {
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/robot/send?access_token=5129dc4c073d28f67c7452e0de6536c3ca496728d8c014d0a209b88a8814307a");
@Resource
private UserService userService;
public void sendNailRobot(MessageDetail messageDetail, List<String> userIds, String context, String eventType){
List<String> addresseeIdList=new ArrayList<>();
messageDetail.getEvents().forEach(e->{
if(StringUtils.equals(eventType,e)){
messageDetail.getUserIds().forEach(u->{
if(StringUtils.equals(NoticeConstants.FOUNDER,u)){
addresseeIdList.addAll(userIds);
}else{
addresseeIdList.add(u);
}
});
sendDingTask(context, addresseeIdList,messageDetail.getWebhook());
}
});
}
public void sendDingTask(String context, List<String> userIds,String Webhook) {
DingTalkClient client = new DefaultDingTalkClient(Webhook);
OapiRobotSendRequest request = new OapiRobotSendRequest();
request.setMsgtype("text");
OapiRobotSendRequest.Text text = new OapiRobotSendRequest.Text();
text.setContent(context);
request.setText(text);
OapiRobotSendRequest.At at = new OapiRobotSendRequest.At();
at.setAtMobiles(Arrays.asList("15135125273"));
List<UserDetail> list=userService.queryTypeByIds(userIds);
List<String> phoneList=new ArrayList<>();
list.forEach(u->{
phoneList.add(u.getPhone());
});
/* at.setAtMobiles(phoneList);*/
at.setAtMobiles(Arrays.asList("15135125273","13718506428"));
request.setAt(at);
OapiRobotSendResponse response = null;
try {

View File

@ -12,7 +12,9 @@ import io.metersphere.commons.utils.EncryptUtils;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.dto.BaseSystemConfigDTO;
import io.metersphere.i18n.Translator;
import io.metersphere.notice.domain.MessageDetail;
import io.metersphere.notice.domain.NoticeDetail;
import io.metersphere.notice.domain.UserDetail;
import io.metersphere.service.SystemParameterService;
import io.metersphere.service.UserService;
import io.metersphere.track.request.testreview.SaveCommentRequest;
@ -100,17 +102,17 @@ public class MailService {
}
}
public void sendEndNotice(List<String> userIds, SaveTestCaseReviewRequest reviewRequest) {
public void sendEndNotice(MessageDetail messageDetail, List<String> userIds, SaveTestCaseReviewRequest reviewRequest, String eventType) {
Map<String, String> context = getReviewContext(reviewRequest);
try {
String endTemplate = IOUtils.toString(this.getClass().getResource("/mail/end.html"), StandardCharsets.UTF_8);
sendReviewNotice(userIds, context, endTemplate);
sendReviewNotice(addresseeIdList(messageDetail,userIds,eventType), context, endTemplate);
} catch (Exception e) {
LogUtil.error(e);
}
}
public void sendCommentNotice(List<String> userIds, SaveCommentRequest request, TestCaseWithBLOBs testCaseWithBLOBs) {
public void sendCommentNotice(MessageDetail messageDetail, List<String> userIds, SaveCommentRequest request, TestCaseWithBLOBs testCaseWithBLOBs, String eventType) {
BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo();
Map<String, String> context = new HashMap<>();
context.put("maintainer", testCaseWithBLOBs.getMaintainer());
@ -126,11 +128,11 @@ public class MailService {
}
}
public void sendReviewerNotice(List<String> userIds, SaveTestCaseReviewRequest reviewRequest) {
public void sendReviewerNotice(MessageDetail messageDetail, List<String> userIds, SaveTestCaseReviewRequest reviewRequest, String eventType) {
Map<String, String> context = getReviewContext(reviewRequest);
try {
String reviewerTemplate = IOUtils.toString(this.getClass().getResource("/mail/reviewer.html"), StandardCharsets.UTF_8);
sendReviewNotice(userIds, context, reviewerTemplate);
sendReviewNotice(addresseeIdList(messageDetail,userIds,eventType), context, reviewerTemplate);
} catch (Exception e) {
LogUtil.error(e);
}
@ -171,7 +173,10 @@ public class MailService {
String[] users;
List<String> emails = new ArrayList<>();
try {
emails = userService.queryEmailByIds(userIds);
List<UserDetail> list=userService.queryTypeByIds(userIds);
list.forEach(u->{
emails.add(u.getEmail());
});
} catch (Exception e) {
LogUtil.error("Recipient information is empty");
}
@ -232,10 +237,16 @@ public class MailService {
if (noticeList.size() > 0) {
for (NoticeDetail n : noticeList) {
if (StringUtils.equals(n.getEnable(), "true") && StringUtils.equals(n.getEvent(), NoticeConstants.EXECUTE_SUCCESSFUL)) {
successEmailList = userService.queryEmail(n.getUserIds());
List<UserDetail> list = userService.queryTypeByIds(n.getUserIds());
list.forEach(u -> {
successEmailList.add(u.getEmail());
});
}
if (StringUtils.equals(n.getEnable(), "true") && StringUtils.equals(n.getEvent(), NoticeConstants.EXECUTE_FAILED)) {
failEmailList = userService.queryEmail(n.getUserIds());
List<UserDetail> list = userService.queryTypeByIds(n.getUserIds());
list.forEach(u -> {
failEmailList.add(u.getEmail());
});
}
}
} else {
@ -250,6 +261,24 @@ public class MailService {
return recipientEmails;
}
private List<String> addresseeIdList(MessageDetail messageDetail, List<String> userIds, String eventType) {
List<String> addresseeIdList = new ArrayList<>();
messageDetail.getEvents().forEach(e -> {
if (StringUtils.equals(eventType, e)) {
messageDetail.getUserIds().forEach(u -> {
if (StringUtils.equals(NoticeConstants.FOUNDER, u)) {
addresseeIdList.addAll(userIds);
} else {
addresseeIdList.add(u);
}
});
}
});
return addresseeIdList;
}
}

View File

@ -1,9 +1,6 @@
package io.metersphere.notice.service;
import io.metersphere.base.domain.MessageTask;
import io.metersphere.base.domain.MessageTaskExample;
import io.metersphere.base.domain.Notice;
import io.metersphere.base.domain.NoticeExample;
import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.MessageTaskMapper;
import io.metersphere.base.mapper.NoticeMapper;
import io.metersphere.commons.constants.NoticeConstants;
@ -13,6 +10,7 @@ import io.metersphere.notice.domain.MessageDetail;
import io.metersphere.notice.domain.MessageSettingDetail;
import io.metersphere.notice.domain.NoticeDetail;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@ -29,6 +27,9 @@ public class NoticeService {
@Resource
private MessageTaskMapper messageTaskMapper;
@Resource
MailService mailService;
public void saveNotice(NoticeRequest noticeRequest) {
NoticeExample example = new NoticeExample();
example.createCriteria().andTestIdEqualTo(noticeRequest.getTestId());
@ -99,6 +100,7 @@ public class NoticeService {
message.setType(list.getType());
message.setWebhook(list.getWebhook());
message.setIdentification(identification);
message.setIsSet(list.getIsSet());
messageTaskMapper.insert(message);
});
});
@ -126,6 +128,7 @@ public class NoticeService {
messageDetail.setWebhook(m.getWebhook());
messageDetail.setIdentification(m.getIdentification());
messageDetail.setType(m.getType());
messageDetail.setIsSet(m.getIsSet());
}
messageDetail.setEvents(new ArrayList(events));
messageDetail.setUserIds(new ArrayList(userIds));
@ -145,4 +148,92 @@ public class NoticeService {
private static String fetchGroupKey(MessageTask user) {
return user.getTaskType() + "#" + user.getIdentification();
}
public int delMessage(String identification){
MessageTaskExample example = new MessageTaskExample();
example.createCriteria().andIdentificationEqualTo(identification);
return messageTaskMapper.deleteByExample(example);
}
/*
public void sendTask(List<String> userIds,String context,String taskType,String eventType){
MessageSettingDetail messageSettingDetail = noticeService.searchMessage();
List<MessageDetail> taskList=new ArrayList<>();
switch (taskType) {
case NoticeConstants.REVIEW_TASK:
taskList=messageSettingDetail.getReviewTask();
break;
case NoticeConstants.JENKINS_TASK:
taskList=messageSettingDetail.getJenkinsTask();
break;
case NoticeConstants.DEFECT_TASK:
taskList=messageSettingDetail.getDefectTask();
break;
case NoticeConstants.TEST_PLAN_TASK:
taskList=messageSettingDetail.getTestCasePlanTask();
break;
}
taskList.forEach(r->{
switch (r.getType()) {
case NoticeConstants.NAIL_ROBOT:
sendNailRobot(r,userIds,context,eventType);
break;
case NoticeConstants.WECHAT_ROBOT:
sendWechatRobot(r,userIds,context,eventType);
break;
case NoticeConstants.EMAIL:
sendEmail(r,userIds,context,eventType);
break;
}
});
}
*/
/*private void sendNailRobot(MessageDetail messageDetail,List<String> userIds,String context,String eventType){
List<String> addresseeIdList=new ArrayList<>();
messageDetail.getEvents().forEach(e->{
if(StringUtils.equals(eventType,e)){
messageDetail.getUserIds().forEach(u->{
if(StringUtils.equals(NoticeConstants.FOUNDER,u)){
addresseeIdList.addAll(userIds);
}else{
addresseeIdList.add(u);
}
});
dingTaskService.sendDingTask(context, addresseeIdList,messageDetail.getWebhook());
}
});
}
private void sendWechatRobot(MessageDetail messageDetail,List<String> userIds,String context,String eventType){
List<String> addresseeIdList=new ArrayList<>();
messageDetail.getEvents().forEach(e->{
if(StringUtils.equals(eventType,e)){
messageDetail.getUserIds().forEach(u->{
if(StringUtils.equals(NoticeConstants.FOUNDER,u)){
addresseeIdList.addAll(userIds);
}else{
addresseeIdList.add(u);
}
});
wxChatTaskService.enterpriseWechatTask(context, addresseeIdList,messageDetail.getWebhook());
}
});
}
private void sendEmail(MessageDetail messageDetail,List<String> userIds,String context,String eventType){
List<String> addresseeIdList=new ArrayList<>();
if(StringUtils.equals(NoticeConstants.EMAIL,messageDetail.getType())){
messageDetail.getEvents().forEach(e->{
if(StringUtils.equals(eventType,e)){
messageDetail.getUserIds().forEach(u->{
if(StringUtils.equals(NoticeConstants.FOUNDER,u)){
addresseeIdList.addAll(userIds);
}else{
addresseeIdList.add(u);
}
});
mailService.sendReviewerNotice(addresseeIdList, context);
}
});
}
}*/
}

View File

@ -1,27 +1,57 @@
package io.metersphere.notice.service;
import io.metersphere.commons.constants.NoticeConstants;
import io.metersphere.notice.domain.MessageDetail;
import io.metersphere.notice.domain.UserDetail;
import io.metersphere.notice.message.TextMessage;
import io.metersphere.notice.util.SendResult;
import io.metersphere.notice.util.WxChatbotClient;
import io.metersphere.service.UserService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@Service
public class WxChatTaskService {
public void enterpriseWechatTask() {
TextMessage message = new TextMessage("脸给你打歪");
@Resource
private UserService userService;
public void sendWechatRobot(MessageDetail messageDetail, List<String> userIds, String context, String eventType){
List<String> addresseeIdList=new ArrayList<>();
messageDetail.getEvents().forEach(e->{
if(StringUtils.equals(eventType,e)){
messageDetail.getUserIds().forEach(u->{
if(StringUtils.equals(NoticeConstants.FOUNDER,u)){
addresseeIdList.addAll(userIds);
}else{
addresseeIdList.add(u);
}
});
enterpriseWechatTask(context, addresseeIdList,messageDetail.getWebhook());
}
});
}
public void enterpriseWechatTask(String context, List<String> userIds,String Webhook) {
TextMessage message = new TextMessage(context);
List<String> mentionedMobileList = new ArrayList<String>();
mentionedMobileList.add("15135125273");//@群内成员 手机号
List<UserDetail> list=userService.queryTypeByIds(userIds);
List<String> phoneList=new ArrayList<>();
list.forEach(u->{
phoneList.add(u.getPhone());
});
mentionedMobileList.addAll(phoneList);
mentionedMobileList.add("15135125273");
mentionedMobileList.add("18046109770");
message.setMentionedMobileList(mentionedMobileList);
message.setIsAtAll(true);//@所有人
try {
SendResult result = WxChatbotClient.send("https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=a03acc34-4988-4200-a9c7-7c9b30c5601e", message);
SendResult result = WxChatbotClient.send(Webhook, message);
System.out.println(result);
} catch (IOException e) {
e.printStackTrace();
}
}
}

View File

@ -22,6 +22,7 @@ import io.metersphere.controller.request.organization.QueryOrgMemberRequest;
import io.metersphere.dto.UserDTO;
import io.metersphere.dto.UserRoleDTO;
import io.metersphere.i18n.Translator;
import io.metersphere.notice.domain.UserDetail;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.*;
@ -61,13 +62,13 @@ public class UserService {
@Resource
private WorkspaceService workspaceService;
public List<String> queryEmail(List<String> userIds) {
return extUserMapper.queryEmailByIds(userIds);
public List<UserDetail> queryTypeByIds(List<String> userIds) {
return extUserMapper.queryTypeByIds(userIds);
}
public List<String> queryEmailByIds(List<String> userIds) {
return extUserMapper.queryEmailByIds(userIds);
}
/* public List<String> queryEmailByIds(List<String> userIds) {
return extUserMapper.queryTypeByIds(userIds);
}*/
public UserDTO insert(UserRequest user) {
checkUserParam(user);

View File

@ -167,7 +167,7 @@ public class TestCaseController {
}
@PostMapping("/file/download")
public ResponseEntity<byte[]> downloadJmx(@RequestBody FileOperationRequest fileOperationRequest) {
public ResponseEntity<byte[]> download(@RequestBody FileOperationRequest fileOperationRequest) {
byte[] bytes = fileService.loadFileAsBytes(fileOperationRequest.getId());
return ResponseEntity.ok()
.contentType(MediaType.parseMediaType("application/octet-stream"))
@ -175,4 +175,13 @@ public class TestCaseController {
.body(bytes);
}
@GetMapping("/file/preview/{fileId}")
public ResponseEntity<byte[]> preview(@PathVariable String fileId) {
byte[] bytes = fileService.loadFileAsBytes(fileId);
return ResponseEntity.ok()
.contentType(MediaType.parseMediaType("application/octet-stream"))
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + fileId + "\"")
.body(bytes);
}
}

View File

@ -60,13 +60,13 @@ public class TestCaseCommentService {
userIds.add(testCaseWithBLOBs.getMaintainer());
String context = getReviewContext(request, testCaseWithBLOBs);
try {
if (StringUtils.equals(NoticeConstants.NAIL_ROBOT, "NAIL_ROBOT")) {
/* if (StringUtils.equals(NoticeConstants.NAIL_ROBOT, "NAIL_ROBOT")) {
dingTaskService.sendDingTask(context, userIds);
} else if (StringUtils.equals(NoticeConstants.WECHAT_ROBOT, "WECHAT_ROBOT")) {
wxChatTaskService.enterpriseWechatTask();
} else {
mailService.sendCommentNotice(userIds, request, testCaseWithBLOBs);
}
}*/
} catch (Exception e) {
LogUtil.error(e);
}

View File

@ -73,15 +73,16 @@ public class TestCaseReviewService {
@Resource
TestCaseReviewTestCaseMapper testCaseReviewTestCaseMapper;
@Resource
MailService mailService;
@Resource
ExtTestCaseMapper extTestCaseMapper;
@Resource
NoticeService noticeService;
@Resource
MailService mailService;
@Resource
DingTaskService dingTaskService;
@Resource
WxChatTaskService wxChatTaskService;
@Resource
NoticeService noticeService;
public void saveTestCaseReview(SaveTestCaseReviewRequest reviewRequest) {
checkCaseReviewExist(reviewRequest);
@ -109,24 +110,28 @@ public class TestCaseReviewService {
reviewRequest.setCreator(SessionUtils.getUser().getId());
reviewRequest.setStatus(TestCaseReviewStatus.Prepare.name());
testCaseReviewMapper.insert(reviewRequest);
String context = getReviewContext(reviewRequest, "create");
MessageSettingDetail messageSettingDetail = noticeService.searchMessage();
List<MessageDetail> reviewTasklist = messageSettingDetail.getReviewTask();
try {
mailService.sendReviewerNotice(userIds, reviewRequest);
/* if (StringUtils.equals(NoticeConstants.NAIL_ROBOT, "NAIL_ROBOT")) {
dingTaskService.sendDingTask(context, userIds);
} else if (StringUtils.equals(NoticeConstants.WECHAT_ROBOT, "WECHAT_ROBOT")) {
wxChatTaskService.enterpriseWechatTask();
} else {
mailService.sendReviewerNotice(userIds, reviewRequest);
}*/
String context = getReviewContext(reviewRequest, NoticeConstants.CREATE);
MessageSettingDetail messageSettingDetail = noticeService.searchMessage();
List<MessageDetail> taskList=messageSettingDetail.getReviewTask();
taskList.forEach(r->{
switch (r.getType()) {
case NoticeConstants.NAIL_ROBOT:
dingTaskService.sendNailRobot(r,userIds,context,NoticeConstants.CREATE);
break;
case NoticeConstants.WECHAT_ROBOT:
wxChatTaskService.sendWechatRobot(r,userIds,context,NoticeConstants.CREATE);
break;
case NoticeConstants.EMAIL:
mailService.sendReviewerNotice(r,userIds, reviewRequest,NoticeConstants.CREATE);
break;
}
});
} catch (Exception e) {
LogUtil.error(e);
}
}
}
public List<TestCaseReviewDTO> listCaseReview(QueryCaseReviewRequest request) {
request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders()));
@ -182,7 +187,22 @@ public class TestCaseReviewService {
checkCaseReviewExist(testCaseReview);
testCaseReviewMapper.updateByPrimaryKeySelective(testCaseReview);
try {
mailService.sendReviewerNotice(testCaseReview.getUserIds(), testCaseReview);
String context = getReviewContext(testCaseReview, NoticeConstants.CREATE);
MessageSettingDetail messageSettingDetail = noticeService.searchMessage();
List<MessageDetail> taskList=messageSettingDetail.getReviewTask();
taskList.forEach(r->{
switch (r.getType()) {
case NoticeConstants.NAIL_ROBOT:
dingTaskService.sendNailRobot(r,testCaseReview.getUserIds(),context,NoticeConstants.CREATE);
break;
case NoticeConstants.WECHAT_ROBOT:
wxChatTaskService.sendWechatRobot(r,testCaseReview.getUserIds(),context,NoticeConstants.CREATE);
break;
case NoticeConstants.EMAIL:
mailService.sendReviewerNotice(r,testCaseReview.getUserIds(), testCaseReview,NoticeConstants.CREATE);
break;
}
});
} catch (Exception e) {
LogUtil.error(e);
}
@ -392,14 +412,22 @@ public class TestCaseReviewService {
testCaseReviewMapper.updateByPrimaryKeySelective(testCaseReview);
try {
BeanUtils.copyProperties(testCaseReviewRequest, _testCaseReview);
String context = getReviewContext(testCaseReviewRequest, "create");
if (StringUtils.equals(NoticeConstants.NAIL_ROBOT, "NAIL_ROBOT")) {
dingTaskService.sendDingTask(context, userIds);
} else if (StringUtils.equals(NoticeConstants.WECHAT_ROBOT, "WECHAT_ROBOT")) {
wxChatTaskService.enterpriseWechatTask();
} else {
mailService.sendEndNotice(userIds, testCaseReviewRequest);
}
String context = getReviewContext(testCaseReviewRequest, NoticeConstants.UPDATE);
MessageSettingDetail messageSettingDetail = noticeService.searchMessage();
List<MessageDetail> taskList=messageSettingDetail.getReviewTask();
taskList.forEach(r->{
switch (r.getType()) {
case NoticeConstants.NAIL_ROBOT:
dingTaskService.sendNailRobot(r,userIds,context,NoticeConstants.CREATE);
break;
case NoticeConstants.WECHAT_ROBOT:
wxChatTaskService.sendWechatRobot(r,userIds,context,NoticeConstants.CREATE);
break;
case NoticeConstants.EMAIL:
mailService.sendReviewerNotice(r,userIds, testCaseReviewRequest,NoticeConstants.CREATE);
break;
}
});
} catch (Exception e) {
LogUtil.error(e);
}
@ -490,8 +518,8 @@ public class TestCaseReviewService {
request.setProjectIds(projectIds);
return extTestReviewCaseMapper.list(request);
}
private String getReviewContext(SaveTestCaseReviewRequest reviewRequest, String type) {
/*通知内容*/
private static String getReviewContext(SaveTestCaseReviewRequest reviewRequest, String type) {
Long startTime = reviewRequest.getCreateTime();
Long endTime = reviewRequest.getEndTime();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@ -506,12 +534,13 @@ public class TestCaseReviewService {
end = sdf.format(new Date(Long.parseLong(eTime)));
}
String context = "";
if (StringUtils.equals("create", type)) {
context = reviewRequest.getCreator() + "发起的" + "'" + reviewRequest.getName() + "'" + "待开始,计划开始时间是" + start + "计划结束时间为" + end + "请跟进";
} else if (StringUtils.equals("end", type)) {
context = reviewRequest.getCreator() + "发起的" + "'" + reviewRequest.getName() + "'" + "已完成,计划开始时间是" + start + "计划结束时间为" + end + "已完成";
if (StringUtils.equals(NoticeConstants.CREATE, type)) {
context = reviewRequest.getCreator() + "发起的任务通知" + "'" + reviewRequest.getName() + "'" + "待开始,计划开始时间是" + start + "计划结束时间为" + end + "请跟进";
} else if (StringUtils.equals(NoticeConstants.UPDATE, type)) {
context = reviewRequest.getCreator() + "发起的任务通知" + "'" + reviewRequest.getName() + "'" + "已完成,计划开始时间是" + start + "计划结束时间为" + end + "已完成";
}
return context;
}
}

View File

@ -263,25 +263,22 @@ public class TestCaseService {
.map(TestCase::getName)
.collect(Collectors.toSet());
List<ExcelErrData<TestCaseExcelData>> errList = null;
if (multipartFile == null)
if (multipartFile == null) {
MSException.throwException(Translator.get("upload_fail"));
}
if (multipartFile.getOriginalFilename().endsWith(".xmind")) {
try {
errList = new ArrayList<>();
XmindCaseParser xmindParser = new XmindCaseParser(this, userId, projectId, testCaseNames);
String processLog = xmindParser.parse(multipartFile);
if (!StringUtils.isEmpty(processLog)) {
excelResponse.setSuccess(false);
ExcelErrData excelErrData = new ExcelErrData(null, 1, Translator.get("upload_fail") + "" + processLog);
errList.add(excelErrData);
excelResponse.setErrList(errList);
} else if (xmindParser.getNodePaths().isEmpty() && xmindParser.getTestCase().isEmpty()) {
excelResponse.setSuccess(false);
errList = xmindParser.parse(multipartFile);
if (xmindParser.getNodePaths().isEmpty() && xmindParser.getTestCase().isEmpty()) {
if (errList == null) {
errList = new ArrayList<>();
}
ExcelErrData excelErrData = new ExcelErrData(null, 1, Translator.get("upload_fail") + "" + Translator.get("upload_content_is_null"));
errList.add(excelErrData);
excelResponse.setErrList(errList);
} else {
}
if (errList.isEmpty()) {
if (!xmindParser.getNodePaths().isEmpty()) {
testCaseNodeService.createNodes(xmindParser.getNodePaths(), projectId);
}
@ -290,7 +287,6 @@ public class TestCaseService {
this.saveImportData(xmindParser.getTestCase(), projectId);
xmindParser.clear();
}
excelResponse.setSuccess(true);
}
} catch (Exception e) {
LogUtil.error(e.getMessage(), e);

View File

@ -6,12 +6,14 @@ import com.google.common.collect.ImmutableMap;
import io.metersphere.base.domain.TestCaseWithBLOBs;
import io.metersphere.commons.constants.TestCaseConstants;
import io.metersphere.commons.utils.BeanUtils;
import io.metersphere.excel.domain.ExcelErrData;
import io.metersphere.excel.domain.TestCaseExcelData;
import io.metersphere.i18n.Translator;
import io.metersphere.track.service.TestCaseService;
import io.metersphere.xmind.parser.XmindParser;
import io.metersphere.xmind.parser.pojo.Attached;
import io.metersphere.xmind.parser.pojo.JsonRootBean;
import io.metersphere.xmind.utils.DetailUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.multipart.MultipartFile;
@ -32,7 +34,7 @@ public class XmindCaseParser {
/**
* 过程校验记录
*/
private StringBuffer process;
private DetailUtil process;
/**
* 已存在用例名称
*/
@ -57,7 +59,7 @@ public class XmindCaseParser {
this.testCaseNames = testCaseNames;
testCases = new LinkedList<>();
compartDatas = new ArrayList<>();
process = new StringBuffer();
process = new DetailUtil();
nodePaths = new ArrayList<>();
}
@ -90,15 +92,15 @@ public class XmindCaseParser {
nodePaths.forEach(nodePath -> {
String[] nodes = nodePath.split("/");
if (nodes.length > TestCaseConstants.MAX_NODE_DEPTH + 1) {
process.append(Translator.get("test_case_node_level_tip") +
TestCaseConstants.MAX_NODE_DEPTH + Translator.get("test_case_node_level") + "; ");
process.add(Translator.get("test_case_node_level_tip") +
TestCaseConstants.MAX_NODE_DEPTH + Translator.get("test_case_node_level"), nodePath);
}
String path = "";
for (int i = 0; i < nodes.length; i++) {
if (i != 0 && StringUtils.equals(nodes[i].trim(), "")) {
process.append(Translator.get("module") + ":【" + path + "" + Translator.get("module_not_null") + "; ");
process.add(Translator.get("module_not_null"), path);
} else if (nodes[i].trim().length() > 30) {
process.append(nodes[i].trim() + "" + Translator.get("test_track.length_less_than") + "30 ;");
process.add(Translator.get("module") + Translator.get("test_track.length_less_than") + "30", path + nodes[i].trim());
} else {
path += nodes[i].trim() + "/";
}
@ -109,7 +111,7 @@ public class XmindCaseParser {
/**
* 验证用例的合规性
*/
private boolean validate(TestCaseWithBLOBs data) {
private void validate(TestCaseWithBLOBs data) {
String nodePath = data.getNodePath();
if (!nodePath.startsWith("/")) {
nodePath = "/" + nodePath;
@ -119,37 +121,36 @@ public class XmindCaseParser {
}
data.setNodePath(nodePath);
StringBuilder stringBuilder = new StringBuilder();
if (data.getName().length() > 50) {
stringBuilder.append(data.getName() + "" + Translator.get("test_case") + Translator.get("test_track.length_less_than") + "50 ;");
process.add(Translator.get("test_case") + Translator.get("test_track.length_less_than") + "50", nodePath + data.getName());
}
if (!StringUtils.isEmpty(nodePath)) {
String[] nodes = nodePath.split("/");
if (nodes.length > TestCaseConstants.MAX_NODE_DEPTH + 1) {
stringBuilder.append(Translator.get("test_case_node_level_tip") +
TestCaseConstants.MAX_NODE_DEPTH + Translator.get("test_case_node_level") + "; ");
process.add(Translator.get("test_case_node_level_tip") +
TestCaseConstants.MAX_NODE_DEPTH + Translator.get("test_case_node_level"), nodePath);
}
for (int i = 0; i < nodes.length; i++) {
if (i != 0 && StringUtils.equals(nodes[i].trim(), "")) {
stringBuilder.append(Translator.get("test_case") + ":【" + data.getName() + "" + Translator.get("module_not_null") + "; ");
process.add(Translator.get("test_case") + Translator.get("module_not_null"), nodePath + data.getName());
break;
} else if (nodes[i].trim().length() > 30) {
stringBuilder.append(nodes[i].trim() + "" + Translator.get("module") + Translator.get("test_track.length_less_than") + "30 ;");
process.add(Translator.get("module") + Translator.get("test_track.length_less_than") + "30 ", nodes[i].trim());
break;
}
}
}
if (StringUtils.equals(data.getType(), TestCaseConstants.Type.Functional.getValue()) && StringUtils.equals(data.getMethod(), TestCaseConstants.Method.Auto.getValue())) {
stringBuilder.append(Translator.get("functional_method_tip") + "; ");
process.add(Translator.get("functional_method_tip"), nodePath + data.getName());
}
if (testCaseNames.contains(data.getName())) {
boolean dbExist = testCaseService.exist(data);
if (dbExist) {
stringBuilder.append(Translator.get("test_case_already_exists_excel") + "" + data.getName() + "; ");
process.add(Translator.get("test_case_already_exists_excel"), nodePath + "/" + data.getName());
}
} else {
testCaseNames.add(data.getName());
@ -157,26 +158,19 @@ public class XmindCaseParser {
// 用例等级和用例性质处理
if (!priorityList.contains(data.getPriority())) {
stringBuilder.append(data.getName() + "" + Translator.get("test_case_priority") + Translator.get("incorrect_format") + "; ");
process.add(Translator.get("test_case_priority") + Translator.get("incorrect_format"), nodePath + data.getName());
}
if (data.getType() == null) {
stringBuilder.append(data.getName() + "" + Translator.get("test_case_type") + Translator.get("incorrect_format") + "; ");
process.add(Translator.get("test_case_type") + Translator.get("incorrect_format"), nodePath + data.getName());
}
// 重复用例校验
TestCaseExcelData compartData = new TestCaseExcelData();
BeanUtils.copyBean(compartData, data);
if (compartDatas.contains(compartData)) {
stringBuilder.append(Translator.get("test_case_already_exists_excel") + "" + compartData.getName() + "; ");
}
if (!StringUtils.isEmpty(stringBuilder.toString())) {
process.append(stringBuilder.toString());
return false;
process.add(Translator.get("test_case_already_exists_excel"), nodePath + "/" + compartData.getName());
}
compartDatas.add(compartData);
return true;
}
/**
@ -267,7 +261,7 @@ public class XmindCaseParser {
String tc = title.replace("", ":");
String[] tcArr = tc.split(":");
if (tcArr.length != 2) {
process.append(Translator.get("test_case_name") + "" + title + "" + Translator.get("incorrect_format"));
process.add(Translator.get("test_case_name") + Translator.get("incorrect_format"), title);
return;
}
// 用例名称
@ -301,17 +295,15 @@ public class XmindCaseParser {
});
}
testCase.setSteps(this.getSteps(steps));
testCases.add(testCase);
// 校验合规性
if (validate(testCase)) {
testCases.add(testCase);
}
validate(testCase);
}
/**
* 导入思维导图处理
*/
public String parse(MultipartFile multipartFile) {
public List<ExcelErrData<TestCaseExcelData>> parse(MultipartFile multipartFile) {
try {
// 获取思维导图内容
List<JsonRootBean> roots = XmindParser.parseObject(multipartFile);
@ -321,7 +313,7 @@ public class XmindCaseParser {
for (Attached item : root.getRootTopic().getChildren().getAttached()) {
// 用例
if (isAvailable(item.getTitle(), TC_REGEX)) {
return replace(item.getTitle(), TC_REGEX) + "" + Translator.get("test_case_create_module_fail");
return process.parse(replace(item.getTitle(), TC_REGEX) + "" + Translator.get("test_case_create_module_fail"));
} else {
String nodePath = item.getTitle();
item.setPath(nodePath);
@ -344,8 +336,8 @@ public class XmindCaseParser {
//检查目录合规性
this.validate();
} catch (Exception ex) {
return ex.getMessage();
return process.parse(ex.getMessage());
}
return process.toString();
return process.parse();
}
}

View File

@ -73,7 +73,7 @@ public class XmindParser {
JsonRootBean jsonRootBean = JSON.parseObject(content, JsonRootBean.class);
jsonRootBeans.add(jsonRootBean);
}
if (caseCount > 500) {
if (caseCount > 800) {
MSException.throwException(Translator.get("import_xmind_count_error"));
}
}

View File

@ -0,0 +1,59 @@
package io.metersphere.xmind.utils;
import io.metersphere.excel.domain.ExcelErrData;
import io.metersphere.excel.domain.TestCaseExcelData;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@Getter
@Setter
public class DetailUtil implements Serializable {
private Map<String, StringBuilder> process;
public DetailUtil() {
process = new LinkedHashMap<>();
}
public void add(String type, String msContent) {
if (process.containsKey(type)) {
process.get(type).append(msContent + "");
} else {
process.put(type, new StringBuilder(msContent + ""));
}
}
public List<ExcelErrData<TestCaseExcelData>> parse(String content) {
List<ExcelErrData<TestCaseExcelData>> errList = new ArrayList<>();
ExcelErrData excelErrData = new ExcelErrData(null, 1, content);
errList.add(excelErrData);
return errList;
}
public List<ExcelErrData<TestCaseExcelData>> parse() {
List<ExcelErrData<TestCaseExcelData>> errList = new ArrayList<>();
List<String> result = new ArrayList<>();
process.entrySet().parallelStream().reduce(result, (first, second) -> {
first.add(second.getKey() + "" + second.getValue());
return first;
}, (first, second) -> {
if (first == second) {
return first;
}
first.addAll(second);
return first;
});
for (int i = 0; i < result.size(); i++) {
ExcelErrData excelErrData = new ExcelErrData(null, i, result.get(i));
errList.add(excelErrData);
}
return errList;
}
}

@ -1 +1 @@
Subproject commit cf6b06526324326a563d933e07118fac014a63b4
Subproject commit ee74568be0beba46da19616f5832e83f9164c688

View File

@ -1,2 +1,5 @@
alter table message_task
add identification varchar(255) not null;
add identification varchar(255) not null;
alter table message_task
add result boolean not null;
alter table message_task change result is_Set tinyint(1) not null;

View File

@ -35,7 +35,8 @@
"jspdf": "^2.1.1",
"yan-progress": "^1.0.3",
"nprogress": "^0.2.0",
"el-table-infinite-scroll": "^1.0.10"
"el-table-infinite-scroll": "^1.0.10",
"vue-pdf": "^4.2.0"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^4.1.0",

View File

@ -16,16 +16,16 @@
<ms-assertion-results :assertions="response.assertions"/>
</el-tab-pane>
<el-tab-pane :label="$t('api_test.request.extract.label')" name="label" class="pane">
<pre>{{response.vars}}</pre>
</el-tab-pane>
<el-tab-pane v-if="activeName == 'body'" :disabled="true" name="mode" class="pane assertions">
<template v-slot:label>
<ms-dropdown :commands="modes" :default-command="mode" @command="modeChange"/>
</template>
</el-tab-pane>
<el-tab-pane :label="$t('api_test.request.extract.label')" name="label" class="pane">
<pre>{{response.vars}}</pre>
</el-tab-pane>
</el-tabs>
</el-collapse-transition>
</div>

View File

@ -29,6 +29,10 @@
type: Boolean,
default: true
},
showCopyTipWithMultiple: {
type: Boolean,
default: false
},
},
data() {
@ -63,7 +67,7 @@
computed: {
variable() {
return "${" + this.value + "}";
return "${" + (this.showCopyTipWithMultiple ? (this.value + "_n") : this.value) + "}";
}
}

View File

@ -8,12 +8,17 @@
</el-col>
<el-col>
<ms-api-variable-input :is-read-only="isReadOnly" v-model="common.variable" size="small" maxlength="60"
@change="change" show-word-limit :placeholder="$t('api_test.variable_name')"/>
@change="change" :show-copy-tip-with-multiple="common.multipleMatching" show-word-limit :placeholder="$t('api_test.variable_name')"/>
</el-col>
<el-col>
<el-input :disabled="isReadOnly" v-model="common.expression" size="small" show-word-limit
:placeholder="expression"/>
</el-col>
<el-col class="multiple_checkbox">
<el-checkbox v-model="common.multipleMatching" :disabled="isReadOnly">
{{ $t('api_test.request.extract.multiple_matching') }}
</el-checkbox>
</el-col>
<el-col class="extract-btn">
<el-button :disabled="isReadOnly" type="danger" size="mini" icon="el-icon-delete" circle @click="remove"
v-if="edit"/>
@ -159,4 +164,10 @@
.extract-btn {
width: 60px;
}
.multiple_checkbox {
text-align: center;
width: 120px;
}
</style>

View File

@ -45,41 +45,29 @@
data() {
return {
result: {},
// relevanceConfigSet: new Set()
}
},
// created() {
// this.listRelevance();
// },
methods: {
handleView(row) {
this.$emit('rowSelect', row);
},
handleDelete(id) {
this.result = this.$get("/jar/delete/" + id, () => {
this.$success(this.$t('commons.delete_success'));
this.$emit('refresh');
this.$confirm(this.$t('api_test.jar_config.delete_tip'), '', {
confirmButtonText: this.$t('commons.confirm'),
cancelButtonText: this.$t('commons.cancel'),
type: 'warning'
}).then(() => {
this.result = this.$get("/jar/delete/" + id, () => {
this.$success(this.$t('commons.delete_success'));
this.$emit('refresh');
});
}).catch(() => {
this.$message({
type: 'info',
message: this.$t('commons.delete_cancelled')
});
});
},
// handleRelevance(id, type) {
// let url = type === 'relevance' ? '/jar/relevance' : '/jar/unrelevance';
// let param = {
// jarConfigId: id
// };
// this.result = this.$post(url, param, () => {
// this.$success(this.$t('commons.save_success'));
// this.$emit('refresh');
// this.listRelevance();
// });
// },
// listRelevance() {
// if (this.testId) {
// this.result = this.$get("/jar/relevance/list/" + this.testId, (response) => {
// this.relevanceConfigSet = new Set(response.data);
// this.$emit('refresh');
// });
// }
// }
}
}
</script>

View File

@ -39,7 +39,7 @@
<el-form-item>
<div class="buttons">
<el-button type="primary" v-show="currentConfig.id" size="small" @click="validate()">{{$t('校验')}}</el-button>
<el-button type="primary" v-show="currentConfig.id" size="small" @click="validate()">{{$t('commons.validate')}}</el-button>
<el-button type="primary" v-show="currentConfig.id" size="small" @click="save('update')">{{$t('commons.update')}}</el-button>
<el-button type="primary" size="small" @click="save('add')">{{$t('commons.add')}}</el-button>
</div>

View File

@ -855,6 +855,7 @@ export class ExtractCommon extends ExtractType {
this.value = ""; // ${variable}
this.expression = undefined;
this.description = undefined;
this.multipleMatching = undefined;
this.set(options);
}
@ -1460,6 +1461,7 @@ class JMXGenerator {
let props = {
name: extractCommon.variable,
expression: extractCommon.expression,
match: extractCommon.multipleMatching ? -1 : undefined
}
let testName = props.name
switch (extractCommon.type) {

View File

@ -74,13 +74,13 @@
<el-button
type="primary"
size="mini"
v-show="scope.row.result.showSave"
v-show="scope.row.isSet"
@click="handleAddTask(scope.$index,scope.row)"
>{{ $t('commons.add') }}
</el-button>
<el-button
size="mini"
v-show="scope.row.result.showCancel"
v-show="scope.row.isSet"
@click.native.prevent="removeRowTask(scope.$index,form.jenkinsTask)"
>{{ $t('commons.cancel') }}
</el-button>
@ -88,8 +88,8 @@
type="danger"
icon="el-icon-delete"
size="mini"
v-show="scope.row.result.showDelete"
@click.native.prevent="deleteRowTask(scope.$index,form.jenkinsTask)"
v-show="!scope.row.isSet"
@click.native.prevent="deleteRowTask(scope.$index,scope.row)"
></el-button>
</template>
</el-table-column>
@ -113,7 +113,7 @@
</el-row>
</div>
<el-table
:data="form.testPlanTask"
:data="form.testCasePlanTask"
class="tb-edit"
border
size="mini"
@ -136,7 +136,7 @@
<template v-slot:default="{row}">
<el-select v-model="row.userIds" filterable multiple
:placeholder="$t('commons.please_select')"
@click.native="defectAndTestPlanUserList()" style="width: 100%;">
@click.native="testPlanUserList()" style="width: 100%;">
<el-option
v-for="item in testPlanReceiverOptions"
:key="item.id"
@ -168,22 +168,22 @@
<el-button
type="primary"
size="mini"
v-show="scope.row.result.showSave"
v-show="scope.row.isSet"
@click="handleAddTask(scope.$index,scope.row)"
>{{ $t('commons.add') }}
</el-button>
<el-button
size="mini"
v-show="scope.row.result.showCancel"
@click.native.prevent="removeRowTask(scope.$index,form.testPlanTask)"
v-show="scope.row.isSet"
@click.native.prevent="removeRowTask(scope.$index,form.testCasePlanTask)"
>{{ $t('commons.cancel') }}
</el-button>
<el-button
type="danger"
icon="el-icon-delete"
size="mini"
v-show="scope.row.result.showDelete"
@click.native.prevent="deleteRowTask(scope.$index,form.testPlanTask)"
v-show="!scope.row.isSet"
@click.native.prevent="deleteRowTask(scope.$index,scope.row)"
></el-button>
</template>
</el-table-column>
@ -260,13 +260,13 @@
<el-button
type="primary"
size="mini"
v-show="scope.row.result.showSave"
v-show="scope.row.isSet"
@click="handleAddTask(scope.$index,scope.row)"
>{{ $t('commons.add') }}
</el-button>
<el-button
size="mini"
v-show="scope.row.result.showCancel"
v-show="scope.row.isSet"
@click.native.prevent="removeRowTask(scope.$index,form.reviewTask)"
>{{ $t('commons.cancel') }}
</el-button>
@ -274,8 +274,8 @@
type="danger"
icon="el-icon-delete"
size="mini"
v-show="scope.row.result.showDelete"
@click.native.prevent="deleteRowTask(scope.$index,form.reviewTask)"
v-show="!scope.row.isSet"
@click.native.prevent="deleteRowTask(scope.$index,scope.row)"
></el-button>
</template>
</el-table-column>
@ -320,7 +320,7 @@
<template v-slot:default="{row}">
<el-select v-model="row.userIds" filterable multiple
:placeholder="$t('commons.please_select')"
@click.native="defectAndTestPlanUserList()" style="width: 100%;">
@click.native="defectUserList()" style="width: 100%;">
<el-option
v-for="item in defectReceiverOptions"
:key="item.id"
@ -352,13 +352,13 @@
<el-button
type="primary"
size="mini"
v-show="scope.row.result.showSave"
v-show="scope.row.isSet"
@click="handleAddTask(scope.$index,scope.row)"
>{{ $t('commons.add') }}
</el-button>
<el-button
size="mini"
v-show="scope.row.result.showCancel"
v-show="scope.row.isSet"
@click.native.prevent="removeRowTask(scope.$index,form.defectTask)"
>{{ $t('commons.cancel') }}
</el-button>
@ -366,8 +366,8 @@
type="danger"
icon="el-icon-delete"
size="mini"
v-show="scope.row.result.showDelete"
@click.native.prevent="deleteRowTask(scope.$index,form.defectTask)"
v-show="!scope.row.isSet"
@click.native.prevent="deleteRowTask(scope.$index,scope.row)"
></el-button>
</template>
</el-table-column>
@ -389,53 +389,37 @@ export default {
taskType: "jenkinsTask",
events: [],
userIds: [],
type:[],
type: [],
webhook: "",
result: {
showSave: true,
showCancel: true,
showDelete: false
},
identification:"",
isSet: true,
identification: "",
}],
testPlanTask: [{
testCasePlanTask: [{
taskType: "testPlanTask",
events: [],
userIds: [],
type:[],
type: [],
webhook: "",
result: {
showSave: true,
showCancel: true,
showDelete: false
},
identification:"",
isSet: true,
identification: "",
}],
reviewTask: [{
taskType: "reviewTask",
events: [],
userIds: [],
type:[],
type: [],
webhook: "",
result: {
showSave: true,
showCancel: true,
showDelete: false
},
identification:"",
isSet: true,
identification: "",
}],
defectTask: [{
taskType: "defectTask",
events: [],
userIds: [],
type:[],
type: [],
webhook: "",
result: {
showSave: true,
showCancel: true,
showDelete: false
},
identification:"",
isSet: true,
identification: "",
}],
},
jenkinsEventOptions: [
@ -467,7 +451,7 @@ export default {
methods: {
initForm() {
this.result = this.$get('/notice/search/message', response => {
/*this.form=response.data*/
this.form = response.data
})
},
userList() {
@ -478,62 +462,73 @@ export default {
reviewUerList() {
this.result = this.$get('user/list', response => {
this.reviewReceiverOptions = response.data
this.reviewReceiverOptions.unshift({id: 'Founder', name: this.$t('api_test.creator')},
this.reviewReceiverOptions.unshift({id: 'FOUNDER', name: this.$t('api_test.creator')},
{id: 'Executor', name: this.$t('test_track.plan_view.executor')},
{id: 'Maintainer', name: this.$t('test_track.case.maintainer')})
{id: 'MAINTAINER', name: this.$t('test_track.case.maintainer')})
})
},
defectAndTestPlanUserList() {
defectUserList() {
this.result = this.$get('user/list', response => {
this.defectReceiverOptions = response.data
this.defectReceiverOptions.unshift({id: 'FOUNDER', name: this.$t('api_test.creator')}, {
id: 'EXECUTOR',
name: this.$t('test_track.plan_view.executor')
})
})
},
testPlanUserList() {
this.result = this.$get('user/list', response => {
this.testPlanReceiverOptions = response.data
this.defectReceiverOptions = response.data
this.testPlanReceiverOptions.unshift({id: 'Founder', name: this.$t('api_test.creator')}, {
id: 'Executor',
this.testPlanReceiverOptions.unshift({id: 'FOUNDER', name: this.$t('api_test.creator')}, {
id: 'EXECUTOR',
name: this.$t('test_track.plan_view.executor')
})
})
},
handleAddTaskModel(type) {
let Task = {};
Task.result = {
showSave: true,
showCancel: true,
showDelete: false,
}
Task.events = [];
Task.userIds = [];
Task.type = "";
Task.webhook = "";
Task.isSet = true;
Task.identification = "";
if (type === 'jenkinsTask') {
Task.taskType = 'jenkinsTask'
Task.taskType = 'JENKINS_TASK'
this.form.jenkinsTask.unshift(Task)
} else if (type === 'testPlanTask') {
Task.taskType = 'testPlanTask'
this.form.testPlanTask.unshift(Task)
} else if (type === 'reviewTask') {
Task.taskType = 'reviewTask'
}
if (type === 'testPlanTask') {
Task.taskType = 'TEST_PLAN_TASK'
this.form.testCasePlanTask.unshift(Task)
}
if (type === 'reviewTask') {
Task.taskType = 'REVIEW_TASK'
this.form.reviewTask.unshift(Task)
} else {
Task.taskType = 'defectTask'
}
if (type === 'defectTask') {
Task.taskType = 'DEFECT_TASK'
this.form.defectTask.unshift(Task)
}
},
handleAddTask(index, data) {
let list = []
data.isSet = false
list.push(data)
let param = {};
param.messageDetail = list
this.result = this.$post("/notice/save/message/task", param, () => {
data.result.showSave = false;
data.result.showCancel = false;
data.result.showDelete = true;
})
},
removeRowTask(index, data) { //
data.splice(index, 1)
},
deleteRowTask(index, data) { //
this.result = this.$get("/delete/message" + index, response => {
this.result = this.$get("/notice/delete/message/" + data.identification, response => {
this.initForm()
})
data.splice(index, 1)
/*data.splice(index, 1)*/
},
}
}

View File

@ -211,7 +211,7 @@
</el-row>
<el-row style="margin-top: 15px;margin-bottom: 10px">
<el-col :offset="2" :span="20">附件:
<el-col :offset="2" :span="20">{{ $t('test_track.case.attachment') }}:
<el-upload
accept=".jpg,.jpeg,.png,.xlsx,.doc,.pdf,.docx"
action=""
@ -223,7 +223,7 @@
:limit="8"
:file-list="fileList">
<el-button icon="el-icon-plus" size="mini"></el-button>
<span slot="tip" class="el-upload__tip"> 只能上传jpgjpegpngdocxdocpdfxlsx文件 </span>
<span slot="tip" class="el-upload__tip"> {{ $t('test_track.case.upload_tip') }} </span>
</el-upload>
</el-col>
</el-row>
@ -252,6 +252,10 @@
<el-table-column
:label="$t('commons.operating')">
<template v-slot:default="scope">
<el-button @click="preview(scope.row)" :disabled="!scope.row.id || readOnly" type="primary"
v-if="isPreview(scope.row)"
icon="el-icon-view"
size="mini" circle/>
<el-button @click="handleDownload(scope.row)" :disabled="!scope.row.id || readOnly" type="primary"
icon="el-icon-download"
size="mini" circle/>
@ -277,6 +281,7 @@
</el-dialog>
<test-case-file ref="testCaseFile"/>
</div>
@ -289,10 +294,11 @@ import MsDialogFooter from '../../../common/components/MsDialogFooter'
import {listenGoBack, removeGoBackListener} from "../../../../../common/js/utils";
import {LIST_CHANGE, TrackEvent} from "@/business/components/common/head/ListEvent";
import {Message} from "element-ui";
import TestCaseFile from "@/business/components/track/case/components/TestCaseFile";
export default {
name: "TestCaseEdit",
components: {MsDialogFooter},
components: {MsDialogFooter, TestCaseFile},
data() {
return {
result: {},
@ -718,7 +724,13 @@ export default {
/// todo:
return file.size > 0;
},
preview(row) {
this.$refs.testCaseFile.open(row);
},
isPreview(row) {
const fileType = row.type;
return fileType === 'JPG' || fileType === 'JPEG' || fileType === 'PDF' || fileType === 'PNG';
}
}
}
</script>

View File

@ -0,0 +1,48 @@
<template>
<el-dialog :visible.sync="dialogVisible" width="80%" :destroy-on-close="true" :before-close="close">
<div>
<img :src="'/test/case/file/preview/' + file.id" :alt="$t('test_track.case.img_loading_fail')" style="width: 100%;height: 100%;"
v-if="file.type === 'JPG' || file.type === 'JPEG' || file.type === 'PNG'">
<div v-if="file.type === 'PDF'">
<test-case-pdf :file-id="file.id"/>
</div>
</div>
</el-dialog>
</template>
<script>
import TestCasePdf from "@/business/components/track/case/components/TestCasePdf";
export default {
name: "TestCaseFiles",
components: {TestCasePdf},
props: {},
data() {
return {
file: {
id: '',
type: ''
},
dialogVisible: false,
}
},
methods: {
open(file) {
this.file = file;
this.dialogVisible = true;
},
close() {
this.file = {
id: '',
type: ''
};
this.dialogVisible = false;
}
}
}
</script>
<style scoped>
</style>

View File

@ -0,0 +1,38 @@
<template>
<div v-loading="loading">
<pdf ref="pdf" v-for="i in numPages" :key="i" :src="loadingTask" :page="i"/>
</div>
</template>
<script>
import pdf from "vue-pdf";
export default {
name: "TestCasePdf",
components: {pdf},
props: {
fileId: String
},
data() {
return {
loading: false,
numPages: null,
loadingTask: null,
}
},
mounted() {
this.loading = true;
this.loadingTask = pdf.createLoadingTask("/test/case/file/preview/" + this.fileId);
this.loadingTask.promise.then(pdf => {
this.numPages = pdf.numPages
this.loading = false;
}).catch(() => {
this.loading = false;
this.$error(this.$t('test_track.case.pdf_loading_fail'));
})
}
}
</script>
<style scoped>
</style>

View File

@ -16,7 +16,7 @@
<el-card>
<el-scrollbar>
<el-header>
<el-header style="height: 100%;">
<el-row type="flex" class="head-bar">
@ -27,7 +27,7 @@
</el-button>
</el-col>
<el-col :span="12" class="head-right">
<el-col :span="14" class="head-right">
<el-button plain size="mini" icon="el-icon-arrow-up"
:disabled="index + 1 <= 1"
@ -425,6 +425,7 @@ export default {
.head-right {
text-align: right;
margin-top: 30px;
}
.el-col:not(.test-detail) {

@ -1 +1 @@
Subproject commit cc38137a69a0f20fadece9c0f9f50a9468c4ace9
Subproject commit 06d935cd1d22ab36f09763745c2aff8ad3fb08c1

View File

@ -119,6 +119,7 @@ export default {
reference_documentation: "Reference documentation",
already_exists: 'The name already exists',
modifier: 'Modifier',
validate: "Validate",
date: {
select_date: 'Select date',
start_date: 'Start date',
@ -441,6 +442,7 @@ export default {
jar_config: {
title: "The Jar Package Management",
jar_file: "Jar package",
delete_tip: "The deletion takes effect after the service is restarted",
file_exist: "The name already exists in the project",
upload_limit_size: "Upload file size cannot exceed 30MB!",
},
@ -554,6 +556,7 @@ export default {
select_type: "Choose type",
description: "Extract data from the response and store it in variables. Use the variables in subsequent requests.",
regex: "Regex",
multiple_matching: "Multiple matching",
regex_expression: "Regular expression",
json_path_expression: "JSONPath expression",
xpath_expression: "XPath expression",
@ -741,6 +744,10 @@ export default {
status_pass: 'Pass',
status_un_pass: 'UnPass',
cancel_relevance_project: "Disassociating the project will also cancel the associated test cases under the project",
img_loading_fail: "Image failed to load",
pdf_loading_fail: "PDF loading failed",
upload_tip: "Only jpg, jpeg, png, docx, doc, pdf, xlsx files can be uploaded",
attachment: "Attachment",
import: {
import: "Import test case",
case_import: "Import test case",
@ -748,7 +755,7 @@ export default {
click_upload: "Upload",
upload_limit: "Only XLS/XLSX/XMIND files can be uploaded, and no more than 20M",
upload_xmind_format: "Upload files can only be .xmind format",
upload_xmind: "Only xmind files can be uploaded, and no more than 500",
upload_xmind: "Only xmind files can be uploaded, and no more than 800",
upload_limit_count: "Only one file can be uploaded at a time",
upload_limit_format: "Upload files can only be XLS, XLSX format!",
upload_limit_size: "Upload file size cannot exceed 20MB!",

View File

@ -119,6 +119,7 @@ export default {
required: "{0}是必填的",
already_exists: '名称不能重复',
modifier: '修改人',
validate: "校验",
date: {
select_date: '选择日期',
start_date: '开始日期',
@ -444,6 +445,7 @@ export default {
jar_config: {
title: "jar包管理",
jar_file: "jar包",
delete_tip: "删除需重启服务后生效",
file_exist: "该项目下已存在改jar包",
upload_limit_size: "上传文件大小不能超过 30MB!",
},
@ -554,6 +556,7 @@ export default {
},
extract: {
label: "提取",
multiple_matching: "匹配多条",
select_type: "请选择类型",
description: "从响应结果中提取数据并将其存储在变量中,在后续请求中使用变量。",
regex: "正则",
@ -745,13 +748,17 @@ export default {
status_pass: '通过',
status_un_pass: '未通过',
cancel_relevance_project: "取消项目关联会同时取消该项目下已关联的测试用例",
img_loading_fail: "图片加载失败",
pdf_loading_fail: "PDF加载失败",
upload_tip: "只能上传jpg、jpeg、png、docx、doc、pdf、xlsx文件",
attachment: "附件",
import: {
import: "导入用例",
case_import: "导入测试用例",
download_template: "下载模版",
click_upload: "点击上传",
upload_limit: "只能上传xls/xlsx文件且不超过20M",
upload_xmind: "支持文件类型:.xmind一次至多导入500 条用例",
upload_xmind: "支持文件类型:.xmind一次至多导入800 条用例",
upload_xmind_format: "上传文件只能是 .xmind 格式",
upload_limit_other_size: "上传文件大小不能超过",
upload_limit_count: "一次只能上传一个文件",

View File

@ -119,6 +119,7 @@ export default {
required: "{0}是必填的",
already_exists: '名稱不能重復',
modifier: '修改人',
validate: "校驗",
date: {
select_date: '選擇日期',
start_date: '開始日期',
@ -444,6 +445,7 @@ export default {
jar_config: {
title: "jar包管理",
jar_file: "jar包",
delete_tip: "刪除需重啟服務後生效",
file_exist: "該項目下已存在改jar包",
upload_limit_size: "上傳文件大小不能超過 30MB!",
},
@ -554,6 +556,7 @@ export default {
},
extract: {
label: "提取",
multiple_matching: "匹配多條",
select_type: "請選擇類型",
description: "從響應結果中提取數據並將其存儲在變量中,在後續請求中使用變量。",
regex: "正則",
@ -745,13 +748,17 @@ export default {
status_pass: '通過',
status_un_pass: '未通過',
cancel_relevance_project: "取消項目關聯會同時取消該項目下已關聯的測試用例",
img_loading_fail: "圖片加載失敗",
pdf_loading_fail: "PDF加載失敗",
upload_tip: "只能上傳jpg、jpeg、png、docx、doc、pdf、xlsx文件",
attachment: "附件",
import: {
import: "導入用例",
case_import: "導入測試用例",
download_template: "下載模版",
click_upload: "點擊上傳",
upload_limit: "只能上傳xls/xlsx文件且不超過20M",
upload_xmind: "支持文件類型:.xmind壹次至多導入500 條用例",
upload_xmind: "支持文件類型:.xmind壹次至多導入800 條用例",
upload_xmind_format: "上傳文件只能是 .xmind 格式",
upload_limit_other_size: "上傳文件大小不能超過",
upload_limit_count: "壹次只能上傳壹個文件",