mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-03-29 08:43:24 +08:00
update 重构 common-sse 与 common-websocket 合并为 ruoyi-common-push 推送模块
This commit is contained in:
@@ -85,7 +85,7 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-websocket</artifactId>
|
||||
<artifactId>ruoyi-common-push</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
package org.dromara.demo.controller;
|
||||
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.websocket.dto.WebSocketMessageDTO;
|
||||
import org.dromara.common.websocket.utils.WebSocketUtils;
|
||||
import org.dromara.common.core.domain.dto.PushPayload;
|
||||
import org.dromara.common.core.enums.PushSourceEnum;
|
||||
import org.dromara.common.core.enums.PushTypeEnum;
|
||||
import org.dromara.common.push.helper.PushHelper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* WebSocket 演示案例
|
||||
*
|
||||
@@ -23,11 +27,22 @@ public class WebSocketController {
|
||||
/**
|
||||
* 发布消息
|
||||
*
|
||||
* @param dto 发送内容
|
||||
* @param userId 目标用户
|
||||
* @param message 发送内容
|
||||
*/
|
||||
@GetMapping("/send")
|
||||
public R<Void> send(WebSocketMessageDTO dto) throws InterruptedException {
|
||||
WebSocketUtils.publishMessage(dto);
|
||||
public R<Void> send(Long userId, String message) {
|
||||
PushPayload payload = PushPayload.of(
|
||||
PushTypeEnum.MESSAGE,
|
||||
PushSourceEnum.BACKEND,
|
||||
message,
|
||||
null
|
||||
);
|
||||
if (userId == null) {
|
||||
PushHelper.publishAll(payload);
|
||||
} else {
|
||||
PushHelper.publishMessage(List.of(userId), payload);
|
||||
}
|
||||
return R.ok("操作成功");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,12 +82,7 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-websocket</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-sse</artifactId>
|
||||
<artifactId>ruoyi-common-push</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
@@ -4,15 +4,15 @@ import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.PageResult;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.domain.dto.PushPayload;
|
||||
import org.dromara.common.core.enums.PushSourceEnum;
|
||||
import org.dromara.common.core.enums.PushTypeEnum;
|
||||
import org.dromara.common.core.service.DictService;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.push.helper.PushHelper;
|
||||
import org.dromara.common.redis.annotation.RepeatSubmit;
|
||||
import org.dromara.common.sse.dto.SseMessageDTO;
|
||||
import org.dromara.common.sse.utils.SseMessageUtils;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.system.domain.bo.SysNoticeBo;
|
||||
import org.dromara.system.domain.vo.SysNoticeVo;
|
||||
@@ -82,13 +82,14 @@ public class SysNoticeController extends BaseController {
|
||||
data.put("noticeType", notice.getNoticeType());
|
||||
data.put("noticeTypeLabel", type);
|
||||
data.put("noticeTitle", notice.getNoticeTitle());
|
||||
SseMessageDTO dto = new SseMessageDTO();
|
||||
dto.setMessage("[" + type + "] " + notice.getNoticeTitle());
|
||||
dto.setMessageType(PushTypeEnum.NOTICE.getType());
|
||||
dto.setMessageSource(PushSourceEnum.NOTICE.getSource());
|
||||
dto.setData(data);
|
||||
dto.setPath("/system/notice");
|
||||
SseMessageUtils.publishMessage(dto);
|
||||
PushHelper.publishAll(PushPayload.of(
|
||||
PushTypeEnum.NOTICE,
|
||||
PushSourceEnum.NOTICE,
|
||||
"[" + type + "] " + notice.getNoticeTitle(),
|
||||
data,
|
||||
"/system/notice",
|
||||
null
|
||||
));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>org.dromara</groupId>
|
||||
<artifactId>ruoyi-common-sse</artifactId>
|
||||
<artifactId>ruoyi-common-push</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.domain.dto.PushPayload;
|
||||
import org.dromara.common.core.domain.dto.UserDTO;
|
||||
import org.dromara.common.core.enums.PushSourceEnum;
|
||||
import org.dromara.common.core.enums.PushTypeEnum;
|
||||
@@ -12,8 +13,7 @@ import org.dromara.common.core.utils.SpringUtils;
|
||||
import org.dromara.common.core.utils.StreamUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mail.utils.MailUtils;
|
||||
import org.dromara.common.sse.dto.SseMessageDTO;
|
||||
import org.dromara.common.sse.utils.SseMessageUtils;
|
||||
import org.dromara.common.push.helper.PushHelper;
|
||||
import org.dromara.warm.flow.core.FlowEngine;
|
||||
import org.dromara.warm.flow.core.entity.Node;
|
||||
import org.dromara.warm.flow.orm.entity.FlowTask;
|
||||
@@ -94,12 +94,12 @@ public class FlwCommonServiceImpl implements IFlwCommonService {
|
||||
try {
|
||||
switch (messageTypeEnum) {
|
||||
case SYSTEM_MESSAGE -> {
|
||||
SseMessageDTO dto = new SseMessageDTO();
|
||||
dto.setUserIds(userIds);
|
||||
dto.setMessage(message);
|
||||
dto.setMessageType(PushTypeEnum.MESSAGE.getType());
|
||||
dto.setMessageSource(PushSourceEnum.WORKFLOW.getSource());
|
||||
SseMessageUtils.publishMessage(dto);
|
||||
PushHelper.publishMessage(userIds, PushPayload.of(
|
||||
PushTypeEnum.MESSAGE,
|
||||
PushSourceEnum.WORKFLOW,
|
||||
message,
|
||||
null
|
||||
));
|
||||
}
|
||||
case EMAIL_MESSAGE -> MailUtils.sendText(emails, subject, message);
|
||||
case SMS_MESSAGE -> {
|
||||
|
||||
Reference in New Issue
Block a user