浏览代码

查询用户列表增加拉黑,获取聊天记录增加拉黑

fangqing 6 月之前
父节点
当前提交
d1fe9327f2

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

@@ -91,6 +91,10 @@ public class CommunityArticleController extends BaseController {
     @Autowired
     private CommunityCircleExpandMapper communityCircleExpandMapper;
 
+
+    @Autowired
+    private CommunityUserBlockMapper communityUserBlockMapper;
+
     /**
      * 获取文章列表信息
      */
@@ -574,10 +578,26 @@ public class CommunityArticleController extends BaseController {
         if (Objects.isNull(SearchValue)) {
             return AjaxResult.error();
         }
+        Long userId = SecurityUtils.getLoginUser().getUserId();
         List<CommunityUserInfoVo> communityUserInfoVos = null;
         try {
             communityUserInfoVos = communityArticleService.selectUserBySearchValue(SearchValue);
+
+            List<CommunityUserInfoVo> communityUserInfoVos_copy = new ArrayList<>(communityUserInfoVos);
+            for (CommunityUserInfoVo communityUserInfoVo : communityUserInfoVos_copy) {
+                communityUserInfoVo.getUserId();
+                List<CommunityUserBlock> communityUserBlocks = communityUserBlockMapper.selectList(new QueryWrapper<CommunityUserBlock>()
+                        .eq("user_id", userId)
+                        .eq("peer_id", communityUserInfoVo.getUserId()));
+                for (CommunityUserBlock userBlock : communityUserBlocks) {
+                    if (userBlock.isBlock()) {
+                        communityUserInfoVos.remove(communityUserInfoVo);
+                        break;
+                    }
+                }
+            }
         } catch (Exception e) {
+            // e.printStackTrace();
             throw new ProjectException();
         }
 

+ 15 - 1
ruoyi-generator/src/main/java/com/ruoyi/generator/controller/CommunityChatMsgController.java

@@ -9,6 +9,8 @@ import com.ruoyi.common.exception.user.ProjectException;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.bean.BeanUtils;
 import com.ruoyi.generator.domain.Community.CommunityArticle;
+import com.ruoyi.generator.domain.Community.CommunityUserBlock;
+import com.ruoyi.generator.mapper.community.CommunityUserBlockMapper;
 import com.ruoyi.system.domain.CommunityChatMsg;
 import com.ruoyi.system.domain.vo.CommunityChatMsgVo;
 import com.ruoyi.system.domain.vo.SysUserVo;
@@ -43,6 +45,9 @@ public class CommunityChatMsgController extends BaseController {
     @Resource
     private SysUserMapper sysUserMapper;
 
+    @Resource
+    private CommunityUserBlockMapper communityUserBlockMapper;
+
     /**
      * 获取当前登录用户聊天记录
      */
@@ -52,6 +57,14 @@ public class CommunityChatMsgController extends BaseController {
         Long userId = SecurityUtils.getUserId();
         List<CommunityChatMsgVo> chatMsgVos = new ArrayList<>();
         try {
+            List<CommunityUserBlock> communityUserBlocks = communityUserBlockMapper.selectList(new QueryWrapper<CommunityUserBlock>()
+                    .eq("user_id", userId)
+                    .eq("peer_id", otherUserId));
+            for (CommunityUserBlock userBlock : communityUserBlocks) {
+                if (userBlock.isBlock()) {
+                    return AjaxResult.success("当前用户已经被拉黑");
+                }
+            }
             List<CommunityChatMsg> chatMsgList = communityChatMsgService.list(new QueryWrapper<CommunityChatMsg>()
                     .and(wrapper -> wrapper.eq("sender_id", userId)
                             .eq("receiver_id", otherUserId)
@@ -93,7 +106,8 @@ public class CommunityChatMsgController extends BaseController {
                 chatMsgVos.add(chatMsgVo);
             }
         } catch (Exception e) {
-            throw new ProjectException();
+            e.printStackTrace();
+            //throw new ProjectException();
         }
 
 

+ 2 - 1
ruoyi-generator/src/main/resources/mapper/community/CommunityUserInfoMapper.xml

@@ -9,7 +9,8 @@
         a.nick_name as nickName,
         a.avatar as avatar,
         (select count(1) as fansCount from community_user_like c where c.like_user_id = a.user_id) as fansCount,
-        (select count(1) as articleCount from community_article d where d.user_id = a.user_id) as articleCount
+        (select count(1) as articleCount from community_article d where d.user_id = a.user_id) as articleCount,
+        a.user_id as userId
         from sys_user a
         left join community_user_info b on a.user_id = b.user_id
         <if test="searchValue != null and searchValue != ''">

+ 2 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/CommunityChatMsg.java

@@ -1,5 +1,6 @@
 package com.ruoyi.system.domain;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.annotation.JsonFormat;
@@ -45,6 +46,7 @@ public class CommunityChatMsg implements Serializable {
     /**
      * 地址名称
      */
+    @TableField("addressname")
     private String addressName;
     /**
      * 地址