通知公告模块使用websocket推送消息

This commit is contained in:
dataprince 2024-01-17 20:24:48 +08:00
parent 74853f4d9c
commit b06857e8c8
2 changed files with 11 additions and 0 deletions

View File

@ -85,6 +85,11 @@
<artifactId>ruoyi-common-web</artifactId>
</dependency>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-websocket</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>

View File

@ -3,10 +3,12 @@ package com.ruoyi.system.controller.system;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.core.core.domain.R;
import com.ruoyi.common.core.service.DictService;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.orm.core.page.TableDataInfo;
import com.ruoyi.common.web.annotation.RepeatSubmit;
import com.ruoyi.common.websocket.utils.WebSocketUtils;
import com.ruoyi.system.domain.bo.SysNoticeBo;
import com.ruoyi.system.domain.vo.SysNoticeVo;
import jakarta.annotation.Resource;
@ -36,6 +38,8 @@ public class SysNoticeController extends BaseController
{
@Resource
private ISysNoticeService noticeService;
@Resource
private DictService dictService;
/**
* 获取通知公告列表
@ -70,6 +74,8 @@ public class SysNoticeController extends BaseController
if (!inserted) {
return R.fail("新增通知公告记录失败!");
}
String type = dictService.getDictLabel("sys_notice_type", noticeBo.getNoticeType());
WebSocketUtils.publishAll("[" + type + "] " + noticeBo.getNoticeTitle());
return R.ok();
}