<?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.neusoft.smart.pos.inventory.persistent.mapper.InventoryStoreInoutMapper">
  <resultMap id="BaseResultMap" type="com.neusoft.smart.pos.inventory.persistent.domain.InventoryStoreInout">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="shop_id" jdbcType="INTEGER" property="shopId" />
    <result column="goods_id" jdbcType="INTEGER" property="goodsId" />
    <result column="batch_id" jdbcType="INTEGER" property="batchId" />
    <result column="residue_num" jdbcType="DECIMAL" property="residueNum" />
    <result column="var_num" jdbcType="DECIMAL" property="varNum" />
    <result column="in_price" jdbcType="DECIMAL" property="inPrice" />
    <result column="sale_price" jdbcType="DECIMAL" property="salePrice" />
    <result column="action_dire" jdbcType="INTEGER" property="actionDire" />
    <result column="action_type" jdbcType="VARCHAR" property="actionType" />
    <result column="supplier" jdbcType="INTEGER" property="supplier" />
    <result column="uniq_id" jdbcType="VARCHAR" property="uniqId" />
    <result column="created_time" jdbcType="TIMESTAMP" property="createdTime" />
    <result column="created_by" jdbcType="VARCHAR" property="createdBy" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause">
    <where>
      <foreach collection="example.oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">
    id, shop_id, goods_id, batch_id, residue_num, var_num, in_price, sale_price, action_dire, 
    action_type, supplier, uniq_id, created_time, created_by
  </sql>
  <select id="selectByExample" parameterType="com.neusoft.smart.pos.inventory.persistent.domain.InventoryStoreInoutExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from inventory_store_inout
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
    <if test="offset != null and limit != null">
      limit ${offset}, ${limit}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from inventory_store_inout
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from inventory_store_inout
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="com.neusoft.smart.pos.inventory.persistent.domain.InventoryStoreInoutExample">
    delete from inventory_store_inout
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.neusoft.smart.pos.inventory.persistent.domain.InventoryStoreInout" useGeneratedKeys="true">
    insert into inventory_store_inout (shop_id, goods_id, batch_id, 
      residue_num, var_num, in_price, 
      sale_price, action_dire, action_type, 
      supplier, uniq_id, created_time, 
      created_by)
    values (#{shopId,jdbcType=INTEGER}, #{goodsId,jdbcType=INTEGER}, #{batchId,jdbcType=INTEGER}, 
      #{residueNum,jdbcType=DECIMAL}, #{varNum,jdbcType=DECIMAL}, #{inPrice,jdbcType=DECIMAL}, 
      #{salePrice,jdbcType=DECIMAL}, #{actionDire,jdbcType=INTEGER}, #{actionType,jdbcType=VARCHAR}, 
      #{supplier,jdbcType=INTEGER}, #{uniqId,jdbcType=VARCHAR}, #{createdTime,jdbcType=TIMESTAMP}, 
      #{createdBy,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.neusoft.smart.pos.inventory.persistent.domain.InventoryStoreInout" useGeneratedKeys="true">
    insert into inventory_store_inout
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="shopId != null">
        shop_id,
      </if>
      <if test="goodsId != null">
        goods_id,
      </if>
      <if test="batchId != null">
        batch_id,
      </if>
      <if test="residueNum != null">
        residue_num,
      </if>
      <if test="varNum != null">
        var_num,
      </if>
      <if test="inPrice != null">
        in_price,
      </if>
      <if test="salePrice != null">
        sale_price,
      </if>
      <if test="actionDire != null">
        action_dire,
      </if>
      <if test="actionType != null">
        action_type,
      </if>
      <if test="supplier != null">
        supplier,
      </if>
      <if test="uniqId != null">
        uniq_id,
      </if>
      <if test="createdTime != null">
        created_time,
      </if>
      <if test="createdBy != null">
        created_by,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="shopId != null">
        #{shopId,jdbcType=INTEGER},
      </if>
      <if test="goodsId != null">
        #{goodsId,jdbcType=INTEGER},
      </if>
      <if test="batchId != null">
        #{batchId,jdbcType=INTEGER},
      </if>
      <if test="residueNum != null">
        #{residueNum,jdbcType=DECIMAL},
      </if>
      <if test="varNum != null">
        #{varNum,jdbcType=DECIMAL},
      </if>
      <if test="inPrice != null">
        #{inPrice,jdbcType=DECIMAL},
      </if>
      <if test="salePrice != null">
        #{salePrice,jdbcType=DECIMAL},
      </if>
      <if test="actionDire != null">
        #{actionDire,jdbcType=INTEGER},
      </if>
      <if test="actionType != null">
        #{actionType,jdbcType=VARCHAR},
      </if>
      <if test="supplier != null">
        #{supplier,jdbcType=INTEGER},
      </if>
      <if test="uniqId != null">
        #{uniqId,jdbcType=VARCHAR},
      </if>
      <if test="createdTime != null">
        #{createdTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        #{createdBy,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.neusoft.smart.pos.inventory.persistent.domain.InventoryStoreInoutExample" resultType="java.lang.Integer">
    select count(*) from inventory_store_inout
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update inventory_store_inout
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=INTEGER},
      </if>
      <if test="record.shopId != null">
        shop_id = #{record.shopId,jdbcType=INTEGER},
      </if>
      <if test="record.goodsId != null">
        goods_id = #{record.goodsId,jdbcType=INTEGER},
      </if>
      <if test="record.batchId != null">
        batch_id = #{record.batchId,jdbcType=INTEGER},
      </if>
      <if test="record.residueNum != null">
        residue_num = #{record.residueNum,jdbcType=DECIMAL},
      </if>
      <if test="record.varNum != null">
        var_num = #{record.varNum,jdbcType=DECIMAL},
      </if>
      <if test="record.inPrice != null">
        in_price = #{record.inPrice,jdbcType=DECIMAL},
      </if>
      <if test="record.salePrice != null">
        sale_price = #{record.salePrice,jdbcType=DECIMAL},
      </if>
      <if test="record.actionDire != null">
        action_dire = #{record.actionDire,jdbcType=INTEGER},
      </if>
      <if test="record.actionType != null">
        action_type = #{record.actionType,jdbcType=VARCHAR},
      </if>
      <if test="record.supplier != null">
        supplier = #{record.supplier,jdbcType=INTEGER},
      </if>
      <if test="record.uniqId != null">
        uniq_id = #{record.uniqId,jdbcType=VARCHAR},
      </if>
      <if test="record.createdTime != null">
        created_time = #{record.createdTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.createdBy != null">
        created_by = #{record.createdBy,jdbcType=VARCHAR},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update inventory_store_inout
    set id = #{record.id,jdbcType=INTEGER},
      shop_id = #{record.shopId,jdbcType=INTEGER},
      goods_id = #{record.goodsId,jdbcType=INTEGER},
      batch_id = #{record.batchId,jdbcType=INTEGER},
      residue_num = #{record.residueNum,jdbcType=DECIMAL},
      var_num = #{record.varNum,jdbcType=DECIMAL},
      in_price = #{record.inPrice,jdbcType=DECIMAL},
      sale_price = #{record.salePrice,jdbcType=DECIMAL},
      action_dire = #{record.actionDire,jdbcType=INTEGER},
      action_type = #{record.actionType,jdbcType=VARCHAR},
      supplier = #{record.supplier,jdbcType=INTEGER},
      uniq_id = #{record.uniqId,jdbcType=VARCHAR},
      created_time = #{record.createdTime,jdbcType=TIMESTAMP},
      created_by = #{record.createdBy,jdbcType=VARCHAR}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.neusoft.smart.pos.inventory.persistent.domain.InventoryStoreInout">
    update inventory_store_inout
    <set>
      <if test="shopId != null">
        shop_id = #{shopId,jdbcType=INTEGER},
      </if>
      <if test="goodsId != null">
        goods_id = #{goodsId,jdbcType=INTEGER},
      </if>
      <if test="batchId != null">
        batch_id = #{batchId,jdbcType=INTEGER},
      </if>
      <if test="residueNum != null">
        residue_num = #{residueNum,jdbcType=DECIMAL},
      </if>
      <if test="varNum != null">
        var_num = #{varNum,jdbcType=DECIMAL},
      </if>
      <if test="inPrice != null">
        in_price = #{inPrice,jdbcType=DECIMAL},
      </if>
      <if test="salePrice != null">
        sale_price = #{salePrice,jdbcType=DECIMAL},
      </if>
      <if test="actionDire != null">
        action_dire = #{actionDire,jdbcType=INTEGER},
      </if>
      <if test="actionType != null">
        action_type = #{actionType,jdbcType=VARCHAR},
      </if>
      <if test="supplier != null">
        supplier = #{supplier,jdbcType=INTEGER},
      </if>
      <if test="uniqId != null">
        uniq_id = #{uniqId,jdbcType=VARCHAR},
      </if>
      <if test="createdTime != null">
        created_time = #{createdTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        created_by = #{createdBy,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.neusoft.smart.pos.inventory.persistent.domain.InventoryStoreInout">
    update inventory_store_inout
    set shop_id = #{shopId,jdbcType=INTEGER},
      goods_id = #{goodsId,jdbcType=INTEGER},
      batch_id = #{batchId,jdbcType=INTEGER},
      residue_num = #{residueNum,jdbcType=DECIMAL},
      var_num = #{varNum,jdbcType=DECIMAL},
      in_price = #{inPrice,jdbcType=DECIMAL},
      sale_price = #{salePrice,jdbcType=DECIMAL},
      action_dire = #{actionDire,jdbcType=INTEGER},
      action_type = #{actionType,jdbcType=VARCHAR},
      supplier = #{supplier,jdbcType=INTEGER},
      uniq_id = #{uniqId,jdbcType=VARCHAR},
      created_time = #{createdTime,jdbcType=TIMESTAMP},
      created_by = #{createdBy,jdbcType=VARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <insert id="batchInsert">
    <if test="items.get(0) != null">
            insert into inventory_store_inout  (shop_id, goods_id, batch_id, 
        residue_num, var_num, in_price, 
        sale_price, action_dire, action_type, 
        supplier, uniq_id, created_time, 
        created_by)
      values
      <foreach collection="items" item="item" index="index" separator=",">
      (#{item.shopId,jdbcType=INTEGER}, #{item.goodsId,jdbcType=INTEGER}, #{item.batchId,jdbcType=INTEGER}, 
        #{item.residueNum,jdbcType=DECIMAL}, #{item.varNum,jdbcType=DECIMAL}, #{item.inPrice,jdbcType=DECIMAL}, 
        #{item.salePrice,jdbcType=DECIMAL}, #{item.actionDire,jdbcType=INTEGER}, #{item.actionType,jdbcType=VARCHAR}, 
        #{item.supplier,jdbcType=INTEGER}, #{item.uniqId,jdbcType=VARCHAR}, #{item.createdTime,jdbcType=TIMESTAMP}, 
        #{item.createdBy,jdbcType=VARCHAR})
      </foreach>
    </if>
  </insert>
</mapper>