123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.ruoyi.generator.mapper.community.CommunityCollectionMapper">
- <select id="selectUserCollection" resultType="com.ruoyi.generator.vo.CommunityCollectionVo">
- select id,user_id,collection_name,collection_profile,images,collection_tag,is_delete,articleCount,pageViews,create_by,update_by,create_time,update_time,isFollow from (
- SELECT a.id,
- a.user_id,
- a.collection_name,
- a.collection_profile,
- a.images,
- a.collection_tag,
- a.is_delete,
- COUNT(b.article_id) AS articleCount,
- a.heat AS pageViews,
- a.create_by,
- a.update_by,
- a.create_time,
- a.update_time,
- '0' as isFollow
- FROM community_collection a
- LEFT JOIN community_collection_article b ON a.id = b.collection_id
- LEFT JOIN community_article c ON b.article_id = c.id
- WHERE a.user_id = #{userId}
- AND (a.is_delete != '1' OR a.is_delete IS NULL)
- <if test="articleId != null and articleId != ''">
- AND b.article_id = #{articleId}
- </if>
- GROUP BY a.id,
- a.user_id,
- a.collection_name,
- a.collection_profile,
- a.images,
- a.collection_tag,
- a.is_delete,
- a.create_by,
- a.update_by,
- a.create_time,
- a.update_time
- union all
- SELECT a.id,
- a.user_id,
- a.collection_name,
- a.collection_profile,
- a.images,
- a.collection_tag,
- a.is_delete,
- COUNT(b.article_id) AS articleCount,
- a.heat AS pageViews,
- a.create_by,
- a.update_by,
- a.create_time,
- a.update_time,
- '1' as isFollow
- FROM community_collection a
- LEFT JOIN community_collection_article b ON a.id = b.collection_id
- LEFT JOIN community_article c ON b.article_id = c.id
- LEFT JOIN community_collection_user d ON d.collection_id = a.id
- WHERE d.user_id = #{userId} AND d.id is not null
- AND (a.is_delete != '1' OR a.is_delete IS NULL)
- <if test="articleId != null and articleId != ''">
- AND b.article_id = #{articleId}
- </if>
- GROUP BY a.id,
- a.user_id,
- a.collection_name,
- a.collection_profile,
- a.images,
- a.collection_tag,
- a.is_delete,
- a.create_by,
- a.update_by,
- a.create_time,
- a.update_time
- ) A
- <if test="searchType == 1">
- order by create_time desc
- </if>
- <if test="searchType == 2">
- order by create_time asc
- </if>
- limit #{offset},#{limit}
- </select>
- <select id="selectCollectById" resultType="com.ruoyi.generator.vo.CommunityCollectionVo">
- select a.id,a.collection_name,a.collection_profile,a.images,a.collection_tag
- from community_collection a
- left join community_collection_article b on a.id = b.collection_id
- where b.article_id = #{articleId} and (b.is_delete is null or b.is_delete != '1')
- </select>
- </mapper>
|