<?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.InventoryGoodsLimitMapper">
  <resultMap id="BaseResultMap" type="com.neusoft.smart.pos.inventory.persistent.domain.InventoryGoodsLimit">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="goods_id" jdbcType="INTEGER" property="goodsId" />
    <result column="bean_id" jdbcType="INTEGER" property="beanId" />
    <result column="cteated_time" jdbcType="TIMESTAMP" property="cteatedTime" />
    <result column="created_by" jdbcType="INTEGER" property="createdBy" />
    <result column="version" jdbcType="INTEGER" property="version" />
  </resultMap>
  <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.neusoft.smart.pos.inventory.persistent.domain.InventoryGoodsLimit">
    <result column="limit_json" jdbcType="LONGVARCHAR" property="limitJson" />
  </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, goods_id, bean_id, cteated_time, created_by, version
  </sql>
  <sql id="Blob_Column_List">
    limit_json
  </sql>
  <select id="selectByExampleWithBLOBs" parameterType="com.neusoft.smart.pos.inventory.persistent.domain.InventoryGoodsLimitExample" resultMap="ResultMapWithBLOBs">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from inventory_goods_limit
    <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="selectByExample" parameterType="com.neusoft.smart.pos.inventory.persistent.domain.InventoryGoodsLimitExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from inventory_goods_limit
    <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="ResultMapWithBLOBs">
    select 
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from inventory_goods_limit
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from inventory_goods_limit
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="com.neusoft.smart.pos.inventory.persistent.domain.InventoryGoodsLimitExample">
    delete from inventory_goods_limit
    <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.InventoryGoodsLimit" useGeneratedKeys="true">
    insert into inventory_goods_limit (goods_id, bean_id, cteated_time, 
      created_by, version, limit_json
      )
    values (#{goodsId,jdbcType=INTEGER}, #{beanId,jdbcType=INTEGER}, #{cteatedTime,jdbcType=TIMESTAMP}, 
    #{createdBy,jdbcType=INTEGER}, 0, #{limitJson,jdbcType=LONGVARCHAR}
      )
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.neusoft.smart.pos.inventory.persistent.domain.InventoryGoodsLimit" useGeneratedKeys="true">
    insert into inventory_goods_limit
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="goodsId != null">
        goods_id,
      </if>
      <if test="beanId != null">
        bean_id,
      </if>
      <if test="cteatedTime != null">
        cteated_time,
      </if>
      <if test="createdBy != null">
        created_by,
      </if>
      version,
      <if test="limitJson != null">
        limit_json,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="goodsId != null">
        #{goodsId,jdbcType=INTEGER},
      </if>
      <if test="beanId != null">
        #{beanId,jdbcType=INTEGER},
      </if>
      <if test="cteatedTime != null">
        #{cteatedTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        #{createdBy,jdbcType=INTEGER},
      </if>
      0,
      <if test="limitJson != null">
        #{limitJson,jdbcType=LONGVARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.neusoft.smart.pos.inventory.persistent.domain.InventoryGoodsLimitExample" resultType="java.lang.Integer">
    select count(*) from inventory_goods_limit
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update inventory_goods_limit
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=INTEGER},
      </if>
      <if test="record.goodsId != null">
        goods_id = #{record.goodsId,jdbcType=INTEGER},
      </if>
      <if test="record.beanId != null">
        bean_id = #{record.beanId,jdbcType=INTEGER},
      </if>
      <if test="record.cteatedTime != null">
        cteated_time = #{record.cteatedTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.createdBy != null">
        created_by = #{record.createdBy,jdbcType=INTEGER},
      </if>
      version = version + 1,
      <if test="record.limitJson != null">
        limit_json = #{record.limitJson,jdbcType=LONGVARCHAR},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExampleWithBLOBs" parameterType="map">
    update inventory_goods_limit
    set id = #{record.id,jdbcType=INTEGER},
      goods_id = #{record.goodsId,jdbcType=INTEGER},
      bean_id = #{record.beanId,jdbcType=INTEGER},
      cteated_time = #{record.cteatedTime,jdbcType=TIMESTAMP},
      created_by = #{record.createdBy,jdbcType=INTEGER},
      version = version + 1,
      limit_json = #{record.limitJson,jdbcType=LONGVARCHAR}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update inventory_goods_limit
    set id = #{record.id,jdbcType=INTEGER},
      goods_id = #{record.goodsId,jdbcType=INTEGER},
      bean_id = #{record.beanId,jdbcType=INTEGER},
      cteated_time = #{record.cteatedTime,jdbcType=TIMESTAMP},
      created_by = #{record.createdBy,jdbcType=INTEGER},
      version = version + 1
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.neusoft.smart.pos.inventory.persistent.domain.InventoryGoodsLimit">
    update inventory_goods_limit
    <set>
      <if test="goodsId != null">
        goods_id = #{goodsId,jdbcType=INTEGER},
      </if>
      <if test="beanId != null">
        bean_id = #{beanId,jdbcType=INTEGER},
      </if>
      <if test="cteatedTime != null">
        cteated_time = #{cteatedTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        created_by = #{createdBy,jdbcType=INTEGER},
      </if>
      version = version + 1,
      <if test="limitJson != null">
        limit_json = #{limitJson,jdbcType=LONGVARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER} and version = #{version,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.neusoft.smart.pos.inventory.persistent.domain.InventoryGoodsLimit">
    update inventory_goods_limit
    set goods_id = #{goodsId,jdbcType=INTEGER},
      bean_id = #{beanId,jdbcType=INTEGER},
      cteated_time = #{cteatedTime,jdbcType=TIMESTAMP},
      created_by = #{createdBy,jdbcType=INTEGER},
      version = version + 1,
      limit_json = #{limitJson,jdbcType=LONGVARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.neusoft.smart.pos.inventory.persistent.domain.InventoryGoodsLimit">
    update inventory_goods_limit
    set goods_id = #{goodsId,jdbcType=INTEGER},
      bean_id = #{beanId,jdbcType=INTEGER},
      cteated_time = #{cteatedTime,jdbcType=TIMESTAMP},
      created_by = #{createdBy,jdbcType=INTEGER},
      version = version + 1
    where id = #{id,jdbcType=INTEGER} and version = #{version,jdbcType=INTEGER}
  </update>
  <insert id="batchInsert">
    <if test="items.get(0) != null">
            insert into inventory_goods_limit  (goods_id, bean_id, cteated_time, 
        created_by, version, limit_json
        )
      values
      <foreach collection="items" item="item" index="index" separator=",">
      (#{item.goodsId,jdbcType=INTEGER}, #{item.beanId,jdbcType=INTEGER}, #{item.cteatedTime,jdbcType=TIMESTAMP}, 
      #{item.createdBy,jdbcType=INTEGER}, 0, #{item.limitJson,jdbcType=LONGVARCHAR}
        )
      </foreach>
    </if>
  </insert>
</mapper>