CartDao.xml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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.CartDao">
  4. <!-- 可根据自己的需求,是否要使用 -->
  5. <resultMap type="com.kmall.admin.entity.CartEntity" id="cartMap">
  6. <result property="id" column="id"/>
  7. <result property="userName" column="user_name"/>
  8. <result property="userId" column="user_id"/>
  9. <result property="goodsId" column="goods_id"/>
  10. <result property="goodsSn" column="goods_sn"/>
  11. <result property="productId" column="product_id"/>
  12. <result property="goodsName" column="goods_name"/>
  13. <result property="marketPrice" column="market_price"/>
  14. <result property="retailPrice" column="retail_price"/>
  15. <result property="number" column="number"/>
  16. <result property="goodsSpecificationNameValue" column="goods_specification_name_value"/>
  17. <result property="goodsSpecificationIds" column="goods_specification_ids"/>
  18. <result property="checked" column="checked"/>
  19. <result property="listPicUrl" column="list_pic_url"/>
  20. <result column="sku" property="sku" jdbcType="VARCHAR" />
  21. <result column="goods_biz_type" property="goodsBizType" jdbcType="CHAR" />
  22. <result column="creater_sn" property="createrSn" jdbcType="VARCHAR" />
  23. <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
  24. <result column="moder_sn" property="moderSn" jdbcType="VARCHAR" />
  25. <result column="mod_time" property="modTime" jdbcType="TIMESTAMP" />
  26. <result column="tstm" property="tstm" jdbcType="TIMESTAMP" />
  27. <result property="stockNum" column="productStockNum"/>
  28. <result property="storeName" column="store_name"/>
  29. </resultMap>
  30. <select id="queryObject" resultType="com.kmall.admin.entity.CartEntity">
  31. select * from mall_cart where id = #{value}
  32. </select>
  33. <select id="queryList" resultMap="cartMap">
  34. select a.* ,b.nickname as user_name
  35. from mall_cart a
  36. left join mall_user b on a.user_id = b.id
  37. where 1=1
  38. <if test="userId != null">
  39. AND a.user_id = #{userId}
  40. </if>
  41. <if test="goodsBizType != null">
  42. AND a.goods_biz_type = #{goodsBizType}
  43. </if>
  44. <choose>
  45. <when test="sidx != null and sidx.trim() != ''">
  46. order by ${sidx} ${order}
  47. </when>
  48. <otherwise>
  49. order by id desc
  50. </otherwise>
  51. </choose>
  52. <if test="offset != null and limit != null">
  53. limit #{offset}, #{limit}
  54. </if>
  55. </select>
  56. <select id="queryTotal" resultType="int">
  57. select count(*) from mall_cart where 1=1
  58. <if test="userId != null">
  59. AND mall_cart.user_id = #{userId}
  60. </if>
  61. </select>
  62. <insert id="save" parameterType="com.kmall.admin.entity.CartEntity" useGeneratedKeys="true" keyProperty="id">
  63. insert into mall_cart
  64. (
  65. `user_id`,
  66. `goods_id`,
  67. `goods_sn`,
  68. `product_id`,
  69. `goods_name`,
  70. `market_price`,
  71. `retail_price`,
  72. `number`,
  73. `goods_specification_name_value`,
  74. `goods_specification_ids`,
  75. `checked`,
  76. `list_pic_url`,
  77. `stock_num`,
  78. `store_id`,
  79. `sku`,
  80. `goods_biz_type`,
  81. `creater_sn`,
  82. `create_time`,
  83. `moder_sn`,
  84. `mod_time`
  85. )
  86. values
  87. (
  88. #{userId},
  89. #{goodsId},
  90. #{goodsSn},
  91. #{productId},
  92. #{goodsName},
  93. #{marketPrice},
  94. #{retailPrice},
  95. #{number},
  96. #{goodsSpecificationNameValue},
  97. #{goodsSpecificationIds},
  98. #{checked},
  99. #{listPicUrl},
  100. #{stockNum},
  101. #{storeId},
  102. #{sku},
  103. #{goodsBizType},
  104. #{createrSn},
  105. #{createTime},
  106. #{moderSn},
  107. #{modTime}
  108. )
  109. </insert>
  110. <update id="update" parameterType="com.kmall.admin.entity.CartEntity">
  111. update mall_cart
  112. <set>
  113. <if test="userId != null">`user_id` = #{userId},</if>
  114. <if test="goodsId != null">`goods_id` = #{goodsId},</if>
  115. <if test="goodsSn != null">`goods_sn` = #{goodsSn},</if>
  116. <if test="productId != null">`product_id` = #{productId},</if>
  117. <if test="goodsName != null">`goods_name` = #{goodsName},</if>
  118. <if test="marketPrice != null">`market_price` = #{marketPrice},</if>
  119. <if test="retailPrice != null">`retail_price` = #{retailPrice},</if>
  120. <if test="number != null">`number` = #{number},</if>
  121. <if test="goodsSpecificationNameValue != null">`goods_specification_name_value` =
  122. #{goodsSpecificationNameValue},
  123. </if>
  124. <if test="goodsSpecificationIds != null">`goods_specification_ids` = #{goodsSpecificationIds},</if>
  125. <if test="checked != null">`checked` = #{checked},</if>
  126. <if test="listPicUrl != null">`list_pic_url` = #{listPicUrl},</if>
  127. <if test="stockNum != null">`stock_num` = #{stockNum},</if>
  128. <if test="storeId != null">`store_id` = #{storeId},</if>
  129. <if test="goodsBizType != null">`goods_biz_type` = #{goodsBizType},</if>
  130. <if test="createrSn != null" >
  131. creater_sn = #{createrSn,jdbcType=VARCHAR},
  132. </if>
  133. <if test="createTime != null" >
  134. create_time = #{createTime,jdbcType=TIMESTAMP},
  135. </if>
  136. <if test="moderSn != null" >
  137. moder_sn = #{moderSn,jdbcType=VARCHAR},
  138. </if>
  139. <if test="modTime != null" >
  140. mod_time = #{modTime,jdbcType=TIMESTAMP}
  141. </if>
  142. </set>
  143. where id = #{id}
  144. </update>
  145. <delete id="delete">
  146. delete from mall_cart where id = #{value}
  147. </delete>
  148. <delete id="deleteBatch">
  149. delete from mall_cart where id in
  150. <foreach item="id" collection="array" open="(" separator="," close=")">
  151. #{id}
  152. </foreach>
  153. </delete>
  154. </mapper>