update 重构 common-sse 与 common-websocket 合并为 ruoyi-common-push 推送模块

This commit is contained in:
疯狂的狮子Li
2026-03-26 17:25:36 +08:00
parent 40011e9acd
commit 029f6a4c11
45 changed files with 775 additions and 1132 deletions

View File

@@ -12,9 +12,12 @@ import me.zhyd.oauth.request.AuthRequest;
import me.zhyd.oauth.utils.AuthStateUtils;
import org.dromara.common.core.constant.SystemConstants;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.domain.dto.PushPayload;
import org.dromara.common.core.domain.model.LoginBody;
import org.dromara.common.core.domain.model.RegisterBody;
import org.dromara.common.core.domain.model.SocialLoginBody;
import org.dromara.common.core.enums.PushSourceEnum;
import org.dromara.common.core.enums.PushTypeEnum;
import org.dromara.common.core.utils.DateUtils;
import org.dromara.common.core.utils.MessageUtils;
import org.dromara.common.core.utils.StringUtils;
@@ -23,12 +26,11 @@ import org.dromara.common.encrypt.annotation.ApiEncrypt;
import org.dromara.common.json.utils.JsonUtils;
import org.dromara.common.redis.annotation.RateLimiter;
import org.dromara.common.redis.enums.LimitType;
import org.dromara.common.push.helper.PushHelper;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.common.social.config.properties.SocialLoginConfigProperties;
import org.dromara.common.social.config.properties.SocialProperties;
import org.dromara.common.social.utils.SocialUtils;
import org.dromara.common.sse.dto.SseMessageDTO;
import org.dromara.common.sse.utils.SseMessageUtils;
import org.dromara.system.domain.vo.SysClientVo;
import org.dromara.system.service.ISysClientService;
import org.dromara.system.service.ISysConfigService;
@@ -93,10 +95,15 @@ public class AuthController {
Long userId = LoginHelper.getUserId();
scheduledExecutorService.schedule(() -> {
SseMessageDTO dto = new SseMessageDTO();
dto.setUserIds(List.of(userId));
dto.setMessage(DateUtils.getTodayHour(new Date()) + "好,欢迎登录 RuoYi-Vue-Plus 后台管理系统");
SseMessageUtils.publishMessage(dto);
PushHelper.publishMessage(
List.of(userId),
PushPayload.of(
PushTypeEnum.MESSAGE,
PushSourceEnum.BACKEND,
DateUtils.getTodayHour(new Date()) + "好,欢迎登录 RuoYi-Vue-Plus 后台管理系统",
null
)
);
}, 5, TimeUnit.SECONDS);
return R.ok(loginVo);
}

View File

@@ -213,18 +213,14 @@ management:
logfile:
external-file: ./logs/sys-console.log
--- # 默认/推荐使用sse推送
sse:
--- # 统一消息推送配置
message:
enabled: true
path: /resource/sse
--- # websocket
websocket:
# 如果关闭 需要和前端开关一起关闭
enabled: false
# 路径
path: /resource/websocket
# 设置访问源地址
# sse / websocket
transport: sse
# 统一访问路径
path: /resource/message
# websocket 允许的跨域来源
allowedOrigins: '*'
--- # warm-flow工作流配置