ArticleInfoMapper.xml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  3. <mapper namespace="com.cslg.ppa.mapper.ArticleInfoMapper">
  4. <select id="selectArticleInfoList" resultType="com.cslg.ppa.vo.SelectArticleInfoVO">
  5. SELECT
  6. ai.id as articleId,
  7. ai.title,
  8. CASE
  9. WHEN ai.old_content IS NOT NULL AND ai.old_content != '' THEN ai.old_content
  10. ELSE ai.digest
  11. END AS digest,
  12. ai.source_id,
  13. ai.public_time,
  14. ai.create_time,
  15. ai.article_url,
  16. ai.wx_article_icon,
  17. si.source_name,
  18. si.source_type,
  19. GROUP_CONCAT(acr.category_id) as categoryIdsStr,
  20. GROUP_CONCAT(ca.name) as categoryNamesStr
  21. FROM article_info ai
  22. LEFT JOIN article_category_relation acr ON acr.article_id = ai.id
  23. LEFT JOIN category ca ON ca.id = acr.category_id
  24. LEFT JOIN source_info si ON si.id = ai.source_id
  25. <where>
  26. <if test="vo.key != null and vo.key != ''">
  27. ai.title like concat('%',#{vo.key},'%')
  28. </if>
  29. <if test="vo.categoryId != null">
  30. and acr.category_id = #{vo.categoryId}
  31. </if>
  32. <if test="vo.sourceName != null and vo.sourceName != ''">
  33. and si.source_name like concat('%',#{vo.sourceName},'%')
  34. </if>
  35. <if test="vo.beginTime != null">
  36. and ai.public_time &gt;= #{vo.beginTime}
  37. </if>
  38. <if test="vo.endTime != null">
  39. and ai.public_time &lt;= #{vo.endTime}
  40. </if>
  41. </where>
  42. GROUP BY ai.id
  43. ORDER BY ai.public_time DESC, ai.id DESC
  44. <if test="vo.pageNum != null and vo.pageSize != null">
  45. LIMIT ${(vo.pageNum -1) * vo.pageSize},${vo.pageSize}
  46. </if>
  47. </select>
  48. <select id="selectArticleInfoCount" resultType="java.lang.Long">
  49. SELECT COUNT(DISTINCT ai.id)
  50. FROM article_info ai
  51. LEFT JOIN article_category_relation acr ON acr.article_id = ai.id
  52. LEFT JOIN category ca ON ca.id = acr.category_id
  53. LEFT JOIN source_info si ON si.id = ai.source_id
  54. <where>
  55. <if test="vo.key != null and vo.key != ''">
  56. ai.title like concat('%',#{vo.key},'%')
  57. </if>
  58. <if test="vo.categoryId != null">
  59. and acr.category_id = #{vo.categoryId}
  60. </if>
  61. <if test="vo.sourceName != null and vo.sourceName != ''">
  62. and si.source_name like concat('%',#{vo.sourceName},'%')
  63. </if>
  64. <if test="vo.beginTime != null">
  65. and ai.public_time &gt;= #{vo.beginTime}
  66. </if>
  67. <if test="vo.endTime != null">
  68. and ai.public_time &lt;= #{vo.endTime}
  69. </if>
  70. </where>
  71. </select>
  72. <select id="selectArticleList" resultType="com.cslg.ppa.vo.OneClickExportVO">
  73. select ai.id as articleId,
  74. ai.title,
  75. ai.digest,
  76. ai.old_content,
  77. ai.category_id,
  78. ai.public_time,
  79. ai.article_url,
  80. ai.if_export_from_local,
  81. ca.name as categoryName,
  82. ai.source_id,
  83. si.source_name,
  84. si.source_type
  85. from article_info ai
  86. left join category ca on ca.id = ai.category_id
  87. left join source_info si on si.id = ai.source_id
  88. <where>
  89. <if test="vo.type == 1">
  90. ai.category_id in (1,2,3,4,5)
  91. </if>
  92. <if test="vo.type == 2">
  93. ai.category_id in (16,17,18,19,20,21,22)
  94. </if>
  95. <if test="vo.beginTime != null">
  96. and ai.public_time &gt;= #{vo.beginTime}
  97. </if>
  98. <if test="vo.endTime != null">
  99. and ai.public_time &lt;= #{vo.endTime}
  100. </if>
  101. </where>
  102. order by ai.public_time asc,ai.id asc
  103. </select>
  104. </mapper>