fangqing hai 2 semanas
pai
achega
c53a6349e8

+ 3 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/community/CommunityArticleCollectMapper.java

@@ -18,4 +18,7 @@ public interface CommunityArticleCollectMapper extends BaseMapper<CommunityArtic
                                                                   @Param("offset") int offset,
                                                                   @Param("limit") int limit,
                                                                   @Param("searchType") int searchType);
+    //刷新全部已读用
+    List<RecommendAndCollectVo> selectRecommendAndCollectByUserId2(@Param("userId") Long userId,
+                                                                  @Param("searchType") int searchType);
 }

+ 3 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/community/CommunityArticleCommentMapper.java

@@ -59,4 +59,7 @@ public interface CommunityArticleCommentMapper extends BaseMapper<CommunityArtic
                                            @Param("offset") int offset,
                                            @Param("limit") int limit,
                                            @Param("searchType") int searchType);
+
+    List<CommentVo> getCommentListByUserId2(@Param("userId") long userId,
+                                           @Param("searchType") int searchType);
 }

+ 5 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/service/CommunityArticleCommentServiceImpl.java

@@ -25,4 +25,9 @@ public class CommunityArticleCommentServiceImpl extends ServiceImpl<CommunityArt
     public List<CommentVo> getCommentInfoByUserId(long userId, int offset, int limit, int searchType) {
         return communityArticleCommentMapper.getCommentListByUserId(userId,offset,limit,searchType);
     }
+
+    @Override
+    public List<CommentVo> getCommentInfoByUserId2(long userId, int searchType) {
+        return communityArticleCommentMapper.getCommentListByUserId2(userId,searchType);
+    }
 }

+ 5 - 0
ruoyi-generator/src/main/java/com/ruoyi/generator/service/ICommunityArticleCommentService.java

@@ -19,4 +19,9 @@ public interface ICommunityArticleCommentService extends IService<CommunityArtic
                                            @Param("offset") int offset,
                                            @Param("limit") int limit,
                                            @Param("searchType") int searchType);
+
+    /** 刷新全部已读用
+     */
+    List<CommentVo> getCommentInfoByUserId2(@Param("userId") long userId,
+                                            @Param("searchType") int searchType);
 }

+ 106 - 0
ruoyi-generator/src/main/resources/mapper/community/CommunityArticleCollectMapper.xml

@@ -110,4 +110,110 @@
         </if>
         limit #{offset},#{limit}
     </select>
+    <select id="selectRecommendAndCollectByUserId2" resultType="com.ruoyi.generator.vo.RecommendAndCollectVo">
+        select *
+        from (select car.id,
+        car.article_id,
+        ca.id                                                                 as third_id,
+        car.user_id,
+        car.create_time,
+        (select su.nick_name from sys_user su where su.user_id = car.user_id) as nick_name,
+        (select su.avatar from sys_user su where su.user_id = car.user_id)    as avatar,
+        (select cai.image_url
+        from community_article_images cai
+        where cai.article_id = car.article_id
+        limit 1)                                                             as image_url,
+        ''                                                                    as content,
+        car.is_read,
+        '0'                                                                   as type
+        from community_article_recommend car
+        left join community_article ca on car.article_id = ca.id
+        where ca.user_id = #{userId} and car.user_id != #{userId} and (car.is_notice != 1 or car.is_notice is null)
+        union all
+        select cac.id,
+        cac.article_id,
+        ca.id                                                                 as third_id,
+        cac.user_id,
+        cac.create_time,
+        (select su.nick_name from sys_user su where su.user_id = cac.user_id) as nick_name,
+        (select su.avatar from sys_user su where su.user_id = cac.user_id)    as avatar,
+        (select cai.image_url
+        from community_article_images cai
+        where cai.article_id = cac.article_id
+        limit 1)                                                             as image_url,
+        ''                                                                    as content,
+        cac.is_read,
+        '1'                                                                   as type
+        from community_article_collect cac
+        left join community_article ca on cac.article_id = ca.id
+        where ca.user_id = #{userId} and cac.user_id != #{userId} and (cac.is_notice != 1 or cac.is_notice is null)
+        union all
+        select ccl.id,
+        cac.article_id                                                        as article_id,
+        cac.id                                                                as third_id,
+        ccl.user_id,
+        ccl.create_time,
+        (select su.nick_name from sys_user su where su.user_id = ccl.user_id) as nick_name,
+        (select su.avatar from sys_user su where su.user_id = ccl.user_id)    as avatar,
+        (select cai.image_url
+        from community_article_comment cai
+        where cai.article_id = ccl.comment_id
+        limit 1)                                                             as image_url,
+        (select cac.content
+        from community_article_comment cac
+        where cac.id = ccl.comment_id)                                       as content,
+        ccl.is_read,
+        '2'                                                                   as type
+        from community_comment_like ccl
+        left join community_article_comment cac on ccl.comment_id = cac.id
+        where cac.user_id = #{userId} and ccl.user_id != #{userId} and (ccl.is_notice != 1 or ccl.is_notice is null)
+        union all
+        select ccl.id,
+        cac.article_id                                                        as article_id,
+        ccr.id                                                                as third_id,
+        ccl.user_id,
+        ccl.create_time,
+        (select su.nick_name from sys_user su where su.user_id = ccl.user_id) as nick_name,
+        (select su.avatar from sys_user su where su.user_id = ccl.user_id)    as avatar,
+        (select cai.image_url
+        from community_article_comment cai
+        where cai.article_id = ccl.comment_id
+        limit 1)                                                             as image_url,
+        (select ccr.content
+        from community_comment_reply ccr
+        where ccr.id = ccl.reply_id)                                         as content,
+        ccl.is_read,
+        '3'                                                                   as type
+        from community_comment_like ccl
+        left join community_comment_reply ccr on ccl.reply_id = ccr.id
+        left join community_article_comment cac on ccr.id = ccr.comment_id
+        where ccr.user_id = #{userId} and ccl.user_id != #{userId} and (ccl.is_notice != 1 or ccl.is_notice is null)
+        union all
+        select cl.id,
+        cl.article_id,
+        ca.id                                                                 as third_id,
+        cl.user_id,
+        cl.create_time,
+        (select su.nick_name from sys_user su where su.user_id = cl.user_id) as nick_name,
+        (select su.avatar from sys_user su where su.user_id = cl.user_id)    as avatar,
+        (select cai.image_url
+        from community_article_images cai
+        where cai.article_id = cl.article_id
+        limit 1)                                                             as image_url,
+        ''                                                                    as content,
+        cl.is_read,
+        '10'                                                                   as type
+        from community_like cl
+        left join community_article ca on cl.article_id = ca.id
+        where ca.user_id =  #{userId} and cl.user_id !=  #{userId} and (cl.is_notice != 1 or cl.is_notice is null)
+        and (ca.is_delete != 1 or ca.is_delete is null)
+        and (ca.is_draft != 1 or ca.is_draft is null)
+        ) result
+        <if test="searchType == 1">
+            order by result.create_time desc
+        </if>
+        <if test="searchType == 2">
+            order by result.create_time asc
+        </if>
+    </select>
 </mapper>

+ 145 - 0
ruoyi-generator/src/main/resources/mapper/community/CommunityArticleCommentMapper.xml

@@ -362,4 +362,149 @@
         </if>
         limit #{offset},#{limit}
     </select>
+    <select id="getCommentListByUserId2" resultType="com.ruoyi.generator.vo.CommentVo">
+        SELECT
+        c.id,
+        c.joinId,
+        c.parentReplyId,
+        c.article_id,
+        c.user_id,
+        c.image_url,
+        c.type,
+        c.avatar,
+        c.nick_name,
+        c.create_time,
+        c.content,
+        c.is_read,
+        c.isLike
+        FROM (
+        SELECT
+        cac.id,
+        cac.id as joinId,
+        cac.id  as parentReplyId,
+        cac.article_id,
+        (SELECT cai.image_url FROM community_article_images cai WHERE cac.article_id = cai.article_id AND (cai.is_delete IS NULL OR cai.is_delete != 1) ORDER BY cai.create_time DESC LIMIT 1) AS image_url,
+        '8' AS type,
+        su.avatar,
+        su.nick_name,
+        cac.user_id,
+        cac.create_time,
+        cac.content,
+        cac.is_read,
+        CASE WHEN EXISTS (SELECT 1 FROM community_comment_like cck WHERE cck.comment_id = cac.id AND cck.user_id = #{userId} ) THEN TRUE ELSE FALSE END AS isLike
+        FROM community_article ca
+        LEFT JOIN community_article_comment cac ON ca.id = cac.article_id
+        LEFT JOIN sys_user su ON cac.user_id = su.user_id
+        WHERE ca.user_id = #{userId}
+        AND cac.user_id != #{userId}
+        AND cac.id IS NOT NULL
+        AND (ca.is_delete IS NULL OR ca.is_delete != 1)
+        AND (cac.is_delete IS NULL OR cac.is_delete != 1)
+        AND (cac.is_notice != 1 or cac.is_notice is null)
+        AND cac.ID  not in ( select comment_id from community_article_at  caa  where peer_id = #{userId})
+
+        UNION ALL
+
+        SELECT
+        ccr.id,
+        ccr.comment_id as joinId,
+        ccr.parent_reply_id as parentReplyId,
+        cac.article_id,
+        (SELECT cai.image_url FROM community_article_images cai WHERE cac.article_id = cai.article_id AND (cai.is_delete IS NULL OR cai.is_delete != 1) ORDER BY cai.create_time DESC LIMIT 1) AS image_url,
+        '9' AS type,
+        su.avatar,
+        su.nick_name,
+        ccr.user_id,
+        ccr.create_time,
+        ccr.content,
+        ccr.is_read,
+        CASE WHEN EXISTS (SELECT 1 FROM community_comment_like cck WHERE cck.reply_id = ccr.id AND cck.user_id = #{userId} ) THEN TRUE ELSE FALSE END AS isLike
+        FROM community_article_comment cac
+        LEFT JOIN community_comment_reply ccr ON cac.id = ccr.comment_id
+        LEFT JOIN sys_user su ON ccr.user_id = su.user_id
+        WHERE cac.user_id = #{userId}
+        AND ccr.user_id != #{userId}
+        AND ccr.id IS NOT NULL
+        AND (cac.is_delete IS NULL OR cac.is_delete != 1)
+        AND (ccr.is_delete IS NULL OR ccr.is_delete != 1)
+        AND (ccr.is_notice != 1 or ccr.is_notice is null)
+
+        UNION ALL
+
+        SELECT
+        caa.id,
+        caa.article_id as joinId,
+        null as parentReplyId,
+        caa.article_id,
+        (SELECT cai.image_url FROM community_article_images cai WHERE caa.article_id = cai.article_id AND (cai.is_delete IS NULL OR cai.is_delete != 1) ORDER BY cai.create_time DESC LIMIT 1) AS image_url,
+        '5' AS type,
+        su.avatar,
+        su.nick_name,
+        caa.peer_id as user_id,
+        caa.create_time,
+        NULL AS content,
+        caa.is_read,
+        CASE WHEN EXISTS (SELECT 1 FROM community_like cl WHERE cl.article_id = caa.article_id AND cl.user_id = #{userId}) THEN TRUE ELSE FALSE END AS isLike
+        FROM community_article_at caa
+        LEFT JOIN sys_user su ON caa.user_id = su.user_id
+        WHERE caa.type = 0
+        AND caa.peer_id = #{userId}
+        AND (caa.is_delete IS NULL OR caa.is_delete != 1)
+        AND (caa.is_notice != 1 or caa.is_notice is null)
+        UNION ALL
+
+        SELECT
+        caa.id,
+        cac.id as joinId,
+        cac.id as parentReplyId,
+        caa.article_id,
+        (SELECT cai.image_url FROM community_article_images cai WHERE caa.article_id = cai.article_id AND (cai.is_delete IS NULL OR cai.is_delete != 1) ORDER BY cai.create_time DESC LIMIT 1) AS image_url,
+        '6' AS type,
+        su.avatar,
+        su.nick_name,
+        caa.peer_id as user_id,
+        caa.create_time,
+        cac.content,
+        caa.is_read,
+        CASE WHEN EXISTS (SELECT 1 FROM community_comment_like cck WHERE cck.comment_id = cac.id AND cck.user_id = #{userId}) THEN TRUE ELSE FALSE END AS isLike
+        FROM community_article_at caa
+        LEFT JOIN community_article_comment cac ON caa.comment_id = cac.id
+        LEFT JOIN sys_user su ON caa.user_id = su.user_id
+        WHERE caa.type = 1
+        AND caa.peer_id = #{userId}
+        AND (caa.is_delete IS NULL OR caa.is_delete != 1)
+        AND (cac.is_delete IS NULL OR cac.is_delete != 1)
+        AND (caa.is_notice != 1 or caa.is_notice is null)
+        UNION ALL
+
+        SELECT
+        caa.id,
+        ccr.comment_id as joinId,
+        ccr.parent_reply_id as parentReplyId,
+        caa.article_id,
+        (SELECT cai.image_url FROM community_article_images cai WHERE caa.article_id = cai.article_id AND (cai.is_delete IS NULL OR cai.is_delete != 1) ORDER BY cai.create_time DESC LIMIT 1) AS image_url,
+        '7' AS type,
+        su.avatar,
+        su.nick_name,
+        caa.peer_id as user_id,
+        caa.create_time,
+        ccr.content,
+        caa.is_read,
+        CASE WHEN EXISTS (SELECT 1 FROM community_comment_like cck WHERE cck.reply_id = ccr.id AND cck.user_id = #{userId}) THEN TRUE ELSE FALSE END AS isLike
+        FROM community_article_at caa
+        LEFT JOIN community_comment_reply ccr ON caa.reply_id = ccr.id
+        LEFT JOIN sys_user su ON caa.user_id = su.user_id
+        WHERE caa.type = 2
+        AND caa.peer_id = #{userId}
+        AND (caa.is_delete IS NULL OR caa.is_delete != 1)
+        AND (ccr.is_delete IS NULL OR ccr.is_delete != 1)
+        AND (caa.is_notice != 1 or caa.is_notice is null)
+        ) c
+        <if test="searchType == 1">
+            order by c.create_time desc
+        </if>
+        <if test="searchType == 2">
+            order by c.create_time asc
+        </if>
+    </select>
 </mapper>