refactor(消息管理): 增加返回的机器人类型

This commit is contained in:
guoyuqi 2023-10-09 14:33:51 +08:00 committed by f2c-ci-robot[bot]
parent 6831220033
commit 094986e8e1
2 changed files with 13 additions and 9 deletions

View File

@ -22,6 +22,9 @@ public class ProjectRobotConfigDTO implements Serializable {
@Schema(description = "所属平台(飞书:LARK钉钉:DING_TALK企业微信:WE_COM自定义:CUSTOM, 站内信:IN_SITE, 邮件:MAIL")
private String platform;
@Schema(description = "钉钉机器人的种类: 自定义:CUSTOM, 企业内部:ENTERPRISE")
private String dingType;
@Schema(description = "消息配置机器人是否开启")
public Boolean enable;

View File

@ -64,7 +64,6 @@ public class NoticeMessageTaskService {
private ExtProjectUserRoleMapper extProjectUserRoleMapper;
public static final String USER_IDS = "user_ids";
public static final String NO_USER_NAMES = "no_user_names";
@ -340,12 +339,12 @@ public class NoticeMessageTaskService {
messageTaskDetailDTO.setEventName(eventMap.get(messageTaskDetailDTO.getEvent()));
List<MessageTask> messageTaskList = messageEventMap.get(messageTaskDetailDTO.getEvent());
List<OptionDTO> receivers = new ArrayList<>();
Map<String,ProjectRobotConfigDTO> projectRobotConfigMap = new HashMap<>();
Map<String, ProjectRobotConfigDTO> projectRobotConfigMap = new HashMap<>();
String defaultTemplate = defaultTemplateMap.get(messageTaskTypeDTO.taskType + "_" + messageTaskDetailDTO.getEvent());
if (CollectionUtils.isEmpty(messageTaskList)) {
String defaultSubject = defaultTemplateTitleMap.get(messageTaskTypeDTO.taskType + "_" + messageTaskDetailDTO.getEvent());
ProjectRobotConfigDTO projectRobotConfigDTO = getDefaultProjectRobotConfigDTO(defaultTemplate, defaultSubject, projectRobot);
projectRobotConfigMap.put(projectRobot.getId(),projectRobotConfigDTO);
projectRobotConfigMap.put(projectRobot.getId(), projectRobotConfigDTO);
} else {
for (MessageTask messageTask : messageTaskList) {
MessageTaskBlob messageTaskBlob = messageTaskBlobMap.get(messageTask.getId());
@ -360,8 +359,8 @@ public class NoticeMessageTaskService {
} else {
defaultSubject = defaultTemplateTitleMap.get(messageTaskTypeDTO.taskType + "_" + messageTaskDetailDTO.getEvent());
}
ProjectRobotConfigDTO projectRobotConfigDTO = getProjectRobotConfigDTO(defaultTemplate, defaultSubject, platform, messageTask, messageTaskBlob);
projectRobotConfigMap.put(messageTask.getProjectRobotId(),projectRobotConfigDTO);
ProjectRobotConfigDTO projectRobotConfigDTO = getProjectRobotConfigDTO(defaultTemplate, defaultSubject, robotMap, messageTask, messageTaskBlob);
projectRobotConfigMap.put(messageTask.getProjectRobotId(), projectRobotConfigDTO);
}
}
List<OptionDTO> distinctReceivers = receivers.stream().distinct().toList();
@ -373,12 +372,13 @@ public class NoticeMessageTaskService {
return messageTaskDTOList;
}
private ProjectRobotConfigDTO getProjectRobotConfigDTO(String defaultTemplate, String defaultSubject, String robotPlatForm, MessageTask messageTask, MessageTaskBlob messageTaskBlob) {
private ProjectRobotConfigDTO getProjectRobotConfigDTO(String defaultTemplate, String defaultSubject, Map<String, ProjectRobot> robotMap, MessageTask messageTask, MessageTaskBlob messageTaskBlob) {
ProjectRobotConfigDTO projectRobotConfigDTO = new ProjectRobotConfigDTO();
ProjectRobot projectRobot = projectRobotMapper.selectByPrimaryKey(messageTask.getProjectRobotId());
ProjectRobot projectRobot = robotMap.get(messageTask.getProjectRobotId());
projectRobotConfigDTO.setRobotName(projectRobot.getName());
projectRobotConfigDTO.setRobotId(messageTask.getProjectRobotId());
projectRobotConfigDTO.setPlatform(robotPlatForm);
projectRobotConfigDTO.setPlatform(projectRobot.getPlatform());
projectRobotConfigDTO.setDingType(projectRobot.getType());
projectRobotConfigDTO.setEnable(messageTask.getEnable());
projectRobotConfigDTO.setTemplate(messageTaskBlob.getTemplate());
projectRobotConfigDTO.setDefaultTemplate(defaultTemplate);
@ -394,6 +394,7 @@ public class NoticeMessageTaskService {
projectRobotConfigDTO.setRobotId(projectRobot.getId());
projectRobotConfigDTO.setRobotName(projectRobot.getName());
projectRobotConfigDTO.setPlatform(ProjectRobotPlatform.IN_SITE.toString());
projectRobotConfigDTO.setDingType(projectRobot.getType());
projectRobotConfigDTO.setEnable(false);
projectRobotConfigDTO.setTemplate("");
projectRobotConfigDTO.setDefaultTemplate(defaultTemplate);
@ -405,6 +406,6 @@ public class NoticeMessageTaskService {
}
public List<OptionDTO> getUserList(String projectId, String keyword) {
return extProjectUserRoleMapper.getProjectUserSelectList(projectId, keyword);
return extProjectUserRoleMapper.getProjectUserSelectList(projectId, keyword);
}
}