1
0

ApiFootprintMapper.xml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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.api.dao.ApiFootprintMapper">
  4. <!-- 可根据自己的需求,是否要使用 -->
  5. <resultMap type="com.kmall.api.entity.FootprintVo" id="footprintMap">
  6. <result property="id" column="id"/>
  7. <result property="user_id" column="user_id"/>
  8. <result property="goods_id" column="goods_id"/>
  9. <result property="add_time" column="add_time"/>
  10. <result property="name" column="name"/>
  11. <result property="list_pic_url" column="list_pic_url"/>
  12. <result property="goods_brief" column="goods_brief"/>
  13. <result property="retail_price" column="retail_price"/>
  14. <result property="referrer" column="referrer"/>
  15. <result property="nickname" column="nickname"/>
  16. <result property="avatar" column="avatar"/>
  17. </resultMap>
  18. <select id="queryObject" resultMap="footprintMap">
  19. select f.id,f.user_id,f.goods_id,f.add_time add_time,f.referrer from mall_footprint f where id = #{value}
  20. </select>
  21. <select id="queryList" resultMap="footprintMap">
  22. select f.id,f.user_id,f.goods_id,f.add_time add_time,f.referrer,
  23. g.name as name, g.list_pic_url as list_pic_url, g.goods_brief as goods_brief, psr.retail_price as
  24. retail_price
  25. from mall_footprint f
  26. <if test="maxFoot == true">
  27. left join mall_footprint max on f.goods_id = max.goods_id and f.user_id = max.user_id
  28. and max.add_time > f.add_time
  29. </if>
  30. left join mall_goods g on f.goods_id = g.id
  31. LEFT JOIN mall_product_store_rela psr ON psr.goods_id = g.id and g.merch_sn = psr.merch_sn
  32. <where>
  33. 1=1 and psr.stock_num >0 and g.is_delete = 0 and g.is_on_sale = 1
  34. <if test="user_id != null">
  35. and f.user_id = #{user_id}
  36. </if>
  37. <if test="maxFoot == true">
  38. and max.id is null
  39. </if>
  40. <if test="bizType == true">
  41. <if test="checkCart != null and checkCart == '00'">
  42. and g.goods_biz_type = '00'
  43. </if>
  44. <if test="checkCart != null and checkCart == '11'">
  45. and g.goods_biz_type = '11'
  46. </if>
  47. </if>
  48. <if test="store_id != null and store_id != ''">
  49. and psr.store_id = #{store_id}
  50. </if>
  51. </where>
  52. <choose>
  53. <when test="sidx != null and sidx.trim() != ''">
  54. order by ${sidx} ${order}
  55. </when>
  56. <otherwise>
  57. order by f.id desc
  58. </otherwise>
  59. </choose>
  60. <if test="offset != null and limit != null">
  61. limit #{offset}, #{limit}
  62. </if>
  63. </select>
  64. <select id="queryTotal" resultType="int">
  65. select count(*) from mall_footprint f
  66. <where>
  67. <if test="user_id != null">
  68. and f.user_id = #{user_id}
  69. </if>
  70. <if test="goods_id != null">
  71. and f.goods_id = #{goods_id}
  72. </if>
  73. <if test="referrer != null">
  74. and f.referrer = #{referrer}
  75. </if>
  76. </where>
  77. </select>
  78. <insert id="save" parameterType="com.kmall.api.entity.FootprintVo" useGeneratedKeys="true" keyProperty="id">
  79. insert into mall_footprint
  80. (
  81. `user_id`,
  82. `goods_id`,
  83. `add_time`,
  84. `referrer`
  85. )
  86. values
  87. (
  88. #{user_id},
  89. #{goods_id},
  90. #{add_time},
  91. #{referrer}
  92. )
  93. </insert>
  94. <update id="update" parameterType="com.kmall.api.entity.FootprintVo">
  95. update mall_footprint
  96. <set>
  97. <if test="user_id != null">`user_id` = #{user_id},</if>
  98. <if test="goods_id != null">`goods_id` = #{goods_id},</if>
  99. <if test="add_time != null">`add_time` = #{add_time}</if>
  100. <if test="referrer != null">`referrer` = #{referrer}</if>
  101. </set>
  102. where id = #{id}
  103. </update>
  104. <delete id="delete">
  105. delete from mall_footprint where id = #{value}
  106. </delete>
  107. <delete id="deleteByParam">
  108. delete from mall_footprint
  109. where 1 = 1
  110. <if test="userId != null">and `user_id` = #{userId},</if>
  111. <if test="goodsId != null">and `goods_id` = #{goodsId},</if>
  112. </delete>
  113. <delete id="deleteBatch">
  114. delete from mall_footprint where id in
  115. <foreach item="id" collection="array" open="(" separator="," close=")">
  116. #{id}
  117. </foreach>
  118. </delete>
  119. <select id="shareList" resultMap="footprintMap">
  120. select f.id,f.user_id,f.goods_id,f.add_time add_time,f.referrer,
  121. g.name as name, g.list_pic_url as list_pic_url, g.goods_brief as goods_brief,
  122. psr.retail_price as retail_price,
  123. u.nickname as nickname,u.avatar as avatar
  124. from mall_footprint f
  125. left join mall_goods g on f.goods_id = g.id
  126. left join mall_user u on u.id = f.user_id
  127. LEFT JOIN mall_product_store_rela psr ON psr.goods_id = g.id
  128. <where>
  129. u.id is not null
  130. <if test="user_id != null">
  131. and f.user_id = #{user_id}
  132. </if>
  133. <if test="referrer != null">
  134. and f.referrer = #{referrer}
  135. </if>
  136. <if test="store_id != null and store_id != ''">
  137. and psr.store_id = #{store_id}
  138. </if>
  139. </where>
  140. <choose>
  141. <when test="sidx != null and sidx.trim() != ''">
  142. order by ${sidx} ${order}
  143. </when>
  144. <otherwise>
  145. order by f.id desc
  146. </otherwise>
  147. </choose>
  148. <if test="offset != null and limit != null">
  149. limit #{offset}, #{limit}
  150. </if>
  151. </select>
  152. </mapper>