ArticleInfoMapper.xml 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 ai.id as articleId,
  6. ai.title,
  7. ai.digest,
  8. ai.category_id,
  9. ai.source_id,
  10. ai.public_time,
  11. ai.create_time,
  12. ai.article_url,
  13. ai.wx_article_icon,
  14. ca.name as categoryName,
  15. si.source_name,
  16. si.source_type
  17. from article_info ai
  18. left join category ca on ca.id = ai.category_id
  19. left join source_info si on si.id = ai.source_id
  20. <where>
  21. <if test="vo.key != null and vo.key != ''">
  22. ai.title like concat('%',#{vo.key},'%')
  23. </if>
  24. <if test="vo.categoryId != null">
  25. and ai.category_id = #{vo.categoryId}
  26. </if>
  27. <if test="vo.sourceName != null and vo.sourceName != ''">
  28. and si.source_name = #{vo.sourceName}
  29. </if>
  30. <if test="vo.beginTime != null">
  31. and ai.public_time &gt;= #{vo.beginTime}
  32. </if>
  33. <if test="vo.endTime != null">
  34. and ai.public_time &lt;= #{vo.endTime}
  35. </if>
  36. </where>
  37. order by ai.public_time desc,ai.id desc
  38. <if test="vo.pageNum != null and vo.pageSize != null">
  39. limit
  40. ${(vo.pageNum -1) * vo.pageSize},${vo.pageSize}
  41. </if>
  42. </select>
  43. <select id="selectArticleInfoCount" resultType="java.lang.Long">
  44. select count(*)
  45. from article_info ai
  46. left join category ca on ca.id = ai.category_id
  47. left join source_info si on si.id = ai.source_id
  48. <where>
  49. <if test="vo.key != null and vo.key != ''">
  50. ai.title like concat('%',#{vo.key},'%')
  51. </if>
  52. <if test="vo.categoryId != null">
  53. and ai.category_id = #{vo.categoryId}
  54. </if>
  55. <if test="vo.sourceName != null and vo.sourceName != ''">
  56. and si.source_name = #{vo.sourceName}
  57. </if>
  58. <if test="vo.beginTime != null">
  59. and ai.public_time &gt;= #{vo.beginTime}
  60. </if>
  61. <if test="vo.endTime != null">
  62. and ai.public_time &lt;= #{vo.endTime}
  63. </if>
  64. </where>
  65. </select>
  66. </mapper>