TopicDao.xml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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.kmall.admin.dao.TopicDao">
  4. <resultMap type="com.kmall.admin.entity.TopicEntity" id="topicMap">
  5. <result property="id" column="id"/>
  6. <result property="title" column="title"/>
  7. <result property="content" column="content"/>
  8. <result property="avatar" column="avatar"/>
  9. <result property="itemPicUrl" column="item_pic_url"/>
  10. <result property="subtitle" column="subtitle"/>
  11. <result property="topicCategoryId" column="topic_category_id"/>
  12. <result property="priceInfo" column="price_info"/>
  13. <result property="readCount" column="read_count"/>
  14. <result property="scenePicUrl" column="scene_pic_url"/>
  15. <result property="topicTemplateId" column="topic_template_id"/>
  16. <result property="topicTagId" column="topic_tag_id"/>
  17. </resultMap>
  18. <select id="queryObject" resultType="com.kmall.admin.entity.TopicEntity">
  19. select
  20. `id`,
  21. `title`,
  22. `content`,
  23. `avatar`,
  24. `item_pic_url`,
  25. `subtitle`,
  26. `topic_category_id`,
  27. `price_info`,
  28. `read_count`,
  29. `scene_pic_url`,
  30. `topic_template_id`,
  31. `topic_tag_id`
  32. from mall_topic
  33. where id = #{id}
  34. </select>
  35. <select id="queryList" resultType="com.kmall.admin.entity.TopicEntity">
  36. select
  37. `id`,
  38. `title`,
  39. `content`,
  40. `avatar`,
  41. `item_pic_url`,
  42. `subtitle`,
  43. `topic_category_id`,
  44. `price_info`,
  45. `read_count`,
  46. `scene_pic_url`,
  47. `topic_template_id`,
  48. `topic_tag_id`
  49. from mall_topic
  50. WHERE 1=1
  51. <if test="title != null and title.trim() != ''">
  52. AND title LIKE concat('%',#{title},'%')
  53. </if>
  54. <choose>
  55. <when test="sidx != null and sidx.trim() != ''">
  56. order by ${sidx} ${order}
  57. </when>
  58. <otherwise>
  59. order by id desc
  60. </otherwise>
  61. </choose>
  62. <if test="offset != null and limit != null">
  63. limit #{offset}, #{limit}
  64. </if>
  65. </select>
  66. <select id="queryTotal" resultType="int">
  67. select count(*) from mall_topic
  68. WHERE 1=1
  69. <if test="title != null and title.trim() != ''">
  70. AND title LIKE concat('%',#{title},'%')
  71. </if>
  72. </select>
  73. <insert id="save" parameterType="com.kmall.admin.entity.TopicEntity" useGeneratedKeys="true" keyProperty="id">
  74. insert into mall_topic(
  75. `title`,
  76. `content`,
  77. `avatar`,
  78. `item_pic_url`,
  79. `subtitle`,
  80. `topic_category_id`,
  81. `price_info`,
  82. `read_count`,
  83. `scene_pic_url`,
  84. `topic_template_id`,
  85. `topic_tag_id`)
  86. values(
  87. #{title},
  88. #{content},
  89. #{avatar},
  90. #{itemPicUrl},
  91. #{subtitle},
  92. #{topicCategoryId},
  93. #{priceInfo},
  94. #{readCount},
  95. #{scenePicUrl},
  96. #{topicTemplateId},
  97. #{topicTagId})
  98. </insert>
  99. <update id="update" parameterType="com.kmall.admin.entity.TopicEntity">
  100. update mall_topic
  101. <set>
  102. <if test="title != null">`title` = #{title},</if>
  103. <if test="content != null">`content` = #{content},</if>
  104. <if test="avatar != null">`avatar` = #{avatar},</if>
  105. <if test="itemPicUrl != null">`item_pic_url` = #{itemPicUrl},</if>
  106. <if test="subtitle != null">`subtitle` = #{subtitle},</if>
  107. <if test="topicCategoryId != null">`topic_category_id` = #{topicCategoryId},</if>
  108. <if test="priceInfo != null">`price_info` = #{priceInfo},</if>
  109. <if test="readCount != null">`read_count` = #{readCount},</if>
  110. <if test="scenePicUrl != null">`scene_pic_url` = #{scenePicUrl},</if>
  111. <if test="topicTemplateId != null">`topic_template_id` = #{topicTemplateId},</if>
  112. <if test="topicTagId != null">`topic_tag_id` = #{topicTagId}</if>
  113. </set>
  114. where id = #{id}
  115. </update>
  116. <delete id="delete">
  117. delete from mall_topic where id = #{value}
  118. </delete>
  119. <delete id="deleteBatch">
  120. delete from mall_topic where id in
  121. <foreach item="id" collection="array" open="(" separator="," close=")">
  122. #{id}
  123. </foreach>
  124. </delete>
  125. </mapper>