Переглянути джерело

个人中心我的私信消息提示

fangqing 5 місяців тому
батько
коміт
2ccd0e14b7

+ 20 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/controller/CommunityChatMsgController.java

@@ -130,6 +130,26 @@ public class CommunityChatMsgController extends BaseController {
         return AjaxResult.success(sysUserChatVos);
     }
 
+    /**
+     * 我的私信是否有未读
+     */
+    @ApiOperation("我的私信消息提示")
+    @GetMapping("/messageAlert")
+    public AjaxResult messageAlert(String type) {
+        Long userId = SecurityUtils.getUserId();
+        List<SysUserVo> sysUserChatVos = null;
+        boolean hasUnreadMessages = false;
+        try {
+            sysUserChatVos = communityChatMsgService.getChatListWithLatestMessage(userId, type);
+            // 判断是否有未读消息
+            hasUnreadMessages = sysUserChatVos.stream()
+                    .anyMatch(vo -> Objects.equals(vo.getReceiverId(), userId) && !vo.isReceiverIsRead());
+        } catch (Exception e) {
+            throw new ProjectException();
+        }
+        return AjaxResult.success(hasUnreadMessages);
+    }
+
     /**
      * 清空聊天记录
      */