chore: 修改类名和参数名,使其更加通用
This commit is contained in:
parent
1f4b8b44e6
commit
7b131c3361
|
@ -42,7 +42,7 @@ import io.metersphere.system.log.constants.OperationLogType;
|
||||||
import io.metersphere.system.log.dto.LogDTO;
|
import io.metersphere.system.log.dto.LogDTO;
|
||||||
import io.metersphere.system.log.service.OperationLogService;
|
import io.metersphere.system.log.service.OperationLogService;
|
||||||
import io.metersphere.system.notice.constants.NoticeConstants;
|
import io.metersphere.system.notice.constants.NoticeConstants;
|
||||||
import io.metersphere.system.notice.sender.AfterReturningNoticeSendService;
|
import io.metersphere.system.service.CommonNoticeSendService;
|
||||||
import io.metersphere.system.uid.IDGenerator;
|
import io.metersphere.system.uid.IDGenerator;
|
||||||
import io.metersphere.system.uid.NumGenerator;
|
import io.metersphere.system.uid.NumGenerator;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
@ -87,7 +87,7 @@ public class ApiDefinitionImportUtilService {
|
||||||
@Resource
|
@Resource
|
||||||
private OperationLogService operationLogService;
|
private OperationLogService operationLogService;
|
||||||
@Resource
|
@Resource
|
||||||
private AfterReturningNoticeSendService afterReturningNoticeSendService;
|
private CommonNoticeSendService commonNoticeSendService;
|
||||||
|
|
||||||
private static final String FILE_JMX = "jmx";
|
private static final String FILE_JMX = "jmx";
|
||||||
private static final String FILE_HAR = "har";
|
private static final String FILE_HAR = "har";
|
||||||
|
@ -389,10 +389,10 @@ public class ApiDefinitionImportUtilService {
|
||||||
//发送通知
|
//发送通知
|
||||||
List<Map> createResources = new ArrayList<>();
|
List<Map> createResources = new ArrayList<>();
|
||||||
createResources.addAll(JSON.parseArray(JSON.toJSONString(createLists), Map.class));
|
createResources.addAll(JSON.parseArray(JSON.toJSONString(createLists), Map.class));
|
||||||
afterReturningNoticeSendService.sendNotice(NoticeConstants.TaskType.API_DEFINITION_TASK, NoticeConstants.Event.CREATE, createResources, user, request.getProjectId());
|
commonNoticeSendService.sendNotice(NoticeConstants.TaskType.API_DEFINITION_TASK, NoticeConstants.Event.CREATE, createResources, user, request.getProjectId());
|
||||||
List<Map> updateResources = new ArrayList<>();
|
List<Map> updateResources = new ArrayList<>();
|
||||||
updateResources.addAll(JSON.parseArray(JSON.toJSONString(updateResources), Map.class));
|
updateResources.addAll(JSON.parseArray(JSON.toJSONString(updateResources), Map.class));
|
||||||
afterReturningNoticeSendService.sendNotice(NoticeConstants.TaskType.API_DEFINITION_TASK, NoticeConstants.Event.UPDATE, updateResources, user, request.getProjectId());
|
commonNoticeSendService.sendNotice(NoticeConstants.TaskType.API_DEFINITION_TASK, NoticeConstants.Event.UPDATE, updateResources, user, request.getProjectId());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getNeedUpdateData(ImportRequest request, ApiDetailWithData apiDetailWithData, ApiDetailWithDataUpdate apiDetailWithDataUpdate) {
|
private void getNeedUpdateData(ImportRequest request, ApiDetailWithData apiDetailWithData, ApiDetailWithDataUpdate apiDetailWithDataUpdate) {
|
||||||
|
|
|
@ -46,7 +46,7 @@ import io.metersphere.system.log.service.OperationLogService;
|
||||||
import io.metersphere.system.mapper.OperationHistoryMapper;
|
import io.metersphere.system.mapper.OperationHistoryMapper;
|
||||||
import io.metersphere.system.mapper.UserMapper;
|
import io.metersphere.system.mapper.UserMapper;
|
||||||
import io.metersphere.system.notice.constants.NoticeConstants;
|
import io.metersphere.system.notice.constants.NoticeConstants;
|
||||||
import io.metersphere.system.notice.sender.AfterReturningNoticeSendService;
|
import io.metersphere.system.service.CommonNoticeSendService;
|
||||||
import io.metersphere.system.service.BaseCustomFieldOptionService;
|
import io.metersphere.system.service.BaseCustomFieldOptionService;
|
||||||
import io.metersphere.system.service.BaseCustomFieldService;
|
import io.metersphere.system.service.BaseCustomFieldService;
|
||||||
import io.metersphere.system.service.OperationHistoryService;
|
import io.metersphere.system.service.OperationHistoryService;
|
||||||
|
@ -156,7 +156,7 @@ public class FunctionalCaseService {
|
||||||
@Resource
|
@Resource
|
||||||
private FileAssociationMapper fileAssociationMapper;
|
private FileAssociationMapper fileAssociationMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private AfterReturningNoticeSendService afterReturningNoticeSendService;
|
private CommonNoticeSendService commonNoticeSendService;
|
||||||
@Resource
|
@Resource
|
||||||
private OperationHistoryService operationHistoryService;
|
private OperationHistoryService operationHistoryService;
|
||||||
@Resource
|
@Resource
|
||||||
|
@ -993,7 +993,7 @@ public class FunctionalCaseService {
|
||||||
|
|
||||||
List<Map> resources = new ArrayList<>();
|
List<Map> resources = new ArrayList<>();
|
||||||
resources.addAll(JSON.parseArray(JSON.toJSONString(noticeList), Map.class));
|
resources.addAll(JSON.parseArray(JSON.toJSONString(noticeList), Map.class));
|
||||||
afterReturningNoticeSendService.sendNotice(NoticeConstants.TaskType.FUNCTIONAL_CASE_TASK, NoticeConstants.Event.CREATE, resources, user, request.getProjectId());
|
commonNoticeSendService.sendNotice(NoticeConstants.TaskType.FUNCTIONAL_CASE_TASK, NoticeConstants.Event.CREATE, resources, user, request.getProjectId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1158,7 +1158,7 @@ public class FunctionalCaseService {
|
||||||
|
|
||||||
List<Map> resources = new ArrayList<>();
|
List<Map> resources = new ArrayList<>();
|
||||||
resources.addAll(JSON.parseArray(JSON.toJSONString(noticeList), Map.class));
|
resources.addAll(JSON.parseArray(JSON.toJSONString(noticeList), Map.class));
|
||||||
afterReturningNoticeSendService.sendNotice(NoticeConstants.TaskType.FUNCTIONAL_CASE_TASK, NoticeConstants.Event.UPDATE, resources, user, request.getProjectId());
|
commonNoticeSendService.sendNotice(NoticeConstants.TaskType.FUNCTIONAL_CASE_TASK, NoticeConstants.Event.UPDATE, resources, user, request.getProjectId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import io.metersphere.sdk.util.JSON;
|
||||||
import io.metersphere.sdk.util.LogUtils;
|
import io.metersphere.sdk.util.LogUtils;
|
||||||
import io.metersphere.system.dto.sdk.SessionUser;
|
import io.metersphere.system.dto.sdk.SessionUser;
|
||||||
import io.metersphere.system.notice.annotation.SendNotice;
|
import io.metersphere.system.notice.annotation.SendNotice;
|
||||||
|
import io.metersphere.system.service.CommonNoticeSendService;
|
||||||
import io.metersphere.system.utils.SessionUtils;
|
import io.metersphere.system.utils.SessionUtils;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.apache.commons.beanutils.BeanMap;
|
import org.apache.commons.beanutils.BeanMap;
|
||||||
|
@ -35,7 +36,7 @@ import java.util.Map;
|
||||||
@Component
|
@Component
|
||||||
public class SendNoticeAspect {
|
public class SendNoticeAspect {
|
||||||
@Resource
|
@Resource
|
||||||
private AfterReturningNoticeSendService afterReturningNoticeSendService;
|
private CommonNoticeSendService commonNoticeSendService;
|
||||||
|
|
||||||
private ExpressionParser parser = new SpelExpressionParser();
|
private ExpressionParser parser = new SpelExpressionParser();
|
||||||
private StandardReflectionParameterNameDiscoverer discoverer = new StandardReflectionParameterNameDiscoverer();
|
private StandardReflectionParameterNameDiscoverer discoverer = new StandardReflectionParameterNameDiscoverer();
|
||||||
|
@ -166,7 +167,7 @@ public class SendNoticeAspect {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
afterReturningNoticeSendService.sendNotice(taskType, event, resources, sessionUser, currentProjectId);
|
commonNoticeSendService.sendNotice(taskType, event, resources, sessionUser, currentProjectId);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogUtils.error(e.getMessage(), e);
|
LogUtils.error(e.getMessage(), e);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
package io.metersphere.system.notice.sender;
|
package io.metersphere.system.service;
|
||||||
|
|
||||||
|
|
||||||
|
import io.metersphere.system.domain.User;
|
||||||
import io.metersphere.system.dto.sdk.BaseSystemConfigDTO;
|
import io.metersphere.system.dto.sdk.BaseSystemConfigDTO;
|
||||||
import io.metersphere.system.dto.sdk.SessionUser;
|
|
||||||
import io.metersphere.system.notice.NoticeModel;
|
import io.metersphere.system.notice.NoticeModel;
|
||||||
import io.metersphere.system.notice.constants.NoticeConstants;
|
import io.metersphere.system.notice.constants.NoticeConstants;
|
||||||
import io.metersphere.system.notice.utils.MessageTemplateUtils;
|
import io.metersphere.system.notice.utils.MessageTemplateUtils;
|
||||||
import io.metersphere.system.service.NoticeSendService;
|
|
||||||
import io.metersphere.system.service.SystemParameterService;
|
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.context.i18n.LocaleContextHolder;
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
|
@ -17,22 +15,22 @@ import org.springframework.stereotype.Component;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class AfterReturningNoticeSendService {
|
public class CommonNoticeSendService {
|
||||||
@Resource
|
@Resource
|
||||||
private SystemParameterService systemParameterService;
|
private SystemParameterService systemParameterService;
|
||||||
@Resource
|
@Resource
|
||||||
private NoticeSendService noticeSendService;
|
private NoticeSendService noticeSendService;
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
public void sendNotice(String taskType, String event, List<Map> resources, SessionUser sessionUser, String currentProjectId) {
|
public void sendNotice(String taskType, String event, List<Map> resources, User operator, String currentProjectId) {
|
||||||
setLanguage(sessionUser.getLanguage());
|
setLanguage(operator.getLanguage());
|
||||||
// 有批量操作发送多次
|
// 有批量操作发送多次
|
||||||
BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo();
|
BaseSystemConfigDTO baseSystemConfigDTO = systemParameterService.getBaseInfo();
|
||||||
for (Map resource : resources) {
|
for (Map resource : resources) {
|
||||||
Map paramMap = new HashMap<>();
|
Map paramMap = new HashMap<>();
|
||||||
paramMap.put("url", baseSystemConfigDTO.getUrl());
|
paramMap.put("url", baseSystemConfigDTO.getUrl());
|
||||||
paramMap.put(NoticeConstants.RelatedUser.OPERATOR, sessionUser.getName());
|
paramMap.put(NoticeConstants.RelatedUser.OPERATOR, operator.getName());
|
||||||
paramMap.put("Language",sessionUser.getLanguage());
|
paramMap.put("Language", operator.getLanguage());
|
||||||
paramMap.putAll(resource);
|
paramMap.putAll(resource);
|
||||||
paramMap.putIfAbsent("projectId", currentProjectId);
|
paramMap.putIfAbsent("projectId", currentProjectId);
|
||||||
//TODO: 加来源处理
|
//TODO: 加来源处理
|
||||||
|
@ -47,7 +45,7 @@ public class AfterReturningNoticeSendService {
|
||||||
List<String> relatedUsers = getRelatedUsers(resource.get("relatedUsers"));
|
List<String> relatedUsers = getRelatedUsers(resource.get("relatedUsers"));
|
||||||
|
|
||||||
NoticeModel noticeModel = NoticeModel.builder()
|
NoticeModel noticeModel = NoticeModel.builder()
|
||||||
.operator(sessionUser.getId())
|
.operator(operator.getId())
|
||||||
.context(context)
|
.context(context)
|
||||||
.subject(subject)
|
.subject(subject)
|
||||||
.paramMap(paramMap)
|
.paramMap(paramMap)
|
||||||
|
@ -76,9 +74,9 @@ public class AfterReturningNoticeSendService {
|
||||||
|
|
||||||
private static void setLanguage(String language) {
|
private static void setLanguage(String language) {
|
||||||
Locale locale = Locale.SIMPLIFIED_CHINESE;
|
Locale locale = Locale.SIMPLIFIED_CHINESE;
|
||||||
if (StringUtils.containsIgnoreCase("US",language)) {
|
if (StringUtils.containsIgnoreCase("US", language)) {
|
||||||
locale = Locale.US;
|
locale = Locale.US;
|
||||||
} else if (StringUtils.containsIgnoreCase("TW",language)){
|
} else if (StringUtils.containsIgnoreCase("TW", language)) {
|
||||||
locale = Locale.TAIWAN;
|
locale = Locale.TAIWAN;
|
||||||
}
|
}
|
||||||
LocaleContextHolder.setLocale(locale);
|
LocaleContextHolder.setLocale(locale);
|
|
@ -24,7 +24,7 @@ import io.metersphere.system.dto.sdk.SessionUser;
|
||||||
import io.metersphere.system.dto.user.UserDTO;
|
import io.metersphere.system.dto.user.UserDTO;
|
||||||
import io.metersphere.system.mapper.CustomFieldMapper;
|
import io.metersphere.system.mapper.CustomFieldMapper;
|
||||||
import io.metersphere.system.notice.constants.NoticeConstants;
|
import io.metersphere.system.notice.constants.NoticeConstants;
|
||||||
import io.metersphere.system.notice.sender.AfterReturningNoticeSendService;
|
import io.metersphere.system.service.CommonNoticeSendService;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.junit.jupiter.api.MethodOrderer;
|
import org.junit.jupiter.api.MethodOrderer;
|
||||||
|
@ -44,11 +44,11 @@ import java.util.Map;
|
||||||
@SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT)
|
@SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||||
@AutoConfigureMockMvc
|
@AutoConfigureMockMvc
|
||||||
public class AfterReturningNoticeSendServiceTests extends BaseTest {
|
public class CommonNoticeSendServiceTests extends BaseTest {
|
||||||
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private AfterReturningNoticeSendService afterReturningNoticeSendService;
|
private CommonNoticeSendService commonNoticeSendService;
|
||||||
@Resource
|
@Resource
|
||||||
private FunctionalCaseMapper functionalCaseMapper;
|
private FunctionalCaseMapper functionalCaseMapper;
|
||||||
@Resource
|
@Resource
|
||||||
|
@ -117,7 +117,7 @@ public class AfterReturningNoticeSendServiceTests extends BaseTest {
|
||||||
SessionUser user = SessionUser.fromUser(userDTO, sessionId);
|
SessionUser user = SessionUser.fromUser(userDTO, sessionId);
|
||||||
user.setLanguage("zh-CN");
|
user.setLanguage("zh-CN");
|
||||||
for (String event : eventList) {
|
for (String event : eventList) {
|
||||||
afterReturningNoticeSendService.sendNotice(functionalCaseTask, event,resources, user, "100001100001");
|
commonNoticeSendService.sendNotice(functionalCaseTask, event,resources, user, "100001100001");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,7 @@ public class AfterReturningNoticeSendServiceTests extends BaseTest {
|
||||||
SessionUser user = SessionUser.fromUser(userDTO, sessionId);
|
SessionUser user = SessionUser.fromUser(userDTO, sessionId);
|
||||||
|
|
||||||
for (String event : eventList) {
|
for (String event : eventList) {
|
||||||
afterReturningNoticeSendService.sendNotice(apiDefinitionTask, event,resources, user, "100001100001");
|
commonNoticeSendService.sendNotice(apiDefinitionTask, event,resources, user, "100001100001");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,7 @@ public class AfterReturningNoticeSendServiceTests extends BaseTest {
|
||||||
SessionUser user = SessionUser.fromUser(userDTO, sessionId);
|
SessionUser user = SessionUser.fromUser(userDTO, sessionId);
|
||||||
|
|
||||||
for (String event : eventList) {
|
for (String event : eventList) {
|
||||||
afterReturningNoticeSendService.sendNotice(apiScenarioTask, event,resources, user, "100001100001");
|
commonNoticeSendService.sendNotice(apiScenarioTask, event,resources, user, "100001100001");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -234,7 +234,7 @@ public class AfterReturningNoticeSendServiceTests extends BaseTest {
|
||||||
SessionUser user = SessionUser.fromUser(userDTO, sessionId);
|
SessionUser user = SessionUser.fromUser(userDTO, sessionId);
|
||||||
|
|
||||||
for (String event : eventList) {
|
for (String event : eventList) {
|
||||||
afterReturningNoticeSendService.sendNotice(testPlanTask, event,resources, user, "100001100001");
|
commonNoticeSendService.sendNotice(testPlanTask, event,resources, user, "100001100001");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -273,7 +273,7 @@ public class AfterReturningNoticeSendServiceTests extends BaseTest {
|
||||||
SessionUser user = SessionUser.fromUser(userDTO, sessionId);
|
SessionUser user = SessionUser.fromUser(userDTO, sessionId);
|
||||||
|
|
||||||
for (String event : eventList) {
|
for (String event : eventList) {
|
||||||
afterReturningNoticeSendService.sendNotice(caseReviewTask, event,resources, user, "100001100001");
|
commonNoticeSendService.sendNotice(caseReviewTask, event,resources, user, "100001100001");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -325,7 +325,7 @@ public class AfterReturningNoticeSendServiceTests extends BaseTest {
|
||||||
SessionUser user = SessionUser.fromUser(userDTO, sessionId);
|
SessionUser user = SessionUser.fromUser(userDTO, sessionId);
|
||||||
|
|
||||||
for (String event : eventList) {
|
for (String event : eventList) {
|
||||||
afterReturningNoticeSendService.sendNotice(loadTestTask, event,resources, user, "100001100001");
|
commonNoticeSendService.sendNotice(loadTestTask, event,resources, user, "100001100001");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue