mirror of
https://gitee.com/dromara/RuoYi-Cloud-Plus.git
synced 2026-05-12 14:52:07 +08:00
update 重构 common-sse 与 common-websocket 合并为 ruoyi-common-push 推送模块
update 优化 通知公告页面增加查看详情功能 支持预览已经编辑好的富文本内容 update 优化 消息盒子相关消息可直接跳转到详情页展示富文本内容 update 完成消息盒子功能前后端联动(已读未读在前端浏览器存储) update 工作流消息推送增加前端路由跳转
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package org.dromara.resource.api;
|
||||
|
||||
import org.dromara.resource.api.domain.dto.RemotePushPayLoad;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -17,10 +19,26 @@ public interface RemoteMessageService {
|
||||
*/
|
||||
void publishMessage(List<Long> sessionKey, String message);
|
||||
|
||||
/**
|
||||
* 发布指定用户的结构化消息
|
||||
*
|
||||
* @param userIds 用户ID列表
|
||||
* @param payload 推送体
|
||||
*/
|
||||
void publishMessagePayload(List<Long> userIds, RemotePushPayLoad payload);
|
||||
|
||||
/**
|
||||
* 发布订阅的消息(群发)
|
||||
*
|
||||
* @param message 消息内容
|
||||
*/
|
||||
void publishAll(String message);
|
||||
|
||||
/**
|
||||
* 发布广播结构化消息
|
||||
*
|
||||
* @param payload 推送体
|
||||
*/
|
||||
void publishAllPayload(RemotePushPayLoad payload);
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.dromara.resource.api;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.resource.api.domain.dto.RemotePushPayLoad;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -31,6 +32,15 @@ public class RemoteMessageServiceStub implements RemoteMessageService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void publishMessagePayload(List<Long> userIds, RemotePushPayLoad payload) {
|
||||
try {
|
||||
remoteMessageService.publishMessagePayload(userIds, payload);
|
||||
} catch (Exception e) {
|
||||
log.warn("推送功能未开启或服务未找到");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发布订阅的消息(群发)
|
||||
*
|
||||
@@ -44,4 +54,14 @@ public class RemoteMessageServiceStub implements RemoteMessageService {
|
||||
log.warn("推送功能未开启或服务未找到");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void publishAllPayload(RemotePushPayLoad payload) {
|
||||
try {
|
||||
remoteMessageService.publishAllPayload(payload);
|
||||
} catch (Exception e) {
|
||||
log.warn("推送功能未开启或服务未找到");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package org.dromara.resource.api.domain.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.enums.PushSourceEnum;
|
||||
import org.dromara.common.core.enums.PushTypeEnum;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 远程推送消息体
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Data
|
||||
public class RemotePushPayLoad implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long messageId;
|
||||
|
||||
private String type;
|
||||
|
||||
private String source;
|
||||
|
||||
private String message;
|
||||
|
||||
private Object data;
|
||||
|
||||
private String path;
|
||||
|
||||
private Long timestamp;
|
||||
|
||||
public static RemotePushPayLoad of(String type, String source, String message, Object data) {
|
||||
RemotePushPayLoad payload = new RemotePushPayLoad();
|
||||
payload.setType(StringUtils.defaultIfBlank(type, PushTypeEnum.MESSAGE.getType()));
|
||||
payload.setSource(StringUtils.defaultIfBlank(source, PushSourceEnum.BACKEND.getSource()));
|
||||
payload.setMessage(message);
|
||||
payload.setData(data);
|
||||
payload.setTimestamp(System.currentTimeMillis());
|
||||
return payload;
|
||||
}
|
||||
|
||||
public static RemotePushPayLoad of(PushTypeEnum type, PushSourceEnum source, String message, Object data) {
|
||||
return of(
|
||||
type == null ? null : type.getType(),
|
||||
source == null ? null : source.getSource(),
|
||||
message,
|
||||
data
|
||||
);
|
||||
}
|
||||
|
||||
public static RemotePushPayLoad of(PushTypeEnum type, PushSourceEnum source, String message, Object data, String path) {
|
||||
RemotePushPayLoad payload = of(type, source, message, data);
|
||||
payload.setPath(path);
|
||||
return payload;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user