CommentDao.xml 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. left join mall_store s on o.store_id = s.id
  58. WHERE 1=1
  59. <if test="userName != null and userName.trim() != ''">
  60. AND mall_user.username LIKE concat('%',#{userName},'%')
  61. </if>
  62. <if test="valueName != null and valueName.trim() != ''">
  63. AND mall_goods.name LIKE concat('%',#{valueName},'%')
  64. </if>
  65. <if test="storeId != null and storeId != ''">
  66. AND o.store_id = #{storeId}
  67. </if>
  68. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  69. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  70. </if>
  71. <if test="status != null">
  72. AND mall_comment.status = #{status}
  73. </if>
  74. <if test="orderId != null">
  75. AND mall_comment.order_id = #{orderId}
  76. </if>
  77. <if test="picUrl == 'true'">
  78. AND EXISTS(SELECT 1 FROM mall_comment_picture WHERE mall_comment.id = mall_comment_picture.comment_id)
  79. </if>
  80. <choose>
  81. <when test="sidx != null and sidx.trim() != ''">
  82. order by ${sidx} ${order}
  83. </when>
  84. <otherwise>
  85. order by mall_comment.id desc
  86. </otherwise>
  87. </choose>
  88. <if test="offset != null and limit != null">
  89. limit #{offset}, #{limit}
  90. </if>
  91. </select>
  92. <select id="queryTotal" resultType="int">
  93. select count(*) from mall_comment LEFT JOIN mall_user ON mall_comment.user_id = mall_user.id
  94. LEFT JOIN mall_goods ON mall_comment.value_id = mall_goods.id
  95. left join mall_order o on mall_comment.order_id = o.id
  96. left join mall_store s on o.store_id = s.id
  97. WHERE 1=1
  98. <if test="userName != null and userName.trim() != ''">
  99. AND mall_user.username LIKE concat('%',#{userName},'%')
  100. </if>
  101. <if test="valueName != null and valueName.trim() != ''">
  102. AND mall_goods.name LIKE concat('%',#{valueName},'%')
  103. </if>
  104. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  105. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  106. </if>
  107. <if test="status != null">
  108. AND mall_comment.status = #{status}
  109. </if>
  110. <if test="orderId != null">
  111. AND mall_comment.order_id = #{orderId}
  112. </if>
  113. <if test="picUrl == 'true'">
  114. AND EXISTS(SELECT 1 FROM mall_comment_picture WHERE mall_comment.id = mall_comment_picture.comment_id)
  115. </if>
  116. </select>
  117. <insert id="save" parameterType="com.kmall.admin.entity.CommentEntity" useGeneratedKeys="true" keyProperty="id">
  118. insert into mall_comment(
  119. `type_id`,
  120. `value_id`,
  121. `user_id`,
  122. `order_id`,
  123. `product_id`,
  124. `goods_specification_name_value`,
  125. `status`,
  126. `content`,
  127. `add_time`,
  128. `eval_level`,
  129. `delivery_level`,
  130. `goods_level`)
  131. values(
  132. #{typeId},
  133. #{valueId},
  134. #{userId},
  135. #{orderId},
  136. #{productId},
  137. #{goodsSpecificationNameValue},
  138. #{status},
  139. #{content},
  140. #{addTime},
  141. #{evalLevel},
  142. #{deliveryLevel},
  143. #{goodsLevel})
  144. </insert>
  145. <update id="update" parameterType="com.kmall.admin.entity.CommentEntity">
  146. update mall_comment
  147. <set>
  148. <if test="typeId != null">`type_id` = #{typeId}, </if>
  149. <if test="valueId != null">`value_id` = #{valueId}, </if>
  150. <if test="userId != null">`user_id` = #{userId}, </if>
  151. <if test="orderId != null">`order_id` = #{orderId}, </if>
  152. <if test="productId != null">`product_id` = #{productId}, </if>
  153. <if test="goodsSpecificationNameValue != null">`goods_specification_name_value` = #{goodsSpecificationNameValue}, </if>
  154. <if test="status != null">`status` = #{status}, </if>
  155. <if test="content != null">`content` = #{content}, </if>
  156. <if test="addTime != null">`add_time` = #{addTime}, </if>
  157. <if test="evalLevel != null">`eval_level` = #{evalLevel}, </if>
  158. <if test="deliveryLevel != null">`delivery_level` = #{deliveryLevel}, </if>
  159. <if test="goodsLevel != null">`goods_level` = #{goodsLevel}</if>
  160. </set>
  161. where id = #{id}
  162. </update>
  163. <delete id="delete">
  164. delete from mall_comment where id = #{value}
  165. </delete>
  166. <delete id="deleteBatch">
  167. delete from mall_comment where id in
  168. <foreach item="id" collection="array" open="(" separator="," close=")">
  169. #{id}
  170. </foreach>
  171. </delete>
  172. </mapper>