BidStoragePriceMapper.xml 8.4 KB
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yoho.ufo.dal.BidStoragePriceMapper">
  <resultMap id="BaseResultMap" type="com.yoho.ufo.dal.model.BidStoragePrice">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="skup" jdbcType="INTEGER" property="skup" />
    <result column="product_id" jdbcType="INTEGER" property="productId" />
    <result column="goods_id" jdbcType="INTEGER" property="goodsId" />
    <result column="storage_id" jdbcType="INTEGER" property="storageId" />
    <result column="bid_uid" jdbcType="INTEGER" property="bidUid" />
    <result column="price" jdbcType="DECIMAL" property="price" />
    <result column="status" jdbcType="TINYINT" property="status" />
    <result column="attribute" jdbcType="INTEGER" property="attribute" />
    <result column="update_time" jdbcType="INTEGER" property="updateTime" />
    <result column="create_time" jdbcType="INTEGER" property="createTime" />
  </resultMap>
  <sql id="Base_Column_List">
    id, skup, product_id, goods_id, storage_id, bid_uid, price, status, attribute, update_time, 
    create_time
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from bid_storage_price
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from bid_storage_price
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.yoho.ufo.dal.model.BidStoragePrice">
    insert into bid_storage_price (id, skup, product_id, 
      goods_id, storage_id, bid_uid, 
      price, status, attribute, 
      update_time, create_time)
    values (#{id,jdbcType=INTEGER}, #{skup,jdbcType=INTEGER}, #{productId,jdbcType=INTEGER}, 
      #{goodsId,jdbcType=INTEGER}, #{storageId,jdbcType=INTEGER}, #{bidUid,jdbcType=INTEGER}, 
      #{price,jdbcType=DECIMAL}, #{status,jdbcType=TINYINT}, #{attribute,jdbcType=INTEGER}, 
      #{updateTime,jdbcType=INTEGER}, #{createTime,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" parameterType="com.yoho.ufo.dal.model.BidStoragePrice">
    insert into bid_storage_price
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="skup != null">
        skup,
      </if>
      <if test="productId != null">
        product_id,
      </if>
      <if test="goodsId != null">
        goods_id,
      </if>
      <if test="storageId != null">
        storage_id,
      </if>
      <if test="bidUid != null">
        bid_uid,
      </if>
      <if test="price != null">
        price,
      </if>
      <if test="status != null">
        status,
      </if>
      <if test="attribute != null">
        attribute,
      </if>
      <if test="updateTime != null">
        update_time,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      <if test="skup != null">
        #{skup,jdbcType=INTEGER},
      </if>
      <if test="productId != null">
        #{productId,jdbcType=INTEGER},
      </if>
      <if test="goodsId != null">
        #{goodsId,jdbcType=INTEGER},
      </if>
      <if test="storageId != null">
        #{storageId,jdbcType=INTEGER},
      </if>
      <if test="bidUid != null">
        #{bidUid,jdbcType=INTEGER},
      </if>
      <if test="price != null">
        #{price,jdbcType=DECIMAL},
      </if>
      <if test="status != null">
        #{status,jdbcType=TINYINT},
      </if>
      <if test="attribute != null">
        #{attribute,jdbcType=INTEGER},
      </if>
      <if test="updateTime != null">
        #{updateTime,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.yoho.ufo.dal.model.BidStoragePrice">
    update bid_storage_price
    <set>
      <if test="skup != null">
        skup = #{skup,jdbcType=INTEGER},
      </if>
      <if test="productId != null">
        product_id = #{productId,jdbcType=INTEGER},
      </if>
      <if test="goodsId != null">
        goods_id = #{goodsId,jdbcType=INTEGER},
      </if>
      <if test="storageId != null">
        storage_id = #{storageId,jdbcType=INTEGER},
      </if>
      <if test="bidUid != null">
        bid_uid = #{bidUid,jdbcType=INTEGER},
      </if>
      <if test="price != null">
        price = #{price,jdbcType=DECIMAL},
      </if>
      <if test="status != null">
        status = #{status,jdbcType=TINYINT},
      </if>
      <if test="attribute != null">
        attribute = #{attribute,jdbcType=INTEGER},
      </if>
      <if test="updateTime != null">
        update_time = #{updateTime,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.yoho.ufo.dal.model.BidStoragePrice">
    update bid_storage_price
    set skup = #{skup,jdbcType=INTEGER},
      product_id = #{productId,jdbcType=INTEGER},
      goods_id = #{goodsId,jdbcType=INTEGER},
      storage_id = #{storageId,jdbcType=INTEGER},
      bid_uid = #{bidUid,jdbcType=INTEGER},
      price = #{price,jdbcType=DECIMAL},
      status = #{status,jdbcType=TINYINT},
      attribute = #{attribute,jdbcType=INTEGER},
      update_time = #{updateTime,jdbcType=INTEGER},
      create_time = #{createTime,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateStatusBySkupSelective" parameterType="com.yoho.ufo.dal.model.BidStoragePrice">
    update bid_storage_price
    <set>
      <if test="productId != null">
        product_id = #{productId,jdbcType=INTEGER},
      </if>
      <if test="goodsId != null">
        goods_id = #{goodsId,jdbcType=INTEGER},
      </if>
      <if test="storageId != null">
        storage_id = #{storageId,jdbcType=INTEGER},
      </if>
      <if test="bidUid != null">
        bid_uid = #{bidUid,jdbcType=INTEGER},
      </if>
      <if test="price != null">
        price = #{price,jdbcType=DECIMAL},
      </if>
      <if test="status != null">
        status = #{status,jdbcType=TINYINT},
      </if>
      <if test="attribute != null">
        attribute = #{attribute,jdbcType=INTEGER},
      </if>
      <if test="updateTime != null">
        update_time = #{updateTime,jdbcType=INTEGER},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=INTEGER},
      </if>
    </set>
    where skup = #{skup,jdbcType=INTEGER}
  </update>
  <sql id="selectCondition">
    <if test="status != null">
      and sp.status = #{status,jdbcType=INTEGER}
    </if>
      <if test="skup != null">
          and sp.skup = #{skup,jdbcType=INTEGER}
      </if>
      <if test="attribute != null">
          and sp.attribute = #{attribute,jdbcType=INTEGER}
      </if>
      <if test="bidUid != null">
          and sp.bid_uid = #{bidUid,jdbcType=INTEGER}
      </if>
      <if test="productId != null">
          and sp.product_id = #{productId,jdbcType=INTEGER}
      </if>
      <if test="sizeId != null">
          and s.size_id = #{sizeId,jdbcType=INTEGER}
      </if>
  </sql>
  <select id="selectCount" resultType="java.lang.Integer">
    select count(1)
    from bid_storage_price as sp, storage as s
    where sp.storage_id = s.id
    <include refid="selectCondition"/>
  </select>

  <select id="selectList" parameterType="com.yoho.ufo.dal.model.BidStoragePrice" resultMap="BaseResultMap">
    select sp.id, sp.skup, sp.product_id, sp.goods_id, sp.storage_id, sp.bid_uid, sp.price, sp.status, sp.attribute, sp.update_time, sp.create_time, s.size_id
    from bid_storage_price as sp, storage as s
    where sp.storage_id = s.id
    <include refid="selectCondition"/>
    limit #{start,jdbcType=INTEGER}, #{rows,jdbcType=INTEGER}
  </select>

  <select id="selectBidInfoByProductIds"  resultMap="BaseResultMap">
    select MAX(price) as price, product_id, COUNT(id) as bidTotal
    from bid_storage_price
    where product_id in
    <foreach item="item" index="index" collection="productIds" open="(" separator="," close=")">
      #{item}
    </foreach>
    group by product_id
  </select>
</mapper>