diff --git a/backend/src/main/java/io/metersphere/api/service/APITestService.java b/backend/src/main/java/io/metersphere/api/service/APITestService.java index 51f5bc30ed..37785d599c 100644 --- a/backend/src/main/java/io/metersphere/api/service/APITestService.java +++ b/backend/src/main/java/io/metersphere/api/service/APITestService.java @@ -8,20 +8,27 @@ import io.metersphere.api.dto.scenario.request.dubbo.RegistryCenter; import io.metersphere.api.jmeter.JMeterService; import io.metersphere.api.parse.ApiImportParser; import io.metersphere.api.parse.ApiImportParserFactory; +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.ext.ExtApiTestMapper; -import io.metersphere.commons.constants.*; +import io.metersphere.commons.constants.APITestStatus; +import io.metersphere.commons.constants.FileType; +import io.metersphere.commons.constants.ScheduleGroup; +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.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; @@ -39,6 +46,8 @@ import java.util.stream.Collectors; @Service @Transactional(rollbackFor = Exception.class) public class APITestService { + @Resource + private UserService userService; @Resource private ApiTestMapper apiTestMapper; @Resource @@ -55,6 +64,11 @@ 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"; @@ -72,19 +86,33 @@ public class APITestService { return extApiTestMapper.listByIds(request.getIds()); } - public void create(SaveAPITestRequest request, List bodyFiles) { + public void create(SaveAPITestRequest request, MultipartFile file, List bodyFiles) { List bodyUploadIds = new ArrayList<>(request.getBodyUploadIds()); - ApiTest test = createTest(request); + ApiTest test = createTest(request, file); createBodyFiles(test, bodyUploadIds, bodyFiles); } + private ApiTest createTest(SaveAPITestRequest request, MultipartFile file) { + if (file == null) { + throw new IllegalArgumentException(Translator.get("file_cannot_be_null")); + } + checkQuota(); + request.setBodyUploadIds(null); + ApiTest test = createTest(request); + saveFile(test.getId(), file); + return test; + } - public void update(SaveAPITestRequest request, List bodyFiles) { + public void update(SaveAPITestRequest request, MultipartFile file, List bodyFiles) { + if (file == null) { + throw new IllegalArgumentException(Translator.get("file_cannot_be_null")); + } deleteFileByTestId(request.getId()); List bodyUploadIds = new ArrayList<>(request.getBodyUploadIds()); request.setBodyUploadIds(null); ApiTest test = updateTest(request); createBodyFiles(test, bodyUploadIds, bodyFiles); + saveFile(test.getId(), file); } private void createBodyFiles(ApiTest test, List bodyUploadIds, List bodyFiles) { @@ -127,6 +155,14 @@ public class APITestService { copy.setStatus(APITestStatus.Saved.name()); copy.setUserId(Objects.requireNonNull(SessionUtils.getUser()).getId()); apiTestMapper.insert(copy); + // copy test file + ApiTestFile apiTestFile = getFileByTestId(request.getId()); + if (apiTestFile != null) { + FileMetadata fileMetadata = fileService.copyFile(apiTestFile.getFileId()); + apiTestFile.setTestId(copy.getId()); + apiTestFile.setFileId(fileMetadata.getId()); + apiTestFileMapper.insert(apiTestFile); + } copyBodyFiles(copy.getId(), request.getId()); } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtWorkspaceMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtWorkspaceMapper.java index 57dfd286bf..5bff8104b1 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtWorkspaceMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtWorkspaceMapper.java @@ -9,4 +9,5 @@ import java.util.List; public interface ExtWorkspaceMapper { List getWorkspaceWithOrg(@Param("request") WorkspaceRequest request); + List getWorkspaceIdsByOrgId(@Param("orgId") String orgId); } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtWorkspaceMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtWorkspaceMapper.xml index f864aec32a..34013f1817 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtWorkspaceMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtWorkspaceMapper.xml @@ -13,4 +13,9 @@ order by w.update_time desc + + \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/commons/utils/JsonPathUtils.java b/backend/src/main/java/io/metersphere/commons/utils/JsonPathUtils.java index 6109d7fd60..d978056402 100644 --- a/backend/src/main/java/io/metersphere/commons/utils/JsonPathUtils.java +++ b/backend/src/main/java/io/metersphere/commons/utils/JsonPathUtils.java @@ -12,6 +12,7 @@ import java.util.stream.Collectors; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONPath; +import org.apache.commons.lang3.StringUtils; public class JsonPathUtils { @@ -68,9 +69,26 @@ public class JsonPathUtils { .compareTo( (String)b.get("json_path") ) ); + // 正则特殊字符转义 + allJsons.forEach(item -> { + item.put("regular_expression", escapeExprSpecialWord((String) item.get("json_value"))); + }); + return allJsons; } + public static String escapeExprSpecialWord(String keyword) { + if (StringUtils.isNotBlank(keyword)) { + String[] fbsArr = {"\\", "$", "(", ")", "*", "+", ".", "[", "]", "?", "^", "{", "}", "|"}; + for (String key : fbsArr) { + if (keyword.contains(key)) { + keyword = keyword.replace(key, "\\" + key); + } + } + } + return keyword; + } + private static String formatJson(String json_path){ String ret=""; String reg = ".(\\d{1,3}).{0,1}"; diff --git a/backend/src/main/java/io/metersphere/controller/TestController.java b/backend/src/main/java/io/metersphere/controller/TestController.java index 9783d98572..2e2e761937 100644 --- a/backend/src/main/java/io/metersphere/controller/TestController.java +++ b/backend/src/main/java/io/metersphere/controller/TestController.java @@ -3,6 +3,7 @@ package io.metersphere.controller; import com.alibaba.fastjson.JSONObject; import io.metersphere.base.domain.User; import io.metersphere.commons.utils.SessionUtils; +import io.metersphere.controller.handler.annotation.NoResultHolder; import org.apache.commons.lang3.StringUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -34,6 +35,26 @@ public class TestController { return jsonObject; } + @NoResultHolder + @GetMapping(value = "/xml") + public String getXmlString() { + return "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + " Harry Potter\n" + + " 29.99\n" + + "\n" + + "\n" + + "\n" + + " Learning XML\n" + + " 39.95\n" + + "\n" + + "\n" + + ""; + } + @GetMapping(value = "/{str}") public Object getString(@PathVariable String str) throws InterruptedException { if (StringUtils.equals("error", str)) { diff --git a/backend/src/main/java/io/metersphere/controller/handler/ResultResponseBodyAdvice.java b/backend/src/main/java/io/metersphere/controller/handler/ResultResponseBodyAdvice.java index 5f2e7e0ce3..f83acde163 100644 --- a/backend/src/main/java/io/metersphere/controller/handler/ResultResponseBodyAdvice.java +++ b/backend/src/main/java/io/metersphere/controller/handler/ResultResponseBodyAdvice.java @@ -2,6 +2,7 @@ package io.metersphere.controller.handler; import com.alibaba.fastjson.JSON; import io.metersphere.controller.ResultHolder; +import io.metersphere.controller.handler.annotation.NoResultHolder; import org.springframework.core.MethodParameter; import org.springframework.http.MediaType; import org.springframework.http.converter.HttpMessageConverter; @@ -30,6 +31,10 @@ public class ResultResponseBodyAdvice implements ResponseBodyAdvice { return null; } + if (methodParameter.hasMethodAnnotation(NoResultHolder.class)) { + return o; + } + if (!(o instanceof ResultHolder)) { if (o instanceof String) { return JSON.toJSONString(ResultHolder.success(o)); diff --git a/backend/src/main/java/io/metersphere/controller/handler/annotation/NoResultHolder.java b/backend/src/main/java/io/metersphere/controller/handler/annotation/NoResultHolder.java new file mode 100644 index 0000000000..f04c9845c4 --- /dev/null +++ b/backend/src/main/java/io/metersphere/controller/handler/annotation/NoResultHolder.java @@ -0,0 +1,15 @@ +package io.metersphere.controller.handler.annotation; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Documented +@Inherited +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +public @interface NoResultHolder { +} diff --git a/backend/src/main/java/io/metersphere/notice/service/DingTaskService.java b/backend/src/main/java/io/metersphere/notice/service/DingTaskService.java index dd30c10ff3..c2d56193ba 100644 --- a/backend/src/main/java/io/metersphere/notice/service/DingTaskService.java +++ b/backend/src/main/java/io/metersphere/notice/service/DingTaskService.java @@ -19,6 +19,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; @Service @Transactional(propagation = Propagation.NOT_SUPPORTED) @@ -57,7 +58,9 @@ public class DingTaskService { list.forEach(u -> { phoneList.add(u.getPhone()); }); - at.setAtMobiles(phoneList); + LogUtil.info("收件人地址" + phoneList); + List phoneLists = phoneList.stream().distinct().collect(Collectors.toList()); + at.setAtMobiles(phoneLists); request.setAt(at); OapiRobotSendResponse response = null; try { diff --git a/backend/src/main/java/io/metersphere/notice/service/MailService.java b/backend/src/main/java/io/metersphere/notice/service/MailService.java index 0cc1c5e44e..6abefde70d 100644 --- a/backend/src/main/java/io/metersphere/notice/service/MailService.java +++ b/backend/src/main/java/io/metersphere/notice/service/MailService.java @@ -37,6 +37,7 @@ import javax.mail.internet.MimeMessage; import java.nio.charset.StandardCharsets; import java.text.SimpleDateFormat; import java.util.*; +import java.util.stream.Collectors; @Service @Transactional(propagation = Propagation.NOT_SUPPORTED) @@ -111,7 +112,9 @@ public class MailService { list.forEach(u -> { emails.add(u.getEmail()); }); - users = emails.toArray(new String[0]); + List email = emails.stream().distinct().collect(Collectors.toList()); + users = email.toArray(new String[0]); + LogUtil.info("收件人地址" + users); helper.setText(getContent(Template, context), true); helper.setTo(users); try { @@ -143,9 +146,10 @@ public class MailService { } public void sendCommentNotice(MessageDetail messageDetail, List userIds, SaveCommentRequest request, TestCaseWithBLOBs testCaseWithBLOBs, String eventType) { + User user = userMapper.selectByPrimaryKey(testCaseWithBLOBs.getMaintainer()); BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo(); Map context = new HashMap<>(); - context.put("maintainer", testCaseWithBLOBs.getMaintainer()); + context.put("maintainer", user.getName()); context.put("testCaseName", testCaseWithBLOBs.getName()); context.put("description", request.getDescription()); context.put("url", baseSystemConfigDTO.getUrl()); @@ -183,7 +187,9 @@ public class MailService { list.forEach(u -> { emails.add(u.getEmail()); }); - users = emails.toArray(new String[0]); + List email = emails.stream().distinct().collect(Collectors.toList()); + users = email.toArray(new String[0]); + LogUtil.info("收件人地址" + users); helper.setText(getContent(Template, context), true); helper.setTo(users); if (users.length > 0) { @@ -195,7 +201,8 @@ public class MailService { public void sendTestPlanStartNotice(MessageDetail messageDetail, List userIds, AddTestPlanRequest testPlan, String eventType) { Map context = getTestPlanContext(testPlan); - context.put("creator", testPlan.getCreator()); + User user = userMapper.selectByPrimaryKey(testPlan.getCreator()); + context.put("creator", user.getName()); try { String endTemplate = IOUtils.toString(this.getClass().getResource("/mail/TestPlanStart.html"), StandardCharsets.UTF_8); sendTestPlanNotice(addresseeIdList(messageDetail, userIds, eventType), context, endTemplate); @@ -205,8 +212,9 @@ public class MailService { } public void sendTestPlanEndNotice(MessageDetail messageDetail, List userIds, AddTestPlanRequest testPlan, String eventType) { + User user = userMapper.selectByPrimaryKey(testPlan.getCreator()); Map context = getTestPlanContext(testPlan); - context.put("creator", userIds.toString()); + context.put("creator", user.getName()); try { String endTemplate = IOUtils.toString(this.getClass().getResource("/mail/TestPlanEnd.html"), StandardCharsets.UTF_8); sendTestPlanNotice(addresseeIdList(messageDetail, userIds, eventType), context, endTemplate); @@ -216,8 +224,9 @@ public class MailService { } public void sendTestPlanDeleteNotice(MessageDetail messageDetail, List userIds, AddTestPlanRequest testPlan, String eventType) { + User user = userMapper.selectByPrimaryKey(testPlan.getCreator()); Map context = getTestPlanContext(testPlan); - context.put("creator", userIds.toString()); + context.put("creator", user.getName()); try { String endTemplate = IOUtils.toString(this.getClass().getResource("/mail/TestPlanDelete.html"), StandardCharsets.UTF_8); sendTestPlanNotice(addresseeIdList(messageDetail, userIds, eventType), context, endTemplate); @@ -241,7 +250,9 @@ public class MailService { list.forEach(u -> { emails.add(u.getEmail()); }); - users = emails.toArray(new String[0]); + List email = emails.stream().distinct().collect(Collectors.toList()); + users = email.toArray(new String[0]); + LogUtil.info("收件人地址" + users); helper.setText(getContent(Template, context), true); helper.setTo(users); javaMailSender.send(mimeMessage); @@ -276,7 +287,9 @@ public class MailService { list.forEach(u -> { emails.add(u.getEmail()); }); - users = emails.toArray(new String[0]); + List email = emails.stream().distinct().collect(Collectors.toList()); + users = email.toArray(new String[0]); + LogUtil.info("收件人地址" + users); helper.setText(getContent(Template, context), true); helper.setTo(users); javaMailSender.send(mimeMessage); @@ -381,7 +394,7 @@ public class MailService { if (StringUtils.isNotBlank(context.get(k))) { template = RegExUtils.replaceAll(template, "\\$\\{" + k + "}", context.get(k)); } else { - template = RegExUtils.replaceAll(template, "\\$\\{" + k + "}", ""); + template = RegExUtils.replaceAll(template, "\\$\\{" + k + "}", "未设置"); } } } diff --git a/backend/src/main/java/io/metersphere/notice/service/NoticeService.java b/backend/src/main/java/io/metersphere/notice/service/NoticeService.java index 771e651f79..af3257e0cc 100644 --- a/backend/src/main/java/io/metersphere/notice/service/NoticeService.java +++ b/backend/src/main/java/io/metersphere/notice/service/NoticeService.java @@ -5,8 +5,10 @@ import io.metersphere.base.domain.MessageTaskExample; import io.metersphere.base.mapper.MessageTaskMapper; import io.metersphere.base.mapper.ext.ExtMessageMapper; import io.metersphere.commons.constants.NoticeConstants; +import io.metersphere.commons.exception.MSException; import io.metersphere.commons.user.SessionUser; import io.metersphere.commons.utils.SessionUtils; +import io.metersphere.i18n.Translator; import io.metersphere.notice.controller.request.MessageRequest; import io.metersphere.notice.domain.MessageDetail; import io.metersphere.notice.domain.MessageSettingDetail; @@ -49,6 +51,7 @@ public class NoticeService { long time = System.currentTimeMillis(); String identification = UUID.randomUUID().toString(); list.getUserIds().forEach(m -> { + checkUserIdExist(m, list); MessageTask message = new MessageTask(); message.setId(UUID.randomUUID().toString()); message.setEvent(list.getEvent()); @@ -57,7 +60,7 @@ public class NoticeService { message.setType(list.getType()); message.setWebhook(list.getWebhook()); message.setIdentification(identification); - message.setIsSet(list.getIsSet()); + message.setIsSet(false); message.setOrganizationId(orgId); message.setTestId(list.getTestId()); message.setCreateTime(time); @@ -65,6 +68,14 @@ public class NoticeService { }); } + private void checkUserIdExist(String userId, MessageDetail list) { + MessageTaskExample example = new MessageTaskExample(); + example.createCriteria().andUserIdEqualTo(userId).andEventEqualTo(list.getEvent()).andTypeEqualTo(list.getType()).andTaskTypeEqualTo(list.getTaskType()).andWebhookEqualTo(list.getWebhook()); + if (messageTaskMapper.countByExample(example) > 0) { + MSException.throwException(Translator.get("message_task_already_exists")); + } + } + public List searchMessageSchedule(String testId) { List messageTaskLists = extMessageMapper.searchMessageByTestId(testId); List scheduleMessageTask = new ArrayList<>(); @@ -116,10 +127,14 @@ public class NoticeService { messageDetail.setUserIds(new ArrayList(userIds)); MessageDetailList.add(messageDetail); }); - List jenkinsTask = MessageDetailList.stream().filter(a -> a.getTaskType().equals(NoticeConstants.JENKINS_TASK)).sorted(Comparator.comparing(MessageDetail::getCreateTime, Comparator.nullsLast(Long::compareTo)).reversed()).collect(Collectors.toList()); - List testCasePlanTask = MessageDetailList.stream().filter(a -> a.getTaskType().equals(NoticeConstants.TEST_PLAN_TASK)).sorted(Comparator.comparing(MessageDetail::getCreateTime, Comparator.nullsLast(Long::compareTo)).reversed()).collect(Collectors.toList()); - List reviewTask = MessageDetailList.stream().filter(a -> a.getTaskType().equals(NoticeConstants.REVIEW_TASK)).sorted(Comparator.comparing(MessageDetail::getCreateTime, Comparator.nullsLast(Long::compareTo)).reversed()).collect(Collectors.toList()); - List defectTask = MessageDetailList.stream().filter(a -> a.getTaskType().equals(NoticeConstants.DEFECT_TASK)).sorted(Comparator.comparing(MessageDetail::getCreateTime, Comparator.nullsLast(Long::compareTo)).reversed()).collect(Collectors.toList()); + List jenkinsTask = (MessageDetailList.stream().filter(a -> a.getTaskType().equals(NoticeConstants.JENKINS_TASK)).sorted(Comparator.comparing( + MessageDetail::getCreateTime, Comparator.nullsLast(Long::compareTo)).reversed()).collect(Collectors.toList())).stream().distinct().collect(Collectors.toList()); + List testCasePlanTask = (MessageDetailList.stream().filter(a -> a.getTaskType().equals(NoticeConstants.TEST_PLAN_TASK)).sorted(Comparator.comparing( + MessageDetail::getCreateTime, Comparator.nullsLast(Long::compareTo)).reversed()).collect(Collectors.toList())).stream().distinct().collect(Collectors.toList()); + List reviewTask = (MessageDetailList.stream().filter(a -> a.getTaskType().equals(NoticeConstants.REVIEW_TASK)).sorted(Comparator.comparing( + MessageDetail::getCreateTime, Comparator.nullsLast(Long::compareTo)).reversed()).collect(Collectors.toList())).stream().distinct().collect(Collectors.toList()); + List defectTask = (MessageDetailList.stream().filter(a -> a.getTaskType().equals(NoticeConstants.DEFECT_TASK)).sorted(Comparator.comparing( + MessageDetail::getCreateTime, Comparator.nullsLast(Long::compareTo)).reversed()).collect(Collectors.toList())).stream().distinct().collect(Collectors.toList()); messageSettingDetail.setJenkinsTask(jenkinsTask); messageSettingDetail.setTestCasePlanTask(testCasePlanTask); messageSettingDetail.setReviewTask(reviewTask); diff --git a/backend/src/main/java/io/metersphere/notice/service/WxChatTaskService.java b/backend/src/main/java/io/metersphere/notice/service/WxChatTaskService.java index 10be211dc5..2de762ead7 100644 --- a/backend/src/main/java/io/metersphere/notice/service/WxChatTaskService.java +++ b/backend/src/main/java/io/metersphere/notice/service/WxChatTaskService.java @@ -18,6 +18,7 @@ import javax.annotation.Resource; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; @Service @Transactional(propagation = Propagation.NOT_SUPPORTED) @@ -50,7 +51,9 @@ public class WxChatTaskService { list.forEach(u -> { phoneList.add(u.getPhone()); }); - mentionedMobileList.addAll(phoneList); + LogUtil.info("收件人地址" + phoneList); + List phoneLists = phoneList.stream().distinct().collect(Collectors.toList()); + mentionedMobileList.addAll(phoneLists); message.setMentionedMobileList(mentionedMobileList); try { SendResult result = WxChatbotClient.send(Webhook, message); diff --git a/backend/src/main/java/io/metersphere/service/SystemParameterService.java b/backend/src/main/java/io/metersphere/service/SystemParameterService.java index 680a0886e0..5e459afb0b 100644 --- a/backend/src/main/java/io/metersphere/service/SystemParameterService.java +++ b/backend/src/main/java/io/metersphere/service/SystemParameterService.java @@ -7,6 +7,7 @@ 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; +import io.metersphere.commons.utils.LogUtil; import io.metersphere.dto.BaseSystemConfigDTO; import io.metersphere.i18n.Translator; import io.metersphere.ldap.domain.LdapInfo; @@ -99,6 +100,7 @@ public class SystemParameterService { try { javaMailSender.testConnection(); } catch (MessagingException e) { + LogUtil.error(e); MSException.throwException(Translator.get("connection_failed")); } } diff --git a/backend/src/main/java/io/metersphere/service/UserService.java b/backend/src/main/java/io/metersphere/service/UserService.java index 6a20ed42c3..a5f0f33543 100644 --- a/backend/src/main/java/io/metersphere/service/UserService.java +++ b/backend/src/main/java/io/metersphere/service/UserService.java @@ -318,6 +318,17 @@ public class UserService { } public void updateUser(User user) { + // todo 提取重复代码 + if (StringUtils.isNotBlank(user.getEmail())) { + UserExample example = new UserExample(); + UserExample.Criteria criteria = example.createCriteria(); + criteria.andEmailEqualTo(user.getEmail()); + criteria.andIdNotEqualTo(user.getId()); + if (userMapper.countByExample(example) > 0) { + MSException.throwException(Translator.get("user_email_already_exists")); + } + } + user.setUpdateTime(System.currentTimeMillis()); userMapper.updateByPrimaryKeySelective(user); // 禁用用户之后,剔除在线用户 @@ -424,8 +435,12 @@ public class UserService { } public void delOrganizationMember(String organizationId, String userId) { + + List resourceIds = workspaceService.getWorkspaceIdsOrgId(organizationId); + resourceIds.add(organizationId); + UserRoleExample userRoleExample = new UserRoleExample(); - userRoleExample.createCriteria().andRoleIdLike("%org%").andUserIdEqualTo(userId).andSourceIdEqualTo(organizationId); + userRoleExample.createCriteria().andUserIdEqualTo(userId).andSourceIdIn(resourceIds); User user = userMapper.selectByPrimaryKey(userId); if (StringUtils.equals(organizationId, user.getLastOrganizationId())) { diff --git a/backend/src/main/java/io/metersphere/service/WorkspaceService.java b/backend/src/main/java/io/metersphere/service/WorkspaceService.java index 20dd34c259..5868b270d2 100644 --- a/backend/src/main/java/io/metersphere/service/WorkspaceService.java +++ b/backend/src/main/java/io/metersphere/service/WorkspaceService.java @@ -202,6 +202,10 @@ public class WorkspaceService { return resultWorkspaceList; } + public List getWorkspaceIdsOrgId(String orgId) { + return extWorkspaceMapper.getWorkspaceIdsByOrgId(orgId); + } + public void updateWorkspaceMember(WorkspaceMemberDTO memberDTO) { String workspaceId = memberDTO.getWorkspaceId(); String userId = memberDTO.getId(); diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseCommentService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseCommentService.java index f7d0f28af4..2ed274c442 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseCommentService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseCommentService.java @@ -3,8 +3,10 @@ package io.metersphere.track.service; import io.metersphere.base.domain.TestCaseComment; import io.metersphere.base.domain.TestCaseCommentExample; import io.metersphere.base.domain.TestCaseWithBLOBs; +import io.metersphere.base.domain.User; import io.metersphere.base.mapper.TestCaseCommentMapper; import io.metersphere.base.mapper.TestCaseMapper; +import io.metersphere.base.mapper.UserMapper; import io.metersphere.base.mapper.ext.ExtTestCaseCommentMapper; import io.metersphere.commons.constants.NoticeConstants; import io.metersphere.commons.exception.MSException; @@ -48,7 +50,8 @@ public class TestCaseCommentService { private NoticeService noticeService; @Resource private ExtTestCaseCommentMapper extTestCaseCommentMapper; - + @Resource + private UserMapper userMapper; public void saveComment(SaveCommentRequest request) { TestCaseComment testCaseComment = new TestCaseComment(); @@ -97,6 +100,7 @@ public class TestCaseCommentService { } private String getReviewContext(TestCaseComment testCaseComment, TestCaseWithBLOBs testCaseWithBLOBs) { + User user = userMapper.selectByPrimaryKey(testCaseComment.getAuthor()); Long startTime = testCaseComment.getCreateTime(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String start = null; @@ -105,7 +109,7 @@ public class TestCaseCommentService { start = sdf.format(new Date(Long.parseLong(sTime))); } String context = ""; - context = "测试评审任务通知:" + testCaseComment.getAuthor() + "在" + start + "为" + "'" + testCaseWithBLOBs.getName() + "'" + "添加评论:" + testCaseComment.getDescription(); + context = "测试评审任务通知:" + user.getName() + "在" + start + "为" + "'" + testCaseWithBLOBs.getName() + "'" + "添加评论:" + testCaseComment.getDescription(); return context; } diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java index 8a76212498..13d75cb5d7 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java @@ -572,10 +572,14 @@ public class TestCaseReviewService { String eTime = String.valueOf(endTime); if (!sTime.equals("null")) { start = sdf.format(new Date(Long.parseLong(sTime))); + } else { + start = "未设置"; } String end = null; if (!eTime.equals("null")) { end = sdf.format(new Date(Long.parseLong(eTime))); + } else { + start = "未设置"; } String context = ""; if (StringUtils.equals(NoticeConstants.CREATE, type)) { diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java index c8157e472d..c6ab04e11b 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -141,7 +141,7 @@ public class TestPlanService { } } - public List getTestPlanByName(String name) { + public synchronized List getTestPlanByName(String name) { TestPlanExample example = new TestPlanExample(); example.createCriteria().andWorkspaceIdEqualTo(SessionUtils.getCurrentWorkspaceId()) .andNameEqualTo(name); @@ -547,13 +547,13 @@ public class TestPlanService { if (!sTime.equals("null")) { start = sdf.format(new Date(Long.parseLong(sTime))); } else { - start = ""; + start = "未设置"; } String end = null; if (!eTime.equals("null")) { end = sdf.format(new Date(Long.parseLong(eTime))); } else { - end = ""; + end = "未设置"; } String context = ""; if (StringUtils.equals(NoticeConstants.CREATE, type)) { diff --git a/backend/src/main/resources/i18n/messages_en_US.properties b/backend/src/main/resources/i18n/messages_en_US.properties index 9aec80622b..8cf497635c 100644 --- a/backend/src/main/resources/i18n/messages_en_US.properties +++ b/backend/src/main/resources/i18n/messages_en_US.properties @@ -171,6 +171,7 @@ task_notification_=Timing task result notification api_definition_url_not_repeating=The interface request address already exists task_notification_jenkins=Jenkins Task notification task_notification=Result notification +message_task_already_exists=Task recipient already exists diff --git a/backend/src/main/resources/i18n/messages_zh_CN.properties b/backend/src/main/resources/i18n/messages_zh_CN.properties index 8226488ddb..c659fa7432 100644 --- a/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -171,4 +171,5 @@ task_defect_notification=缺陷任务通知 task_notification_=定时任务结果通知 api_definition_url_not_repeating=接口请求地址已经存在 task_notification_jenkins=jenkins任务通知 -task_notification=任务通知 \ No newline at end of file +task_notification=任务通知 +message_task_already_exists=任务接收人已经存在 \ No newline at end of file diff --git a/backend/src/main/resources/i18n/messages_zh_TW.properties b/backend/src/main/resources/i18n/messages_zh_TW.properties index 4d60417416..491a543523 100644 --- a/backend/src/main/resources/i18n/messages_zh_TW.properties +++ b/backend/src/main/resources/i18n/messages_zh_TW.properties @@ -173,3 +173,5 @@ task_notification_jenkins=jenkins任務通知 task_notification=任務通知 task_notification_=定時任務通知 api_definition_url_not_repeating=接口請求地址已經存在 +message_task_already_exists=任務接收人已經存在 + diff --git a/frontend/src/business/components/api/report/components/ResponseText.vue b/frontend/src/business/components/api/report/components/ResponseText.vue index 3c6e4cf331..d960e179f8 100644 --- a/frontend/src/business/components/api/report/components/ResponseText.vue +++ b/frontend/src/business/components/api/report/components/ResponseText.vue @@ -21,9 +21,10 @@
{{response.vars}}
- + @@ -33,60 +34,64 @@