Prechádzať zdrojové kódy

聊天记录代码优化新增 接收人是否已删除字段,新增 获取个人中心信息 代码

fangqing 5 mesiacov pred
rodič
commit
255c3569a4

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

@@ -997,7 +997,23 @@ public class CommunityArticleController extends BaseController {
     }
 
 
+    @ApiOperation("获取个人中心信息")
+    @GetMapping("/userPrompt")
+    public AjaxResult userPrompt() {
 
+        Long  userId = SecurityUtils.getLoginUser().getUserId();
+
+        CommunityUserPrompt communityUserPrompt = null;
+        try {
+        communityUserPrompt = communityUserPromptMapper.selectOne(new QueryWrapper<CommunityUserPrompt>()
+                  .eq("create_by",userId));
+
+          System.out.println(communityUserPrompt);
+        } catch (Exception e) {
+           e.printStackTrace();
+        }
+        return AjaxResult.success(communityUserPrompt);
+    }
 
 
 

+ 18 - 2
ruoyi-generator/src/main/java/com/ruoyi/generator/controller/CommunityChatMsgController.java

@@ -14,6 +14,7 @@ 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;
+import com.ruoyi.system.mapper.CommunityChatMsgMapper;
 import com.ruoyi.system.mapper.SysUserMapper;
 import com.ruoyi.system.service.ICommunityChatMsgService;
 import io.swagger.annotations.Api;
@@ -48,6 +49,8 @@ public class CommunityChatMsgController extends BaseController {
     @Resource
     private CommunityUserBlockMapper communityUserBlockMapper;
 
+    @Resource
+    private CommunityChatMsgMapper communitychatMsgMapper;
     /**
      * 获取当前登录用户聊天记录
      */
@@ -65,7 +68,8 @@ public class CommunityChatMsgController extends BaseController {
                     return AjaxResult.success("当前用户已经被拉黑");
                 }
             }
-            List<CommunityChatMsg> chatMsgList = communityChatMsgService.list(new QueryWrapper<CommunityChatMsg>()
+
+            /*List<CommunityChatMsg> chatMsgList = communityChatMsgService.list(new QueryWrapper<CommunityChatMsg>()
                     .and(wrapper -> wrapper.eq("sender_id", userId)
                             .eq("receiver_id", otherUserId)
                             .or()
@@ -76,7 +80,9 @@ public class CommunityChatMsgController extends BaseController {
                         wrapper.ne("is_delete", 1).or().isNull("is_delete");
                     })
                     .orderByDesc("create_time")
-            );
+            );*/
+            List<CommunityChatMsg> chatMsgList = communitychatMsgMapper.getChatMsgRecord(userId, otherUserId, type);
+
             //更新该消息标记为已读
             List<Long> msgId = chatMsgList.stream()
                     .filter(item -> !item.isReceiverIsRead() && Objects.equals(item.getReceiverId(), SecurityUtils.getUserId()))
@@ -168,6 +174,16 @@ public class CommunityChatMsgController extends BaseController {
                                 wrapper.ne("is_delete", 1).or().isNull("is_delete");
                             })
             );
+            communityChatMsgService.update(
+                    null,
+                    new UpdateWrapper<CommunityChatMsg>()
+                            .eq("sender_id", otherUserId )
+                            .eq("receiver_id", userId)
+                            .set("receiver_is_delete", true)
+                            .and((wrapper) -> {
+                                wrapper.ne("receiver_is_delete", 1).or().isNull("receiver_is_delete");
+                            })
+            );
         } catch (Exception e) {
             throw new ProjectException();
         }

+ 72 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/domain/Community/CommunityUserPrompt.java

@@ -0,0 +1,72 @@
+package com.ruoyi.generator.domain.Community;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 个人中心通知表 By Qing
+ * @TableName community_user_prompt
+ */
+@Data
+@TableName("community_user_prompt")
+public class CommunityUserPrompt implements Serializable  {
+    /**
+     * 唯一id
+     */
+    @NotNull(message = "[唯一id]不能为空")
+    @ApiModelProperty("唯一id")
+    @TableId(type = IdType.AUTO, value = "id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long id;
+
+    /**
+     * 赞和收藏
+     */
+    @ApiModelProperty("赞和收藏")
+    private Boolean  likeCollect;
+
+    /**
+     * 新增关注
+     */
+    @ApiModelProperty("新增关注")
+    private Boolean likeUser;
+
+    /**
+     * 评论与@
+     */
+    @ApiModelProperty("评论与@")
+    private Boolean commentCircle;
+
+    /**
+     * 创建者
+     */
+    private Long createBy;
+
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+
+    /**
+     * 更新者
+     */
+    private Long updateBy;
+
+    /**
+     * 更新时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date updateTime;
+
+}

+ 10 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/community/CommunityUserPromptMapper.java

@@ -0,0 +1,10 @@
+package com.ruoyi.generator.mapper.community;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ruoyi.generator.domain.Community.CommunityUserPrivacy;
+import com.ruoyi.generator.domain.Community.CommunityUserPrompt;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface CommunityUserPromptMapper extends BaseMapper<CommunityUserPrompt> {
+}

+ 7 - 1
ruoyi-system/src/main/java/com/ruoyi/system/domain/CommunityChatMsg.java

@@ -102,7 +102,13 @@ public class CommunityChatMsg implements Serializable {
     private Long updateBy;
 
     /**
-     * 是否已删除
+     * 发送人是否已删除
      */
     private Boolean isDelete;
+
+    /**
+     * 接收人是否已删除
+     */
+    private Boolean receiverIsDelete;
+
 }

+ 7 - 1
ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/CommunityChatMsgVo.java

@@ -101,7 +101,13 @@ public class CommunityChatMsgVo implements Serializable {
     private Date createTime;
 
     /**
-     * 是否已删除
+     * 发送人是否已删除
      */
     private Boolean isDelete;
+
+    /**
+     * 接收人是否已删除
+     */
+    private Boolean receiverIsDelete;
+
 }

+ 3 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/CommunityChatMsgMapper.java

@@ -2,6 +2,7 @@ package com.ruoyi.system.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.ruoyi.system.domain.CommunityChatMsg;
+import com.ruoyi.system.domain.vo.CommunityChatMsgVo;
 import com.ruoyi.system.domain.vo.SysUserVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -17,4 +18,6 @@ public interface CommunityChatMsgMapper extends BaseMapper<CommunityChatMsg> {
      * @return
      */
     List<SysUserVo> getChatListWithLatestMessage(@Param("userId") Long userId, @Param("type") String type);
+
+    List<CommunityChatMsg>  getChatMsgRecord (@Param("userId") Long userId, @Param("otherUserId") Long otherUserId, @Param("type") String type);
 }

+ 48 - 0
ruoyi-system/src/main/resources/mapper/system/CommunityChatMsgMapper.xml

@@ -55,4 +55,52 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             u.user_id = latest.chat_user_id
         ORDER BY latest.latest_time DESC
     </select>
+    <select id="getChatMsgRecord" resultType="com.ruoyi.system.domain.CommunityChatMsg">
+        SELECT
+            id	                as id,
+            content	            as content,
+            sender_id	        as senderId,
+            receiver_id	        as receiverId,
+            sender_is_read	    as senderIsRead,
+            receiver_is_read	as receiverIsRead,
+            address	            as address,
+            address_name	    as addressName,
+            latitude	        as latitude,
+            longitude	        as longitude,
+            url	                as url,
+            voice_time	        as voiceTime,
+            create_by	        as createBy,
+            create_time	        as createTime,
+            update_by	        as updateBy,
+            update_time	        as updateTime,
+            message_type	    as messageType,
+            type	            as type,
+            is_delete	        as isDelete,
+            receiver_is_delete  as receiverIsDelete
+        FROM
+            community_chat_msg
+        WHERE
+            (
+                    (
+                        sender_id = #{userId} AND receiver_id = #{otherUserId}
+                        )
+                    OR (
+                        sender_id = #{otherUserId} AND receiver_id = #{userId}
+                        )
+                )
+          AND type = 'chat'
+          AND (
+                (
+                            sender_id = #{userId} AND (
+                        is_delete IS NULL OR is_delete !=  1
+                        )
+                    )
+                OR (
+                            receiver_id = #{userId} AND (
+                        receiver_is_delete IS NULL OR receiver_is_delete !=   1
+                        )
+                    )
+            )
+        ORDER BY create_time DESC
+    </select>
 </mapper>