LiveCartMapper.xml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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="cardId" column="card_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. </resultMap>
  20. <sql id="selectLiveCartVo">
  21. select card_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 from live_cart
  22. </sql>
  23. <select id="selectLiveCartList" parameterType="LiveCart" resultMap="LiveCartResult">
  24. <include refid="selectLiveCartVo"/>
  25. <where>
  26. <if test="liveId != null "> and live_id = #{liveId}</if>
  27. <if test="userId != null and userId != ''"> and user_id = #{userId}</if>
  28. <if test="goodsId != null "> and goods_id = #{goodsId}</if>
  29. <if test="productId != null and productId != ''"> and product_id = #{productId}</if>
  30. <if test="productAttrValueId != null "> and product_attr_value_id = #{productAttrValueId}</if>
  31. <if test="cartNum != null and cartNum != ''"> and cart_num = #{cartNum}</if>
  32. <if test="isPay != null "> and is_pay = #{isPay}</if>
  33. <if test="isDel != null "> and is_del = #{isDel}</if>
  34. <if test="isBuy != null "> and is_buy = #{isBuy}</if>
  35. </where>
  36. </select>
  37. <select id="selectLiveCartByCardId" parameterType="Long" resultMap="LiveCartResult">
  38. <include refid="selectLiveCartVo"/>
  39. where card_id = #{cardId}
  40. </select>
  41. <insert id="insertLiveCart" parameterType="LiveCart" useGeneratedKeys="true" keyProperty="cardId">
  42. insert into live_cart
  43. <trim prefix="(" suffix=")" suffixOverrides=",">
  44. <if test="liveId != null">live_id,</if>
  45. <if test="userId != null and userId != ''">user_id,</if>
  46. <if test="goodsId != null">goods_id,</if>
  47. <if test="productId != null and productId != ''">product_id,</if>
  48. <if test="productAttrValueId != null">product_attr_value_id,</if>
  49. <if test="cartNum != null and cartNum != ''">cart_num,</if>
  50. <if test="createTime != null">create_time,</if>
  51. <if test="updateTime != null">update_time,</if>
  52. <if test="isPay != null">is_pay,</if>
  53. <if test="isDel != null">is_del,</if>
  54. <if test="isBuy != null">is_buy,</if>
  55. </trim>
  56. <trim prefix="values (" suffix=")" suffixOverrides=",">
  57. <if test="liveId != null">#{liveId},</if>
  58. <if test="userId != null and userId != ''">#{userId},</if>
  59. <if test="goodsId != null">#{goodsId},</if>
  60. <if test="productId != null and productId != ''">#{productId},</if>
  61. <if test="productAttrValueId != null">#{productAttrValueId},</if>
  62. <if test="cartNum != null and cartNum != ''">#{cartNum},</if>
  63. <if test="createTime != null">#{createTime},</if>
  64. <if test="updateTime != null">#{updateTime},</if>
  65. <if test="isPay != null">#{isPay},</if>
  66. <if test="isDel != null">#{isDel},</if>
  67. <if test="isBuy != null">#{isBuy},</if>
  68. </trim>
  69. </insert>
  70. <update id="updateLiveCart" parameterType="LiveCart">
  71. update live_cart
  72. <trim prefix="SET" suffixOverrides=",">
  73. <if test="liveId != null">live_id = #{liveId},</if>
  74. <if test="userId != null and userId != ''">user_id = #{userId},</if>
  75. <if test="goodsId != null">goods_id = #{goodsId},</if>
  76. <if test="productId != null and productId != ''">product_id = #{productId},</if>
  77. <if test="productAttrValueId != null">product_attr_value_id = #{productAttrValueId},</if>
  78. <if test="cartNum != null and cartNum != ''">cart_num = #{cartNum},</if>
  79. <if test="createTime != null">create_time = #{createTime},</if>
  80. <if test="updateTime != null">update_time = #{updateTime},</if>
  81. <if test="isPay != null">is_pay = #{isPay},</if>
  82. <if test="isDel != null">is_del = #{isDel},</if>
  83. <if test="isBuy != null">is_buy = #{isBuy},</if>
  84. </trim>
  85. where card_id = #{cardId}
  86. </update>
  87. <delete id="deleteLiveCartByCardId" parameterType="Long">
  88. delete from live_cart where card_id = #{cardId}
  89. </delete>
  90. <delete id="deleteLiveCartByCardIds" parameterType="String">
  91. delete from live_cart where card_id in
  92. <foreach item="cardId" collection="array" open="(" separator="," close=")">
  93. #{cardId}
  94. </foreach>
  95. </delete>
  96. </mapper>