LiveCartMapper.xml 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.fs.live.mapper.LiveCartMapper">
  6. <resultMap type="LiveCart" id="LiveCartResult">
  7. <result property="cartId" column="cart_id" />
  8. <result property="liveId" column="live_id" />
  9. <result property="userId" column="user_id" />
  10. <result property="goodsId" column="goods_id" />
  11. <result property="productId" column="product_id" />
  12. <result property="productAttrValueId" column="product_attr_value_id" />
  13. <result property="cartNum" column="cart_num" />
  14. <result property="createTime" column="create_time" />
  15. <result property="updateTime" column="update_time" />
  16. <result property="isPay" column="is_pay" />
  17. <result property="isDel" column="is_del" />
  18. <result property="isBuy" column="is_buy" />
  19. <result property="checked" column="checked" />
  20. </resultMap>
  21. <sql id="selectLiveCartVo">
  22. select cart_id, live_id, user_id, goods_id, product_id, product_attr_value_id, cart_num, create_time, update_time, is_pay, is_del, is_buy, checked from live_cart
  23. </sql>
  24. <select id="selectLiveCartList" parameterType="LiveCart" resultMap="LiveCartResult">
  25. <include refid="selectLiveCartVo"/>
  26. <where>
  27. <if test="liveId != null "> and live_id = #{liveId}</if>
  28. <if test="userId != null and userId != ''"> and user_id = #{userId}</if>
  29. <if test="goodsId != null "> and goods_id = #{goodsId}</if>
  30. <if test="productId != null and productId != ''"> and product_id = #{productId}</if>
  31. <if test="productAttrValueId != null "> and product_attr_value_id = #{productAttrValueId}</if>
  32. <if test="cartNum != null and cartNum != ''"> and cart_num = #{cartNum}</if>
  33. <if test="isPay != null "> and is_pay = #{isPay}</if>
  34. <if test="isDel != null "> and is_del = #{isDel}</if>
  35. <if test="isBuy != null "> and is_buy = #{isBuy}</if>
  36. <if test="checked != null "> and checked = #{checked}</if>
  37. </where>
  38. </select>
  39. <select id="selectLiveCartListVo" parameterType="LiveCart" resultType="com.fs.live.vo.LiveCartVo">
  40. select a.cart_id, a.live_id, a.user_id, a.goods_id, a.product_id, a.product_attr_value_id, a.cart_num, a.create_time, a.update_time, a.is_pay, a.is_del, a.is_buy,a.checked,
  41. b.product_name, b.img_url,b.price, b.ot_price, b.stock,b.sales
  42. from live_cart a
  43. left join fs_store_product b on a.product_id = b.product_id
  44. <where>
  45. <if test="liveId != null "> and live_id = #{liveId}</if>
  46. <if test="userId != null and userId != ''"> and user_id = #{userId}</if>
  47. <if test="goodsId != null "> and goods_id = #{goodsId}</if>
  48. <if test="productId != null and productId != ''"> and product_id = #{productId}</if>
  49. <if test="productAttrValueId != null "> and product_attr_value_id = #{productAttrValueId}</if>
  50. <if test="cartNum != null and cartNum != ''"> and cart_num = #{cartNum}</if>
  51. <if test="isPay != null "> and is_pay = #{isPay}</if>
  52. <if test="isDel != null "> and is_del = #{isDel}</if>
  53. <if test="isBuy != null "> and is_buy = #{isBuy}</if>
  54. <if test="checked != null "> and checked = #{checked}</if>
  55. </where>
  56. </select>
  57. <select id="selectLiveCartByCartId" parameterType="Long" resultMap="LiveCartResult">
  58. <include refid="selectLiveCartVo"/>
  59. where cart_id = #{cartId}
  60. </select>
  61. <insert id="insertLiveCart" parameterType="LiveCart" useGeneratedKeys="true" keyProperty="cartId">
  62. insert into live_cart
  63. <trim prefix="(" suffix=")" suffixOverrides=",">
  64. <if test="liveId != null">live_id,</if>
  65. <if test="userId != null and userId != ''">user_id,</if>
  66. <if test="goodsId != null">goods_id,</if>
  67. <if test="productId != null and productId != ''">product_id,</if>
  68. <if test="productAttrValueId != null">product_attr_value_id,</if>
  69. <if test="cartNum != null and cartNum != ''">cart_num,</if>
  70. <if test="createTime != null">create_time,</if>
  71. <if test="updateTime != null">update_time,</if>
  72. <if test="isPay != null">is_pay,</if>
  73. <if test="isDel != null">is_del,</if>
  74. <if test="isBuy != null">is_buy,</if>
  75. <if test="checked != null">checked,</if>
  76. </trim>
  77. <trim prefix="values (" suffix=")" suffixOverrides=",">
  78. <if test="liveId != null">#{liveId},</if>
  79. <if test="userId != null and userId != ''">#{userId},</if>
  80. <if test="goodsId != null">#{goodsId},</if>
  81. <if test="productId != null and productId != ''">#{productId},</if>
  82. <if test="productAttrValueId != null">#{productAttrValueId},</if>
  83. <if test="cartNum != null and cartNum != ''">#{cartNum},</if>
  84. <if test="createTime != null">#{createTime},</if>
  85. <if test="updateTime != null">#{updateTime},</if>
  86. <if test="isPay != null">#{isPay},</if>
  87. <if test="isDel != null">#{isDel},</if>
  88. <if test="isBuy != null">#{isBuy},</if>
  89. <if test="checked != null">#{checked},</if>
  90. </trim>
  91. </insert>
  92. <update id="updateLiveCart" parameterType="LiveCart">
  93. update live_cart
  94. <trim prefix="SET" suffixOverrides=",">
  95. <if test="liveId != null">live_id = #{liveId},</if>
  96. <if test="userId != null and userId != ''">user_id = #{userId},</if>
  97. <if test="goodsId != null">goods_id = #{goodsId},</if>
  98. <if test="productId != null and productId != ''">product_id = #{productId},</if>
  99. <if test="productAttrValueId != null">product_attr_value_id = #{productAttrValueId},</if>
  100. <if test="cartNum != null and cartNum != ''">cart_num = #{cartNum},</if>
  101. <if test="createTime != null">create_time = #{createTime},</if>
  102. <if test="updateTime != null">update_time = #{updateTime},</if>
  103. <if test="isPay != null">is_pay = #{isPay},</if>
  104. <if test="isDel != null">is_del = #{isDel},</if>
  105. <if test="isBuy != null">is_buy = #{isBuy},</if>
  106. <if test="checked != null">checked = #{checked},</if>
  107. </trim>
  108. where cart_id = #{cartId}
  109. </update>
  110. <delete id="deleteLiveCartByCartId" parameterType="Long">
  111. delete from live_cart where cart_id = #{cartId}
  112. </delete>
  113. <delete id="deleteLiveCartByCartIds" parameterType="String">
  114. delete from live_cart where cart_id in
  115. <foreach item="cartId" collection="array" open="(" separator="," close=")">
  116. #{cartId}
  117. </foreach>
  118. </delete>
  119. <delete id="deleteByCartIdsAndUserId" parameterType="String">
  120. delete from live_cart where user_id = #{userId} and cart_id in
  121. <foreach item="cartId" collection="cartIds" open="(" separator="," close=")">
  122. #{cartId}
  123. </foreach>
  124. </delete>
  125. </mapper>