StorageMapper.xml 3.22 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.StorageMapper">
  <resultMap id="BaseResultMap" type="com.yoho.ufo.dal.model.Storage">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="product_id" jdbcType="INTEGER" property="productId" />
    <result column="goods_id" jdbcType="INTEGER" property="goodsId" />
    <result column="size_id" jdbcType="INTEGER" property="sizeId" />
    <result column="storage_num" jdbcType="INTEGER" property="storageNum" />
    <result column="update_time" jdbcType="INTEGER" property="updateTime" />
    <result column="create_time" jdbcType="INTEGER" property="createTime" />
  </resultMap>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from storage
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.yoho.ufo.dal.model.Storage">
    insert into storage (id, product_id, goods_id, 
      size_id, storage_num, update_time, 
      create_time)
    values (#{id,jdbcType=INTEGER}, #{productId,jdbcType=INTEGER}, #{goodsId,jdbcType=INTEGER}, 
      #{sizeId,jdbcType=INTEGER}, #{storageNum,jdbcType=INTEGER}, #{updateTime,jdbcType=INTEGER}, 
      #{createTime,jdbcType=INTEGER})
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yoho.ufo.dal.model.Storage">
    update storage
    set product_id = #{productId,jdbcType=INTEGER},
      goods_id = #{goodsId,jdbcType=INTEGER},
      size_id = #{sizeId,jdbcType=INTEGER},
      storage_num = #{storageNum,jdbcType=INTEGER},
      update_time = #{updateTime,jdbcType=INTEGER},
      create_time = #{createTime,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select id, product_id, goods_id, size_id, storage_num, update_time, create_time
    from storage
    where id = #{id,jdbcType=INTEGER}
  </select>
  <select id="selectAll" resultMap="BaseResultMap">
    select id, product_id, goods_id, size_id, storage_num, update_time, create_time
    from storage
  </select>
  <select id="selectByGoodsId" resultMap="BaseResultMap">
    select id, product_id, goods_id, size_id, storage_num, update_time, create_time
    from storage where goods_id = #{goodsId,jdbcType=INTEGER}
  </select>
  <select id="selectByGoodsIdList" resultMap="BaseResultMap">
    select id, product_id, goods_id, size_id, storage_num, update_time, create_time
    from storage where goods_id in 
        <foreach item="item" index="index" collection="list" open="(" separator="," close=")">  
	  		#{item}  
	 	</foreach>
  </select>
  <update id="addStorageNum">
    update storage set storage_num = storage_num + #{storageNum,jdbcType=INTEGER},
      update_time = #{updateTime,jdbcType=INTEGER},
    where id = #{storageId,jdbcType=INTEGER}
  </update>
  <select id="selectByIds" resultMap="BaseResultMap">
    select id, product_id, goods_id, size_id, storage_num, update_time, create_time
    from storage where id in
    <foreach item="item" index="index" collection="storageIdList" open="(" separator="," close=")">
      #{item}
    </foreach>
  </select>
</mapper>