Explorar o código

APP端 消息 各类消息显示各自角标

zhulu hai 1 ano
pai
achega
36a1eb483e

+ 1 - 1
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/information/mapper/CoreMessageCenterMapper.java

@@ -18,7 +18,7 @@ import java.util.List;
 public interface CoreMessageCenterMapper extends BaseMapper<CoreMessageCenter> {
 
     Page<CoreMessageCenterVO> selectByPage(Page<CoreMessageCenter> page, @Param("request") CoreMessageCenterDTO request);
-    Integer selectNoRead(Long userId);
+    Integer selectNoRead(@Param("userId") Long userId, @Param("messageType") Integer messageType);
     /**
      * 查询消息中心
      *

+ 2 - 1
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/information/service/ICoreMessageCenterService.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.xunmei.common.core.web.page.TableDataInfo;
 import com.xunmei.core.information.domain.CoreMessageCenter;
 import com.xunmei.core.information.dto.CoreMessageCenterDTO;
+import com.xunmei.core.information.vo.CoreMessageUnReadVO;
 
 import java.util.List;
 
@@ -36,7 +37,7 @@ public interface ICoreMessageCenterService extends IService<CoreMessageCenter> {
 
     TableDataInfo selectByPage(CoreMessageCenterDTO coreMessageCenterDTO);
 
-    Integer isRead();
+    CoreMessageUnReadVO isRead();
 
     /**
      * 新增消息中心

+ 31 - 28
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/information/service/impl/CoreMessageCenterServiceImpl.java

@@ -1,14 +1,11 @@
 package com.xunmei.core.information.service.impl;
 
 
-import cn.hutool.core.collection.CollectionUtil;
 import com.alibaba.nacos.common.utils.CollectionUtils;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.xunmei.common.core.constant.SecurityConstants;
 import com.xunmei.common.core.domain.message.vo.MessageAppPageVo;
-import com.xunmei.common.core.domain.retrieval.domain.CoreMonitoringRetrievalTask;
 import com.xunmei.common.core.utils.DateUtils;
 import com.xunmei.common.core.web.page.TableDataInfo;
 import com.xunmei.common.security.utils.SecurityUtils;
@@ -17,19 +14,17 @@ import com.xunmei.core.information.dto.CoreMessageCenterDTO;
 import com.xunmei.core.information.mapper.CoreMessageCenterMapper;
 import com.xunmei.core.information.service.ICoreMessageCenterService;
 import com.xunmei.core.information.vo.CoreMessageCenterVO;
+import com.xunmei.core.information.vo.CoreMessageUnReadVO;
 import com.xunmei.core.message.mapper.CoreAnnouncementNotificationMapper;
 import com.xunmei.system.api.RemoteOrgService;
 import com.xunmei.system.api.RemoteRoleService;
 import com.xunmei.system.api.RemoteUserService;
-import com.xunmei.system.api.domain.SysOrg;
-import com.xunmei.system.api.domain.SysRole;
 import com.xunmei.system.api.model.LoginUser;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.util.Arrays;
-import java.util.Collections;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -93,33 +88,41 @@ public class CoreMessageCenterServiceImpl extends ServiceImpl<CoreMessageCenterM
     }
 
     @Override
-    public Integer isRead() {
+    public CoreMessageUnReadVO isRead() {
         Long userId = SecurityUtils.getUserId();
-        Integer integer1 = baseMapper.selectNoRead(userId);
-        //通知
+        // 业务提醒数量
+        Integer businessUnReadCount = baseMapper.selectNoRead(userId,2);
+        // 消息未读数量
+        Integer messageUnReadCount = baseMapper.selectNoRead(userId,3);
+        //获取通知公共未读数量
         LoginUser loginUser = SecurityUtils.getLoginUser();
-        List<SysRole> roleByUserId = remoteRoleService.getRoleByUserId(loginUser.getUserid(), SecurityConstants.INNER);
-        List<Long> collect = roleByUserId.stream().map(SysRole::getId).collect(Collectors.toList());
-        Long[] roles;
-        if (CollectionUtils.isNotEmpty(collect)) {
-            roles = collect.toArray(new Long[collect.size()]);
-        } else {
-            roles = null;
-        }
+//        List<SysRole> roleByUserId = remoteRoleService.getRoleByUserId(loginUser.getUserid(), SecurityConstants.INNER);
+//        List<Long> collect = roleByUserId.stream().map(SysRole::getId).collect(Collectors.toList());
+//        Long[] roles;
+//        if (CollectionUtils.isNotEmpty(collect)) {
+//            roles = collect.toArray(new Long[collect.size()]);
+//        } else {
+//            roles = null;
+//        }
         //通知
-        Integer i = 0;
-        if (null!=roles){
-            List<MessageAppPageVo> messageAppPageVos = coreAnnouncementNotificationMapper.selectAll(loginUser.getOrgId(), roles);
-            List<Long> longs = coreAnnouncementNotificationMapper.selectReadByUser(loginUser.getUserid());
-            List<Long> collect1 = messageAppPageVos.stream().map(MessageAppPageVo::getId).collect(Collectors.toList());
-            if (CollectionUtils.isNotEmpty(collect1) && null != longs && longs.size() != collect1.size()) {
-                i = collect1.size() - longs.size();
-            }
+        Integer noticeUnReadCount = 0;
+//        if (null!=roles){
+        List<MessageAppPageVo> messageAppPageVos = coreAnnouncementNotificationMapper.selectAll(loginUser.getOrgId(), null);
+        List<Long> longs = coreAnnouncementNotificationMapper.selectReadByUser(loginUser.getUserid());
+        List<Long> collect1 = messageAppPageVos.stream().map(MessageAppPageVo::getId).collect(Collectors.toList());
+        if (CollectionUtils.isNotEmpty(collect1) && null != longs && longs.size() != collect1.size()) {
+            noticeUnReadCount = collect1.size() - longs.size();
         }
-        Integer result = 0;
-        if (i + integer1 > 0) {
-            result = i + integer1;
+//        }
+        Integer totalUnReadCount = 0;
+        if (noticeUnReadCount + businessUnReadCount+messageUnReadCount > 0) {
+            totalUnReadCount = noticeUnReadCount + businessUnReadCount+messageUnReadCount;
         }
+        CoreMessageUnReadVO result=new CoreMessageUnReadVO();
+        result.setTotalCount(totalUnReadCount);
+        result.setMessageUnReadCount(messageUnReadCount);
+        result.setBusinessUnReadCount(businessUnReadCount);
+        result.setNoticeUnReadCount(noticeUnReadCount);
         return result;
     }
 

+ 27 - 0
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/information/vo/CoreMessageUnReadVO.java

@@ -0,0 +1,27 @@
+package com.xunmei.core.information.vo;
+
+import com.xunmei.common.core.domain.message.vo.MessageAppPageVo;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author :LuoWei
+ * @date : 2023/9/25
+ */
+@Data
+public class CoreMessageUnReadVO {
+    @ApiModelProperty(value = "消息未读总数")
+    private Integer totalCount;
+
+    @ApiModelProperty(value = "业务提示未读总数")
+    private Integer businessUnReadCount;
+
+    @ApiModelProperty(value = "消息未读总数")
+    private Integer messageUnReadCount;
+
+    @ApiModelProperty(value = "通知公告未读总数")
+    private Integer noticeUnReadCount;
+
+
+
+}

+ 5 - 1
soc-modules/soc-modules-core/src/main/resources/mapper/information/CoreMessageCenterMapper.xml

@@ -81,7 +81,11 @@
         FROM
             core_message_center
         WHERE
-            is_read = 0 AND user_id=#{userId}
+            is_read = 0
+          AND user_id=#{userId}
+        <if test="messageType != null ">
+            and type = #{messageType}
+        </if>
     </select>
 
     <insert id="insertCoreMessageCenter" parameterType="com.xunmei.core.information.domain.CoreMessageCenter">

+ 6 - 5
soc-modules/soc-modules-core/src/main/resources/mapper/message/CoreAnnouncementNotificationMapper.xml

@@ -138,12 +138,13 @@
     </select>
     <select id="selectAll" resultType="com.xunmei.common.core.domain.message.vo.MessageAppPageVo">
         select T.*,T.file_list as strFileList from (select a.* from core_announcement_notification a
-        left join core_announcement_notification_to_role b on a.id = b.announcement_notification_id
+<!--        left join core_announcement_notification_to_role b on a.id = b.announcement_notification_id-->
         left join core_announcement_notification_to_org c on a.id = c.announcement_notification_id
-        where a.messag_status = 1 and c.org_id = #{orgId} and (a.messag_type = 0 or (b.role_id in
-        <foreach collection="roles" item="item" open="(" close=")" separator=",">
-            #{item}
-        </foreach> and a.messag_type=1))
+        where a.messag_status = 1 and c.org_id = #{orgId}
+<!--        and (a.messag_type = 0 or (b.role_id in-->
+<!--        <foreach collection="roles" item="item" open="(" close=")" separator=",">-->
+<!--            #{item}-->
+<!--        </foreach> and a.messag_type=1))-->
         GROUP BY a.id) T
     </select>
     <select id="selectReadByUser" resultType="java.lang.Long">