CommentDao.xml 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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.CommentDao">
  4. <resultMap type="com.kmall.admin.entity.CommentEntity" id="commentMap">
  5. <result property="id" column="id"/>
  6. <result property="typeId" column="type_id"/>
  7. <result property="valueId" column="value_id"/>
  8. <result property="userId" column="user_id"/>
  9. <result property="orderId" column="order_id"/>
  10. <result property="productId" column="product_id"/>
  11. <result property="goodsSpecificationNameValue" column="goods_specification_name_value"/>
  12. <result property="status" column="status"/>
  13. <result property="content" column="content"/>
  14. <result property="addTime" column="add_time"/>
  15. <result property="evalLevel" column="eval_level"/>
  16. <result property="deliveryLevel" column="delivery_level"/>
  17. <result property="goodsLevel" column="goods_level"/>
  18. </resultMap>
  19. <select id="queryObject" resultType="com.kmall.admin.entity.CommentEntity">
  20. select
  21. `id`,
  22. `type_id`,
  23. `value_id`,
  24. `user_id`,
  25. `order_id`,
  26. `product_id`,
  27. `goods_specification_name_value`,
  28. `status`,
  29. `content`,
  30. `add_time`,
  31. `eval_level`,
  32. `delivery_level`,
  33. `goods_level`
  34. from mall_comment
  35. where id = #{id}
  36. </select>
  37. <select id="queryList" resultType="com.kmall.admin.entity.CommentEntity">
  38. select
  39. mall_comment.id,
  40. mall_comment.type_id,
  41. mall_comment.value_id,
  42. mall_comment.user_id,
  43. mall_comment.order_id,
  44. mall_comment.product_id,
  45. mall_comment.goods_specification_name_value,
  46. mall_comment.status,
  47. mall_comment.content,
  48. mall_comment.add_time,
  49. mall_comment.eval_level,
  50. mall_comment.delivery_level,
  51. mall_comment.goods_level,
  52. mall_user.username user_name,
  53. mall_goods.name value_name
  54. from mall_comment LEFT JOIN mall_user ON mall_comment.user_id = mall_user.id
  55. LEFT JOIN mall_goods ON mall_comment.value_id = mall_goods.id
  56. left join mall_order o on mall_comment.order_id = o.id
  57. WHERE 1=1
  58. <if test="userName != null and userName.trim() != ''">
  59. AND mall_user.username LIKE concat('%',#{userName},'%')
  60. </if>
  61. <if test="valueName != null and valueName.trim() != ''">
  62. AND mall_goods.name LIKE concat('%',#{valueName},'%')
  63. </if>
  64. <if test="storeId != null and storeId != ''">
  65. AND o.store_id = #{storeId}
  66. </if>
  67. <if test="status != null">
  68. AND mall_comment.status = #{status}
  69. </if>
  70. <if test="orderId != null">
  71. AND mall_comment.order_id = #{orderId}
  72. </if>
  73. <if test="picUrl == 'true'">
  74. AND EXISTS(SELECT 1 FROM mall_comment_picture WHERE mall_comment.id = mall_comment_picture.comment_id)
  75. </if>
  76. <choose>
  77. <when test="sidx != null and sidx.trim() != ''">
  78. order by ${sidx} ${order}
  79. </when>
  80. <otherwise>
  81. order by mall_comment.id desc
  82. </otherwise>
  83. </choose>
  84. <if test="offset != null and limit != null">
  85. limit #{offset}, #{limit}
  86. </if>
  87. </select>
  88. <select id="queryTotal" resultType="int">
  89. select count(*) from mall_comment LEFT JOIN mall_user ON mall_comment.user_id = mall_user.id
  90. LEFT JOIN mall_goods ON mall_comment.value_id = mall_goods.id
  91. WHERE 1=1
  92. <if test="userName != null and userName.trim() != ''">
  93. AND mall_user.username LIKE concat('%',#{userName},'%')
  94. </if>
  95. <if test="valueName != null and valueName.trim() != ''">
  96. AND mall_goods.name LIKE concat('%',#{valueName},'%')
  97. </if>
  98. <if test="status != null">
  99. AND mall_comment.status = #{status}
  100. </if>
  101. <if test="orderId != null">
  102. AND mall_comment.order_id = #{orderId}
  103. </if>
  104. <if test="picUrl == 'true'">
  105. AND EXISTS(SELECT 1 FROM mall_comment_picture WHERE mall_comment.id = mall_comment_picture.comment_id)
  106. </if>
  107. </select>
  108. <insert id="save" parameterType="com.kmall.admin.entity.CommentEntity" useGeneratedKeys="true" keyProperty="id">
  109. insert into mall_comment(
  110. `type_id`,
  111. `value_id`,
  112. `user_id`,
  113. `order_id`,
  114. `product_id`,
  115. `goods_specification_name_value`,
  116. `status`,
  117. `content`,
  118. `add_time`,
  119. `eval_level`,
  120. `delivery_level`,
  121. `goods_level`)
  122. values(
  123. #{typeId},
  124. #{valueId},
  125. #{userId},
  126. #{orderId},
  127. #{productId},
  128. #{goodsSpecificationNameValue},
  129. #{status},
  130. #{content},
  131. #{addTime},
  132. #{evalLevel},
  133. #{deliveryLevel},
  134. #{goodsLevel})
  135. </insert>
  136. <update id="update" parameterType="com.kmall.admin.entity.CommentEntity">
  137. update mall_comment
  138. <set>
  139. <if test="typeId != null">`type_id` = #{typeId}, </if>
  140. <if test="valueId != null">`value_id` = #{valueId}, </if>
  141. <if test="userId != null">`user_id` = #{userId}, </if>
  142. <if test="orderId != null">`order_id` = #{orderId}, </if>
  143. <if test="productId != null">`product_id` = #{productId}, </if>
  144. <if test="goodsSpecificationNameValue != null">`goods_specification_name_value` = #{goodsSpecificationNameValue}, </if>
  145. <if test="status != null">`status` = #{status}, </if>
  146. <if test="content != null">`content` = #{content}, </if>
  147. <if test="addTime != null">`add_time` = #{addTime}, </if>
  148. <if test="evalLevel != null">`eval_level` = #{evalLevel}, </if>
  149. <if test="deliveryLevel != null">`delivery_level` = #{deliveryLevel}, </if>
  150. <if test="goodsLevel != null">`goods_level` = #{goodsLevel}</if>
  151. </set>
  152. where id = #{id}
  153. </update>
  154. <delete id="delete">
  155. delete from mall_comment where id = #{value}
  156. </delete>
  157. <delete id="deleteBatch">
  158. delete from mall_comment where id in
  159. <foreach item="id" collection="array" open="(" separator="," close=")">
  160. #{id}
  161. </foreach>
  162. </delete>
  163. </mapper>