This commit is contained in:
chenjianxing 2020-09-23 11:47:39 +08:00
commit 9f8a937d50
19 changed files with 97 additions and 74 deletions

View File

@ -12,7 +12,6 @@ import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.controller.request.QueryScheduleRequest;
import io.metersphere.dto.LicenseDTO;
import io.metersphere.dto.ScheduleDao;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;

View File

@ -20,7 +20,6 @@ import io.metersphere.commons.constants.ScheduleType;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.utils.*;
import io.metersphere.controller.request.QueryScheduleRequest;
import io.metersphere.dto.LicenseDTO;
import io.metersphere.dto.ScheduleDao;
import io.metersphere.i18n.Translator;
import io.metersphere.job.sechedule.ApiTestJob;

View File

@ -5,7 +5,6 @@ import io.metersphere.commons.constants.UserSource;
import io.metersphere.commons.user.SessionUser;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.controller.request.LoginRequest;
import io.metersphere.dto.LicenseDTO;
import io.metersphere.service.UserService;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;

View File

@ -1,14 +0,0 @@
package io.metersphere.dto;
import lombok.Data;
import java.io.Serializable;
@Data
public class LicenseDTO implements Serializable {
private String status;
private LicenseInfoDTO license;
}

View File

@ -1,21 +0,0 @@
package io.metersphere.dto;
import lombok.Data;
import java.io.Serializable;
@Data
public class LicenseInfoDTO implements Serializable {
// 客户名称
private String corporation;
// 授权截止时间
private String expired;
//产品名称
private String product;
//产品版本
private String edition;
//icense版本
private String licenseVersion;
//授权数量
private int licenseCount;
}

View File

@ -3,12 +3,14 @@ package io.metersphere.notice.service;
import io.metersphere.api.dto.APIReportResult;
import io.metersphere.base.domain.Notice;
import io.metersphere.base.domain.SystemParameter;
import io.metersphere.base.domain.TestCaseWithBLOBs;
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.service.SystemParameterService;
import io.metersphere.service.UserService;
import io.metersphere.track.request.testreview.SaveCommentRequest;
import io.metersphere.track.request.testreview.SaveTestCaseReviewRequest;
import org.springframework.mail.MailException;
import org.springframework.mail.javamail.JavaMailSenderImpl;
@ -138,12 +140,20 @@ public class MailService {
}
public void sendHtml(List<String> userIds, String type, SaveTestCaseReviewRequest reviewRequest) {
public void sendHtml(List<String> userIds, String type, SaveTestCaseReviewRequest reviewRequest, SaveCommentRequest request, TestCaseWithBLOBs testCaseWithBLOBs) {
Long startTime = reviewRequest.getCreateTime();
Long endTime = reviewRequest.getEndTime();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String start = sdf.format(new Date(Long.parseLong(String.valueOf(startTime))));
String end = sdf.format(new Date(Long.parseLong(String.valueOf(endTime))));
String start = null;
String sTime = String.valueOf(startTime);
String eTime = String.valueOf(endTime);
if (!sTime.equals("null")) {
start = sdf.format(new Date(Long.parseLong(sTime)));
}
String end = null;
if (!eTime.equals("null")) {
end = sdf.format(new Date(Long.parseLong(eTime)));
}
JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl();
List<SystemParameter> paramList = systemParameterService.getParamList(ParamConstants.Classify.MAIL.getValue());
javaMailSender.setDefaultEncoding("UTF-8");
@ -182,8 +192,31 @@ public class MailService {
" </div>\n" +
"</body>\n" +
"</html>";
String html2 = "";
String html3 = "";
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" +
" <p>" + testCaseWithBLOBs.getMaintainer() + "发起的" + testCaseWithBLOBs.getName() + "添加评论:" + request.getDescription() + "</p>\n" +
" </div>\n" +
"</body>\n" +
"</html>";
String html3 = "<!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" +
" <p>" + reviewRequest.getCreator() + "发起的" + reviewRequest.getName() + "的计划开始时间是" + start + ",计划结束时间为" + end + "已完成" + "</p>\n" +
" </div>\n" +
"</body>\n" +
"</html>";
;
try {
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true);
helper.setFrom(javaMailSender.getUsername());
@ -198,6 +231,10 @@ public class MailService {
users = emails.toArray(new String[emails.size()]);
if (type.equals("reviewer")) {
helper.setText(html1, true);
} else if (type.equals("comment")) {
helper.setText(html2, true);
} else if (type.equals("end")) {
helper.setText(html3, true);
}
helper.setTo(users);

View File

@ -1,10 +0,0 @@
package io.metersphere.service;
import io.metersphere.dto.LicenseDTO;
public interface LicenseService {
public LicenseDTO valid();
public LicenseDTO addValidLicense(String reqLicenseCode);
}

View File

@ -10,7 +10,6 @@ import io.metersphere.commons.constants.UserStatus;
import io.metersphere.commons.exception.MSException;
import io.metersphere.commons.user.SessionUser;
import io.metersphere.commons.utils.CodingUtil;
import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.controller.ResultHolder;
import io.metersphere.controller.request.LoginRequest;
@ -20,7 +19,6 @@ import io.metersphere.controller.request.member.QueryMemberRequest;
import io.metersphere.controller.request.member.UserRequest;
import io.metersphere.controller.request.organization.AddOrgMemberRequest;
import io.metersphere.controller.request.organization.QueryOrgMemberRequest;
import io.metersphere.dto.LicenseDTO;
import io.metersphere.dto.UserDTO;
import io.metersphere.dto.UserRoleDTO;
import io.metersphere.i18n.Translator;

View File

@ -1,16 +1,21 @@
package io.metersphere.track.service;
import io.metersphere.base.domain.TestCaseComment;
import io.metersphere.base.domain.TestCaseCommentExample;
import io.metersphere.base.domain.User;
import io.metersphere.base.domain.*;
import io.metersphere.base.mapper.TestCaseCommentMapper;
import io.metersphere.base.mapper.TestCaseMapper;
import io.metersphere.base.mapper.TestCaseReviewMapper;
import io.metersphere.base.mapper.UserMapper;
import io.metersphere.commons.utils.SessionUtils;
import io.metersphere.notice.service.MailService;
import io.metersphere.track.request.testreview.SaveCommentRequest;
import io.metersphere.track.request.testreview.SaveTestCaseReviewRequest;
import org.apache.commons.beanutils.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
@ -21,7 +26,13 @@ public class TestCaseCommentService {
@Resource
TestCaseCommentMapper testCaseCommentMapper;
@Resource
private TestCaseReviewMapper testCaseReviewMapper;
@Resource
UserMapper userMapper;
@Resource
MailService mailService;
@Resource
TestCaseMapper testCaseMapper;
public void saveComment(SaveCommentRequest request) {
TestCaseComment testCaseComment = new TestCaseComment();
@ -32,6 +43,13 @@ public class TestCaseCommentService {
testCaseComment.setUpdateTime(System.currentTimeMillis());
testCaseComment.setDescription(request.getDescription());
testCaseCommentMapper.insert(testCaseComment);
TestCaseWithBLOBs testCaseWithBLOBs;
testCaseWithBLOBs = testCaseMapper.selectByPrimaryKey(request.getCaseId());
SaveTestCaseReviewRequest caseReviewRequest = new SaveTestCaseReviewRequest();
List<String> userIds = new ArrayList<>();
userIds.add(testCaseComment.getAuthor());
mailService.sendHtml(userIds, "comment", caseReviewRequest, request, testCaseWithBLOBs);
}
public List<TestCaseComment> getComments(String caseId) {

View File

@ -17,10 +17,8 @@ import io.metersphere.controller.request.member.QueryMemberRequest;
import io.metersphere.notice.service.MailService;
import io.metersphere.service.UserService;
import io.metersphere.track.dto.*;
import io.metersphere.track.request.testreview.QueryTestReviewRequest;
import io.metersphere.track.request.testreview.ReviewRelevanceRequest;
import io.metersphere.track.request.testreview.QueryCaseReviewRequest;
import io.metersphere.track.request.testreview.SaveTestCaseReviewRequest;
import io.metersphere.track.request.testreview.*;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
@ -30,6 +28,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.lang.reflect.InvocationTargetException;
import java.util.*;
import java.util.stream.Collectors;
@ -64,6 +63,7 @@ public class TestCaseReviewService {
@Resource
MailService mailService;
public void saveTestCaseReview(SaveTestCaseReviewRequest reviewRequest) {
checkCaseReviewExist(reviewRequest);
@ -91,7 +91,9 @@ public class TestCaseReviewService {
reviewRequest.setCreator(SessionUtils.getUser().getId());
reviewRequest.setStatus(TestCaseReviewStatus.Prepare.name());
testCaseReviewMapper.insert(reviewRequest);
mailService.sendHtml(userIds, "reviewer", reviewRequest);
SaveCommentRequest request = new SaveCommentRequest();
TestCaseWithBLOBs testCaseWithBLOBs = new TestCaseWithBLOBs();
mailService.sendHtml(userIds, "reviewer", reviewRequest, request, testCaseWithBLOBs);
}
@ -148,7 +150,9 @@ public class TestCaseReviewService {
testCaseReview.setUpdateTime(System.currentTimeMillis());
checkCaseReviewExist(testCaseReview);
testCaseReviewMapper.updateByPrimaryKeySelective(testCaseReview);
mailService.sendHtml(testCaseReview.getUserIds(), "reviewer", testCaseReview);
SaveCommentRequest request = new SaveCommentRequest();
TestCaseWithBLOBs testCaseWithBLOBs = new TestCaseWithBLOBs();
mailService.sendHtml(testCaseReview.getUserIds(), "reviewer", testCaseReview, request, testCaseWithBLOBs);
}
private void editCaseReviewer(SaveTestCaseReviewRequest testCaseReview) {
@ -321,6 +325,20 @@ public class TestCaseReviewService {
}
}
testCaseReview.setStatus(TestPlanStatus.Completed.name());
SaveCommentRequest request = new SaveCommentRequest();
TestCaseWithBLOBs testCaseWithBLOBs = new TestCaseWithBLOBs();
SaveTestCaseReviewRequest testCaseReviewRequest = new SaveTestCaseReviewRequest();
TestCaseReview _testCaseReview = testCaseReviewMapper.selectByPrimaryKey(reviewId);
List<String> userIds = new ArrayList<>();
userIds.add(_testCaseReview.getCreator());
try {
BeanUtils.copyProperties(testCaseReviewRequest, _testCaseReview);
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
mailService.sendHtml(userIds, "end", testCaseReviewRequest, request, testCaseWithBLOBs);
testCaseReviewMapper.updateByPrimaryKeySelective(testCaseReview);
}

@ -1 +1 @@
Subproject commit e51e5704f9d7fbfb030a8a7d67d0094a9f36c23d
Subproject commit cf6b06526324326a563d933e07118fac014a63b4

View File

@ -32,7 +32,7 @@
import {saveLocalStorage} from "../common/js/utils";
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
const header = requireComponent("./license/LicenseMessage.vue");
const header = requireComponent.keys().length > 0 ? requireComponent("./license/LicenseMessage.vue") : {};
export default {
name: 'app',

View File

@ -210,7 +210,7 @@ export default {
});
},
editTestReview(param) {
this.$post('/test/case/review/' + this.operationType, param, () => {
this.result = this.$post('/test/case/review/' + this.operationType, param, () => {
this.$success(this.$t('commons.save_success'));
this.dialogFormVisible = false;
this.$emit("refresh");

View File

@ -166,7 +166,7 @@
type="textarea"
:autosize="{ minRows: 2, maxRows: 4}"
:rows="2"
:disabled="isReadOnly"
:disabled="true"
v-model="scope.row.actualResult"
:placeholder="$t('commons.input_content')"
clearable/>
@ -175,7 +175,7 @@
<el-table-column :label="$t('test_track.plan_view.step_result')" min-width="12%">
<template v-slot:default="scope">
<el-select
:disabled="isReadOnly"
:disabled="true"
v-model="scope.row.executeResult"
@change="stepResultChange()"
size="mini">

@ -1 +1 @@
Subproject commit 0368a1888936d4ae75554e5341509379982e243c
Subproject commit 06d935cd1d22ab36f09763745c2aff8ad3fb08c1

View File

@ -136,7 +136,7 @@ export default {
.then(response => {
let fileName = window.decodeURI(response.headers['content-disposition'].split('=')[1]);
let link = document.createElement("a");
link.href = window.URL.createObjectURL(new Blob([response.data], {type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"}));
link.href = window.URL.createObjectURL(new Blob([response.data]));
link.download = fileName;
link.click();
});

View File

@ -279,7 +279,7 @@ export default {
email_format_is_incorrect: 'Email format is incorrect',
delete_confirm: 'Are you sure you want to delete this User?',
apikey_delete_confirm: 'Are you sure you want to delete this API Key?',
input_id_placeholder: 'Please enter ID (only supports numbers and English letters)',
input_id_placeholder: 'Please enter ID (Chinese characters are not supported)',
source: 'Source'
},
role: {

View File

@ -279,7 +279,7 @@ export default {
email_format_is_incorrect: '邮箱格式不正确',
delete_confirm: '这个用户确定要删除吗?',
apikey_delete_confirm: '这个 API Key 确定要删除吗?',
input_id_placeholder: '请输入ID (只支持数字、英文字母)',
input_id_placeholder: '请输入ID (不支持中文)',
source: '用户来源'
},
role: {

View File

@ -279,7 +279,7 @@ export default {
email_format_is_incorrect: '郵箱格式不正確',
delete_confirm: '這個用戶確定要刪除嗎?',
apikey_delete_confirm: '這個 API Key 確定要刪除嗎?',
input_id_placeholder: '請輸入ID (只支持數字、英文字母)',
input_id_placeholder: '請輸入ID (不支持中文字符)',
source: '用戶來源'
},
role: {