fix: 修复消息通知websocket的连接问题
This commit is contained in:
@@ -104,7 +104,7 @@ public class WebSocketServer {
|
|||||||
/**
|
/**
|
||||||
* 群发自定义消息
|
* 群发自定义消息
|
||||||
* */
|
* */
|
||||||
public static void sendInfo(SocketMsg socketMsg,@PathParam("sid") String sid) throws IOException {
|
public static void sendInfo(SocketMsg socketMsg, @PathParam("sid") String sid) throws IOException {
|
||||||
String message = JSONObject.toJSONString(socketMsg);
|
String message = JSONObject.toJSONString(socketMsg);
|
||||||
log.info("推送消息到"+sid+",推送内容:"+message);
|
log.info("推送消息到"+sid+",推送内容:"+message);
|
||||||
for (WebSocketServer item : webSocketSet) {
|
for (WebSocketServer item : webSocketSet) {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import cn.dev33.satoken.stp.StpLogic;
|
|||||||
import cn.dev33.satoken.stp.StpUtil;
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
@@ -17,12 +18,12 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|||||||
* @Date: 2022-09-20
|
* @Date: 2022-09-20
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RequiredArgsConstructor
|
|
||||||
@Configuration
|
@Configuration
|
||||||
public class SaTokenConfigure implements WebMvcConfigurer {
|
public class SaTokenConfigure implements WebMvcConfigurer {
|
||||||
|
|
||||||
// 白名单
|
// 白名单
|
||||||
private final SecurityProperties securityProperties;
|
@Autowired
|
||||||
|
private SecurityProperties securityProperties;
|
||||||
|
|
||||||
// Sa-Token 整合 jwt (Simple 简单模式)
|
// Sa-Token 整合 jwt (Simple 简单模式)
|
||||||
@Bean
|
@Bean
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import org.springframework.web.socket.server.standard.ServerEndpointExporter;
|
|||||||
* @author ZhangHouYing
|
* @author ZhangHouYing
|
||||||
* @date 2019-08-24 15:44
|
* @date 2019-08-24 15:44
|
||||||
*/
|
*/
|
||||||
//@Configuration
|
@Configuration
|
||||||
public class WebSocketConfig {
|
public class WebSocketConfig {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package org.nl.system.service.menu.dao;
|
package org.nl.system.service.menu.dao;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
@@ -117,6 +118,7 @@ public class SysMenu implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 创建时间
|
* 创建时间
|
||||||
*/
|
*/
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
private Date create_time;
|
private Date create_time;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -132,6 +134,7 @@ public class SysMenu implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 修改时间
|
* 修改时间
|
||||||
*/
|
*/
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
private Date update_time;
|
private Date update_time;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.nl.common.domain.query.PageQuery;
|
import org.nl.common.domain.query.PageQuery;
|
||||||
import org.nl.common.enums.NoticeEnum;
|
import org.nl.common.enums.NoticeEnum;
|
||||||
@@ -26,6 +27,7 @@ import org.nl.system.service.notice.dao.SysNotice;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -48,7 +50,7 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
|
|||||||
@Autowired
|
@Autowired
|
||||||
private SysDictMapper dictMapper;
|
private SysDictMapper dictMapper;
|
||||||
|
|
||||||
@Autowired
|
@Resource
|
||||||
private WebSocketServer webSocketServer;
|
private WebSocketServer webSocketServer;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -153,6 +155,7 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createNotice(String msg, String title, String type) {
|
public void createNotice(String msg, String title, String type) {
|
||||||
|
log.info("创建消息通知:信息-{}, 标题-{}, 类型-{}", msg, title, type);
|
||||||
// 获取标题相同的信息
|
// 获取标题相同的信息
|
||||||
List<SysNotice> sysNotices = sysNoticeMapper.selectList(new LambdaQueryWrapper<SysNotice>().eq(SysNotice::getNotice_title, title));
|
List<SysNotice> sysNotices = sysNoticeMapper.selectList(new LambdaQueryWrapper<SysNotice>().eq(SysNotice::getNotice_title, title));
|
||||||
if (ObjectUtil.isNotEmpty(sysNotices)) return;
|
if (ObjectUtil.isNotEmpty(sysNotices)) return;
|
||||||
|
|||||||
@@ -75,7 +75,6 @@ security:
|
|||||||
# actuator 监控配置
|
# actuator 监控配置
|
||||||
- /actuator
|
- /actuator
|
||||||
- /actuator/**
|
- /actuator/**
|
||||||
- /**
|
|
||||||
# 上传
|
# 上传
|
||||||
- /api/localStorage/pictures
|
- /api/localStorage/pictures
|
||||||
# 参数
|
# 参数
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ window.g = {
|
|||||||
},
|
},
|
||||||
prod: {
|
prod: {
|
||||||
VUE_APP_BASE_API: 'http://127.0.0.1:8010'
|
VUE_APP_BASE_API: 'http://127.0.0.1:8010'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,6 +76,9 @@ export default {
|
|||||||
Doc,
|
Doc,
|
||||||
TopNav
|
TopNav
|
||||||
},
|
},
|
||||||
|
created() {
|
||||||
|
this.initWebSocket()
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
Avatar: Avatar,
|
Avatar: Avatar,
|
||||||
@@ -106,9 +109,6 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
|
||||||
this.initWebSocket()
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
toggleSideBar() {
|
toggleSideBar() {
|
||||||
this.$store.dispatch('app/toggleSideBar')
|
this.$store.dispatch('app/toggleSideBar')
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<div style="margin: 5px" v-loading="loading">
|
<div style="margin: 5px" v-loading="loading">
|
||||||
<el-tabs v-model="activeName" @tab-click="handleClick">
|
<el-tabs v-model="activeName" @tab-click="handleClick">
|
||||||
<el-tab-pane :label="d.label" :name="d.value" v-for="d in dict.notice_type" :key="d.id">
|
<el-tab-pane :label="d.label" :name="d.value" v-for="d in dict.notice_type" :key="d.id">
|
||||||
<el-empty v-show="notReadMsgList[d.value-1].length == 0" description="暂无信息" ></el-empty>
|
<el-empty v-if="notReadMsgList && notReadMsgList[d.value-1] && notReadMsgList[d.value-1].length === 0" description="暂无信息" ></el-empty>
|
||||||
<div v-for="o in notReadMsgList[d.value-1]" :key="o.notice_id">
|
<div v-for="o in notReadMsgList[d.value-1]" :key="o.notice_id">
|
||||||
<a href="javascript:" @click="showMessage(o)">
|
<a href="javascript:" @click="showMessage(o)">
|
||||||
<el-row @click="showMessage">
|
<el-row @click="showMessage">
|
||||||
@@ -52,6 +52,9 @@ export default {
|
|||||||
notReadMsgList: []
|
notReadMsgList: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
beforeMount() {
|
||||||
|
this.getMessage()
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
/**
|
/**
|
||||||
* 打开列表页
|
* 打开列表页
|
||||||
|
|||||||
Reference in New Issue
Block a user