yujian
2019-09-02 9eeda0d3049b71877c373c04d65533939b5582ef
fanli/src/main/java/com/yeshi/fanli/mapping/user/UserGoodsStorageMapper.xml
@@ -51,17 +51,62 @@
    </set> where guc_id = #{id,jdbcType=BIGINT}
  </update>
  
   <insert id="insertBatch"  useGeneratedKeys="true" keyProperty="id"  parameterType="java.util.List">
        insert into yeshi_ec_user_goods_storage
        (<include refid="Base_Column_List" />)
       values
        <foreach collection="list" item="item" separator=",">
            (
             #{item.id,jdbcType=BIGINT},
             #{item.commonGoods.id,jdbcType=BIGINT},
             #{item.uid,jdbcType=BIGINT},
             #{item.state,jdbcType=INTEGER},
             #{item.createTime.id,jdbcType=TIMESTAMP},
             #{item.updateTime,jdbcType=TIMESTAMP}
           )
        </foreach>
  </insert>
     <update id="updateBatchSelective" parameterType="java.util.List">
        update yeshi_ec_user_goods_storage
        <trim prefix="set" suffixOverrides=",">
             <trim prefix="guc_state =case" suffix="end,">
                <foreach collection="list" item="item" index="index">
                      <if test="item.state !=null">
                     when guc_id=#{item.id} then #{item.state}
                     </if>
                </foreach>
            </trim>
             <trim prefix="guc_updatetime =case" suffix="end,">
                <foreach collection="list" item="item" index="index">
                      <if test="item.updateTime !=null">
                     when guc_id=#{item.id} then #{item.updateTime}
                     </if>
                </foreach>
            </trim>
        </trim>
        where guc_id in
        <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
            #{item.id,jdbcType=BIGINT}
        </foreach>
    </update>
  <select id="listQueryByUid" resultMap="BaseResultMap">
    SELECT * FROM yeshi_ec_user_goods_storage  tg
    LEFT JOIN  `yeshi_ec_common_goods` cg ON tg.`guc_common_id` = cg.`cg_id`
    WHERE tg.`guc_uid` = #{uid}
    ORDER BY tg.`guc_updatetime` DESC
    WHERE tg.`guc_uid` = #{uid} <if test="gooodsType != null">AND cg.cg_goods_type = #{gooodsType}</if>
    ORDER BY  cg.cg_state, tg.guc_state, tg.`guc_updatetime` DESC
     LIMIT #{start},#{count}
   </select>
   
   <select id="countQueryByUid" resultType="java.lang.Long">
    SELECT IFNULL(count(guc_id),0) FROM yeshi_ec_user_goods_storage  tg
    WHERE tg.`guc_uid` = #{uid}
     <if test="gooodsType != null"> LEFT JOIN  `yeshi_ec_common_goods` cg ON tg.`guc_common_id` = cg.`cg_id`</if>
    WHERE tg.`guc_uid` = #{uid} <if test="gooodsType != null">AND cg.cg_goods_type = #{gooodsType}</if>
   </select>
  
   <select id="getByUidAndCid" resultMap="BaseResultMap">
@@ -86,6 +131,14 @@
      SELECT <include refid="Convert_Column_List"/>  FROM `yeshi_ec_user_goods_storage` g 
      LEFT JOIN  `yeshi_ec_common_goods` c ON g.`guc_common_id` = c.`cg_id`
      WHERE g.`guc_uid` = #{uid} AND c.`cg_goods_id`= #{auctionId}  
         <if test="gooodsType != null">AND c.cg_goods_type = #{gooodsType}</if>
   </select>
   
   <select id="listQueryByIds" resultMap="BaseResultMap" parameterType="java.util.List">
      SELECT * FROM `yeshi_ec_user_goods_storage` g
      LEFT JOIN  `yeshi_ec_common_goods` c ON g.`guc_common_id` = c.`cg_id`
      WHERE g.guc_id IN <foreach collection="list" item="item" open="(" close=")"
         separator=",">#{item}</foreach>
   </select>
</mapper>