diff --git a/kernel-s-message/message-business/src/main/java/cn/stylefeng/roses/kernel/message/modular/manage/controller/SysMessageController.java b/kernel-s-message/message-business/src/main/java/cn/stylefeng/roses/kernel/message/modular/manage/controller/SysMessageController.java index f3cc5156a..35cc2b6a6 100644 --- a/kernel-s-message/message-business/src/main/java/cn/stylefeng/roses/kernel/message/modular/manage/controller/SysMessageController.java +++ b/kernel-s-message/message-business/src/main/java/cn/stylefeng/roses/kernel/message/modular/manage/controller/SysMessageController.java @@ -10,11 +10,11 @@ import cn.stylefeng.roses.kernel.resource.api.annotation.GetResource; import cn.stylefeng.roses.kernel.resource.api.annotation.PostResource; import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData; import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; +import javax.annotation.Resource; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -33,7 +33,7 @@ public class SysMessageController { /** * 系统消息api */ - @Autowired + @Resource private MessageApi messageApi; /** @@ -86,7 +86,6 @@ public class SysMessageController { return new SuccessResponseData(); } - /** * 查看系统消息 * @@ -98,7 +97,6 @@ public class SysMessageController { return new SuccessResponseData(messageApi.messageDetail(messageRequest)); } - /** * 分页查询系统消息列表 * @@ -121,7 +119,6 @@ public class SysMessageController { return new SuccessResponseData(messageApi.queryListCurrentUser(messageRequest)); } - /** * 系统消息未读数量 * diff --git a/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/service/SysMessageService.java b/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/service/SysMessageService.java index 388913bbd..43be476bd 100644 --- a/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/service/SysMessageService.java +++ b/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/service/SysMessageService.java @@ -77,4 +77,5 @@ public interface SysMessageService extends IService { * @date 2021/1/11 19:21 */ Integer findCount(MessageRequest messageRequest); + } diff --git a/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/service/impl/SysMessageServiceImpl.java b/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/service/impl/SysMessageServiceImpl.java index 5bb99a5f5..4993cc0ac 100644 --- a/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/service/impl/SysMessageServiceImpl.java +++ b/kernel-s-message/message-sdk-db/src/main/java/cn/stylefeng/roses/kernel/message/db/service/impl/SysMessageServiceImpl.java @@ -98,6 +98,16 @@ public class SysMessageServiceImpl extends ServiceImpl createWrapper(MessageRequest messageRequest) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + // 查询未删除的 + queryWrapper.ne(SysMessage::getDelFlag, YesOrNotEnum.Y.getCode()); + + // 按发送事件倒序 + queryWrapper.orderByDesc(SysMessage::getMessageSendTime); + + if (ObjectUtil.isEmpty(messageRequest)) { + return queryWrapper; + } + // 消息标题 String messageTitle = messageRequest.getMessageTitle(); @@ -116,12 +126,6 @@ public class SysMessageServiceImpl extends ServiceImpl> userIdSessionMap = new ConcurrentHashMap<>(); /** @@ -97,4 +101,5 @@ public class WebSocketManager { sendMessage(userId, message); } } + } diff --git a/kernel-s-message/message-sdk-websocket/src/main/java/cn/stylefeng/roses/kernel/message/websocket/server/WebSocketEndpoint.java b/kernel-s-message/message-sdk-websocket/src/main/java/cn/stylefeng/roses/kernel/message/websocket/server/WebSocketEndpoint.java index ee0a51551..c45879c72 100644 --- a/kernel-s-message/message-sdk-websocket/src/main/java/cn/stylefeng/roses/kernel/message/websocket/server/WebSocketEndpoint.java +++ b/kernel-s-message/message-sdk-websocket/src/main/java/cn/stylefeng/roses/kernel/message/websocket/server/WebSocketEndpoint.java @@ -19,7 +19,6 @@ import javax.websocket.server.ServerEndpoint; @ServerEndpoint("/message/websocket/{userId}") public class WebSocketEndpoint { - /** * 连接建立成功后调用 * @@ -30,10 +29,12 @@ public class WebSocketEndpoint { */ @OnOpen public void onOpen(@PathParam(value = "userId") Long userId, Session session) { + // 添加到链接管理 WebSocketManager.add(userId, session); + // 返回消息 -// session.getAsyncRemote().sendText("WebSocket连接成功"); + session.getAsyncRemote().sendText("WebSocket连接成功"); } /** @@ -77,4 +78,4 @@ public class WebSocketEndpoint { } } -} \ No newline at end of file +} diff --git a/kernel-s-message/message-spring-boot-starter/pom.xml b/kernel-s-message/message-spring-boot-starter/pom.xml index 10492a132..1f31d33c2 100644 --- a/kernel-s-message/message-spring-boot-starter/pom.xml +++ b/kernel-s-message/message-spring-boot-starter/pom.xml @@ -24,7 +24,6 @@ 7.0.0 - cn.stylefeng.roses @@ -32,7 +31,6 @@ 7.0.0 - cn.stylefeng.roses