ApiFootprintMapper.xml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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.product_id = g.primary_product_id
  32. <where>
  33. <if test="user_id != null">
  34. and f.user_id = #{user_id}
  35. </if>
  36. <if test="maxFoot == true">
  37. and max.id is null
  38. </if>
  39. <if test="bizType == true">
  40. and g.goods_biz_type in ('00','11')
  41. </if>
  42. <if test="store_id != null and store_id != ''">
  43. and psr.store_id = #{store_id}
  44. </if>
  45. </where>
  46. <choose>
  47. <when test="sidx != null and sidx.trim() != ''">
  48. order by ${sidx} ${order}
  49. </when>
  50. <otherwise>
  51. order by f.id desc
  52. </otherwise>
  53. </choose>
  54. <if test="offset != null and limit != null">
  55. limit #{offset}, #{limit}
  56. </if>
  57. </select>
  58. <select id="queryTotal" resultType="int">
  59. select count(*) from mall_footprint f
  60. <where>
  61. <if test="user_id != null">
  62. and f.user_id = #{user_id}
  63. </if>
  64. <if test="goods_id != null">
  65. and f.goods_id = #{goods_id}
  66. </if>
  67. <if test="referrer != null">
  68. and f.referrer = #{referrer}
  69. </if>
  70. </where>
  71. </select>
  72. <insert id="save" parameterType="com.kmall.api.entity.FootprintVo" useGeneratedKeys="true" keyProperty="id">
  73. insert into mall_footprint
  74. (
  75. `user_id`,
  76. `goods_id`,
  77. `add_time`,
  78. `referrer`
  79. )
  80. values
  81. (
  82. #{user_id},
  83. #{goods_id},
  84. #{add_time},
  85. #{referrer}
  86. )
  87. </insert>
  88. <update id="update" parameterType="com.kmall.api.entity.FootprintVo">
  89. update mall_footprint
  90. <set>
  91. <if test="user_id != null">`user_id` = #{user_id},</if>
  92. <if test="goods_id != null">`goods_id` = #{goods_id},</if>
  93. <if test="add_time != null">`add_time` = #{add_time}</if>
  94. <if test="referrer != null">`referrer` = #{referrer}</if>
  95. </set>
  96. where id = #{id}
  97. </update>
  98. <delete id="delete">
  99. delete from mall_footprint where id = #{value}
  100. </delete>
  101. <delete id="deleteByParam">
  102. delete from mall_footprint
  103. where 1 = 1
  104. <if test="userId != null">and `user_id` = #{userId},</if>
  105. <if test="goodsId != null">and `goods_id` = #{goodsId},</if>
  106. </delete>
  107. <delete id="deleteBatch">
  108. delete from mall_footprint where id in
  109. <foreach item="id" collection="array" open="(" separator="," close=")">
  110. #{id}
  111. </foreach>
  112. </delete>
  113. <select id="shareList" resultMap="footprintMap">
  114. select f.id,f.user_id,f.goods_id,f.add_time add_time,f.referrer,
  115. g.name as name, g.list_pic_url as list_pic_url, g.goods_brief as goods_brief,
  116. psr.retail_price as retail_price,
  117. u.nickname as nickname,u.avatar as avatar
  118. from mall_footprint f
  119. left join mall_goods g on f.goods_id = g.id
  120. left join mall_user u on u.id = f.user_id
  121. LEFT JOIN mall_product_store_rela psr ON psr.product_id = g.primary_product_id
  122. <where>
  123. u.id is not null
  124. <if test="user_id != null">
  125. and f.user_id = #{user_id}
  126. </if>
  127. <if test="referrer != null">
  128. and f.referrer = #{referrer}
  129. </if>
  130. <if test="store_id != null and store_id != ''">
  131. and psr.store_id = #{store_id}
  132. </if>
  133. </where>
  134. <choose>
  135. <when test="sidx != null and sidx.trim() != ''">
  136. order by ${sidx} ${order}
  137. </when>
  138. <otherwise>
  139. order by f.id desc
  140. </otherwise>
  141. </choose>
  142. <if test="offset != null and limit != null">
  143. limit #{offset}, #{limit}
  144. </if>
  145. </select>
  146. </mapper>