LiveGoodsMapper.xml 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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.LiveGoodsMapper">
  6. <resultMap type="LiveGoods" id="LiveGoodsResult">
  7. <result property="goodsId" column="goods_id" />
  8. <result property="liveId" column="live_id" />
  9. <result property="companyId" column="company_id" />
  10. <result property="companyUserId" column="company_user_id" />
  11. <result property="storeId" column="store_id" />
  12. <result property="productId" column="product_id" />
  13. <result property="createTime" column="create_time" />
  14. <result property="createBy" column="create_by" />
  15. <result property="updateBy" column="update_by" />
  16. <result property="updateTime" column="update_time" />
  17. <result property="remark" column="remark" />
  18. <result property="status" column="status" />
  19. <result property="stock" column="stock" />
  20. <result property="sort" column="sort" />
  21. </resultMap>
  22. <sql id="selectLiveGoodsVo">
  23. select goods_id, live_id, company_id, company_user_id, store_id, product_id, create_time, create_by, update_by, update_time, remark, status, stock, sort from live_goods
  24. </sql>
  25. <select id="selectLiveGoodsList" parameterType="LiveGoods" resultMap="LiveGoodsResult">
  26. <include refid="selectLiveGoodsVo"/>
  27. <where>
  28. <if test="liveId != null "> and live_id = #{liveId}</if>
  29. <if test="companyId != null "> and company_id = #{companyId}</if>
  30. <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
  31. <if test="storeId != null "> and store_id = #{storeId}</if>
  32. <if test="productId != null "> and product_id = #{productId}</if>
  33. <if test="status != null "> and status = #{status}</if>
  34. <if test="stock != null "> and stock = #{stock}</if>
  35. <if test="sort != null "> and sort = #{sort}</if>
  36. </where>
  37. </select>
  38. <select id="selectLiveGoodsByGoodsId" parameterType="Long" resultMap="LiveGoodsResult">
  39. <include refid="selectLiveGoodsVo"/>
  40. where goods_id = #{goodsId}
  41. </select>
  42. <insert id="insertLiveGoods" parameterType="LiveGoods" useGeneratedKeys="true" keyProperty="goodsId">
  43. insert into live_goods
  44. <trim prefix="(" suffix=")" suffixOverrides=",">
  45. <if test="liveId != null">live_id,</if>
  46. <if test="companyId != null">company_id,</if>
  47. <if test="companyUserId != null">company_user_id,</if>
  48. <if test="storeId != null">store_id,</if>
  49. <if test="productId != null">product_id,</if>
  50. <if test="createTime != null">create_time,</if>
  51. <if test="createBy != null">create_by,</if>
  52. <if test="updateBy != null">update_by,</if>
  53. <if test="updateTime != null">update_time,</if>
  54. <if test="remark != null">remark,</if>
  55. <if test="status != null">status,</if>
  56. <if test="stock != null">stock,</if>
  57. <if test="sort != null">sort,</if>
  58. </trim>
  59. <trim prefix="values (" suffix=")" suffixOverrides=",">
  60. <if test="liveId != null">#{liveId},</if>
  61. <if test="companyId != null">#{companyId},</if>
  62. <if test="companyUserId != null">#{companyUserId},</if>
  63. <if test="storeId != null">#{storeId},</if>
  64. <if test="productId != null">#{productId},</if>
  65. <if test="createTime != null">#{createTime},</if>
  66. <if test="createBy != null">#{createBy},</if>
  67. <if test="updateBy != null">#{updateBy},</if>
  68. <if test="updateTime != null">#{updateTime},</if>
  69. <if test="remark != null">#{remark},</if>
  70. <if test="status != null">#{status},</if>
  71. <if test="stock != null">#{stock},</if>
  72. <if test="sort != null">#{sort},</if>
  73. </trim>
  74. </insert>
  75. <update id="updateLiveGoods" parameterType="LiveGoods">
  76. update live_goods
  77. <trim prefix="SET" suffixOverrides=",">
  78. <if test="liveId != null">live_id = #{liveId},</if>
  79. <if test="companyId != null">company_id = #{companyId},</if>
  80. <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
  81. <if test="storeId != null">store_id = #{storeId},</if>
  82. <if test="productId != null">product_id = #{productId},</if>
  83. <if test="createTime != null">create_time = #{createTime},</if>
  84. <if test="createBy != null">create_by = #{createBy},</if>
  85. <if test="updateBy != null">update_by = #{updateBy},</if>
  86. <if test="updateTime != null">update_time = #{updateTime},</if>
  87. <if test="remark != null">remark = #{remark},</if>
  88. <if test="status != null">status = #{status},</if>
  89. <if test="stock != null">stock = #{stock},</if>
  90. <if test="sort != null">sort = #{sort},</if>
  91. </trim>
  92. where goods_id = #{goodsId}
  93. </update>
  94. <delete id="deleteLiveGoodsByGoodsId" parameterType="Long">
  95. delete from live_goods where goods_id = #{goodsId}
  96. </delete>
  97. <delete id="deleteLiveGoodsByGoodsIds" parameterType="String">
  98. delete from live_goods where goods_id in
  99. <foreach item="goodsId" collection="array" open="(" separator="," close=")">
  100. #{goodsId}
  101. </foreach>
  102. </delete>
  103. <select id="selectStoreIdByLiveId" parameterType="Long" resultType="Long">
  104. select distinct store_id from live_goods where live_id = #{liveId}
  105. </select>
  106. <insert id="insertLiveGoodsList">
  107. INSERT INTO live_goods (
  108. live_id, company_id, company_user_id, store_id,
  109. product_id, create_time, create_by, update_by,
  110. update_time, remark, status, stock, sort
  111. ) VALUES
  112. <foreach collection="liveGoodsList" item="item" separator=",">
  113. (
  114. #{item.liveId}, #{item.companyId}, #{item.companyUserId}, #{item.storeId},
  115. #{item.productId}, #{item.createTime}, #{item.createBy}, #{item.updateBy},
  116. #{item.updateTime}, #{item.remark}, #{item.status}, #{item.stock}, #{item.sort}
  117. )
  118. </foreach>
  119. </insert>
  120. <select id="selectProductIdsByLiveId" resultType="string">
  121. SELECT product_id
  122. FROM live_goods
  123. WHERE live_id = #{liveId}
  124. </select>
  125. <select id="selectProductListByLiveId" parameterType="LiveGoods" resultType="com.fs.live.vo.LiveGoodsVo">
  126. select lg.goods_id,sp.img_url,sp.product_name,sp.price,sp.stock,sp.sales from live_goods lg
  127. LEFT JOIN fs_store_product sp
  128. ON lg.store_id = sp.store_id AND lg.product_id = sp.product_id
  129. <where>
  130. <if test="liveId != null "> and live_id = #{liveId}</if>
  131. <if test="companyId != null "> and company_id = #{companyId}</if>
  132. <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
  133. <if test="storeId != null "> and store_id = #{storeId}</if>
  134. <if test="productId != null "> and product_id = #{productId}</if>
  135. <if test="status != null "> and status = #{status}</if>
  136. <if test="stock != null "> and stock = #{stock}</if>
  137. <if test="sort != null "> and sort = #{sort}</if>
  138. </where>
  139. </select>
  140. </mapper>