BbsArticleMapper.xml 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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.yonge.cooleshow.bbs.dao.BbsArticleDao">
  4. <resultMap id="BaseResultMap" type="com.yonge.cooleshow.bbs.entity.BbsArticle">
  5. <result column="id_" property="id" />
  6. <result column="user_id_" property="userId" />
  7. <result column="title_" property="title" />
  8. <result column="content_" property="content" />
  9. <result column="label_id_" property="labelId" />
  10. <result column="label_name_" property="labelName" />
  11. <result column="views_count_" property="viewsCount" />
  12. <result column="likes_count_" property="likesCount" />
  13. <result column="comments_count_" property="commentsCount" />
  14. <result column="collects_count_" property="collectsCount" />
  15. <result column="status_" property="status" />
  16. <result column="top_flag_" property="topFlag" />
  17. <result column="reply_flag_" property="replyFlag" />
  18. <result column="examine_time_" property="examineTime" />
  19. <result column="created_time_" property="createdTime" />
  20. <result column="updated_time_" property="updatedTime" />
  21. <result column="del_flag_" property="delFlag" />
  22. </resultMap>
  23. <!-- 表字段 -->
  24. <sql id="baseColumns">
  25. t.id_ as id
  26. , t.user_id_ as userId
  27. , t.title_ as title
  28. , t.content_ as content
  29. , t.label_id_ as labelId
  30. , t.label_name_ as labelName
  31. , t.views_count_ as viewsCount
  32. , t.likes_count_ as likesCount
  33. , t.comments_count_ as commentsCount
  34. , t.collects_count_ as collectsCount
  35. , t.status_ as status
  36. , t.top_flag_ as topFlag
  37. , t.reply_flag_ as replyFlag
  38. , t.examine_time_ as examineTime
  39. , t.created_time_ as createdTime
  40. , t.updated_time_ as updatedTime
  41. , t.del_flag_ as delFlag
  42. </sql>
  43. <insert id="addArticle" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  44. INSERT INTO bbs_article
  45. (user_id_,title_,content_,label_id_,label_name_,status_,reply_flag_)
  46. VALUES(#{userId},#{title},#{content},#{labelId},#{labelName},#{status},#{replyFlag})
  47. </insert>
  48. <update id="deleteArticle" parameterType="java.util.List">
  49. UPDATE bbs_article SET del_flag_=1 WHERE id_ IN
  50. <foreach collection="list" item="item" open="(" separator="," close=")">
  51. #{item}
  52. </foreach>
  53. </update>
  54. <select id="selectPage" resultType="com.yonge.cooleshow.bbs.vo.BbsArticleVo">
  55. SELECT
  56. <include refid="baseColumns" />
  57. FROM bbs_article t
  58. <where>
  59. <if test="param.status != null ">
  60. and #{param.status} = t.status_
  61. </if>
  62. <if test="param.search != null and param.search != ''">
  63. and t.title_ like concat('%',#{param.search},'%')
  64. </if>
  65. <if test="param.label != null">
  66. and t.label_id_ = #{param.label}
  67. </if>
  68. <if test="param.userId != null" >
  69. and t.user_id_ = #{param.userId}
  70. </if>
  71. <if test="param.delFlag != null" >
  72. and t.del_flag_ = #{param.delFlag}
  73. </if>
  74. </where>
  75. order by find_in_set(t.top_flag_,1),
  76. <if test="param.sort != null">
  77. <choose>
  78. <when test="param.sort == 'HOT'">
  79. t.comments_count_ desc,
  80. </when>
  81. </choose>
  82. </if>
  83. t.created_time_ desc
  84. </select>
  85. </mapper>