<?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.InventoryGoodsInfoMapper">
  <resultMap id="BaseResultMap" type="com.neusoft.smart.pos.inventory.persistent.domain.InventoryGoodsInfo">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="bar_code" jdbcType="VARCHAR" property="barCode" />
    <result column="unit" jdbcType="VARCHAR" property="unit" />
    <result column="scale" jdbcType="INTEGER" property="scale" />
    <result column="price" jdbcType="DECIMAL" property="price" />
    <result column="image" jdbcType="VARCHAR" property="image" />
    <result column="on_sale" jdbcType="INTEGER" property="onSale" />
    <result column="org_id" jdbcType="INTEGER" property="orgId" />
    <result column="shop_id" jdbcType="INTEGER" property="shopId" />
    <result column="cate_id" jdbcType="INTEGER" property="cateId" />
    <result column="deleted" jdbcType="INTEGER" property="deleted" />
    <result column="is_stock" jdbcType="INTEGER" property="isStock" />
    <result column="priority" jdbcType="INTEGER" property="priority" />
    <result column="is_thirdparty" jdbcType="INTEGER" property="isThirdparty" />
    <result column="created_time" jdbcType="TIMESTAMP" property="createdTime" />
    <result column="created_by" jdbcType="INTEGER" property="createdBy" />
    <result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime" />
    <result column="updated_by" jdbcType="INTEGER" property="updatedBy" />
  </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, name, bar_code, unit, scale, price, image, on_sale, org_id, shop_id, cate_id, 
    deleted, is_stock, priority, is_thirdparty, created_time, created_by, updated_time, 
    updated_by
  </sql>
  <select id="selectByExample" parameterType="com.neusoft.smart.pos.inventory.persistent.domain.InventoryGoodsInfoExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from inventory_goods_info
    <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_goods_info
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from inventory_goods_info
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="com.neusoft.smart.pos.inventory.persistent.domain.InventoryGoodsInfoExample">
    delete from inventory_goods_info
    <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.InventoryGoodsInfo" useGeneratedKeys="true">
    insert into inventory_goods_info (name, bar_code, unit, 
      scale, price, image, 
      on_sale, org_id, shop_id, 
      cate_id, deleted, is_stock, 
      priority, is_thirdparty, created_time, 
      created_by, updated_time, updated_by
      )
    values (#{name,jdbcType=VARCHAR}, #{barCode,jdbcType=VARCHAR}, #{unit,jdbcType=VARCHAR}, 
      #{scale,jdbcType=INTEGER}, #{price,jdbcType=DECIMAL}, #{image,jdbcType=VARCHAR}, 
      #{onSale,jdbcType=INTEGER}, #{orgId,jdbcType=INTEGER}, #{shopId,jdbcType=INTEGER}, 
      #{cateId,jdbcType=INTEGER}, #{deleted,jdbcType=INTEGER}, #{isStock,jdbcType=INTEGER}, 
      #{priority,jdbcType=INTEGER}, #{isThirdparty,jdbcType=INTEGER}, #{createdTime,jdbcType=TIMESTAMP}, 
      #{createdBy,jdbcType=INTEGER}, #{updatedTime,jdbcType=TIMESTAMP}, #{updatedBy,jdbcType=INTEGER}
      )
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.neusoft.smart.pos.inventory.persistent.domain.InventoryGoodsInfo" useGeneratedKeys="true">
    insert into inventory_goods_info
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="name != null">
        name,
      </if>
      <if test="barCode != null">
        bar_code,
      </if>
      <if test="unit != null">
        unit,
      </if>
      <if test="scale != null">
        scale,
      </if>
      <if test="price != null">
        price,
      </if>
      <if test="image != null">
        image,
      </if>
      <if test="onSale != null">
        on_sale,
      </if>
      <if test="orgId != null">
        org_id,
      </if>
      <if test="shopId != null">
        shop_id,
      </if>
      <if test="cateId != null">
        cate_id,
      </if>
      <if test="deleted != null">
        deleted,
      </if>
      <if test="isStock != null">
        is_stock,
      </if>
      <if test="priority != null">
        priority,
      </if>
      <if test="isThirdparty != null">
        is_thirdparty,
      </if>
      <if test="createdTime != null">
        created_time,
      </if>
      <if test="createdBy != null">
        created_by,
      </if>
      <if test="updatedTime != null">
        updated_time,
      </if>
      <if test="updatedBy != null">
        updated_by,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="name != null">
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="barCode != null">
        #{barCode,jdbcType=VARCHAR},
      </if>
      <if test="unit != null">
        #{unit,jdbcType=VARCHAR},
      </if>
      <if test="scale != null">
        #{scale,jdbcType=INTEGER},
      </if>
      <if test="price != null">
        #{price,jdbcType=DECIMAL},
      </if>
      <if test="image != null">
        #{image,jdbcType=VARCHAR},
      </if>
      <if test="onSale != null">
        #{onSale,jdbcType=INTEGER},
      </if>
      <if test="orgId != null">
        #{orgId,jdbcType=INTEGER},
      </if>
      <if test="shopId != null">
        #{shopId,jdbcType=INTEGER},
      </if>
      <if test="cateId != null">
        #{cateId,jdbcType=INTEGER},
      </if>
      <if test="deleted != null">
        #{deleted,jdbcType=INTEGER},
      </if>
      <if test="isStock != null">
        #{isStock,jdbcType=INTEGER},
      </if>
      <if test="priority != null">
        #{priority,jdbcType=INTEGER},
      </if>
      <if test="isThirdparty != null">
        #{isThirdparty,jdbcType=INTEGER},
      </if>
      <if test="createdTime != null">
        #{createdTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        #{createdBy,jdbcType=INTEGER},
      </if>
      <if test="updatedTime != null">
        #{updatedTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updatedBy != null">
        #{updatedBy,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.neusoft.smart.pos.inventory.persistent.domain.InventoryGoodsInfoExample" resultType="java.lang.Integer">
    select count(*) from inventory_goods_info
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update inventory_goods_info
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=INTEGER},
      </if>
      <if test="record.name != null">
        name = #{record.name,jdbcType=VARCHAR},
      </if>
      <if test="record.barCode != null">
        bar_code = #{record.barCode,jdbcType=VARCHAR},
      </if>
      <if test="record.unit != null">
        unit = #{record.unit,jdbcType=VARCHAR},
      </if>
      <if test="record.scale != null">
        scale = #{record.scale,jdbcType=INTEGER},
      </if>
      <if test="record.price != null">
        price = #{record.price,jdbcType=DECIMAL},
      </if>
      <if test="record.image != null">
        image = #{record.image,jdbcType=VARCHAR},
      </if>
      <if test="record.onSale != null">
        on_sale = #{record.onSale,jdbcType=INTEGER},
      </if>
      <if test="record.orgId != null">
        org_id = #{record.orgId,jdbcType=INTEGER},
      </if>
      <if test="record.shopId != null">
        shop_id = #{record.shopId,jdbcType=INTEGER},
      </if>
      <if test="record.cateId != null">
        cate_id = #{record.cateId,jdbcType=INTEGER},
      </if>
      <if test="record.deleted != null">
        deleted = #{record.deleted,jdbcType=INTEGER},
      </if>
      <if test="record.isStock != null">
        is_stock = #{record.isStock,jdbcType=INTEGER},
      </if>
      <if test="record.priority != null">
        priority = #{record.priority,jdbcType=INTEGER},
      </if>
      <if test="record.isThirdparty != null">
        is_thirdparty = #{record.isThirdparty,jdbcType=INTEGER},
      </if>
      <if test="record.createdTime != null">
        created_time = #{record.createdTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.createdBy != null">
        created_by = #{record.createdBy,jdbcType=INTEGER},
      </if>
      <if test="record.updatedTime != null">
        updated_time = #{record.updatedTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.updatedBy != null">
        updated_by = #{record.updatedBy,jdbcType=INTEGER},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update inventory_goods_info
    set id = #{record.id,jdbcType=INTEGER},
      name = #{record.name,jdbcType=VARCHAR},
      bar_code = #{record.barCode,jdbcType=VARCHAR},
      unit = #{record.unit,jdbcType=VARCHAR},
      scale = #{record.scale,jdbcType=INTEGER},
      price = #{record.price,jdbcType=DECIMAL},
      image = #{record.image,jdbcType=VARCHAR},
      on_sale = #{record.onSale,jdbcType=INTEGER},
      org_id = #{record.orgId,jdbcType=INTEGER},
      shop_id = #{record.shopId,jdbcType=INTEGER},
      cate_id = #{record.cateId,jdbcType=INTEGER},
      deleted = #{record.deleted,jdbcType=INTEGER},
      is_stock = #{record.isStock,jdbcType=INTEGER},
      priority = #{record.priority,jdbcType=INTEGER},
      is_thirdparty = #{record.isThirdparty,jdbcType=INTEGER},
      created_time = #{record.createdTime,jdbcType=TIMESTAMP},
      created_by = #{record.createdBy,jdbcType=INTEGER},
      updated_time = #{record.updatedTime,jdbcType=TIMESTAMP},
      updated_by = #{record.updatedBy,jdbcType=INTEGER}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.neusoft.smart.pos.inventory.persistent.domain.InventoryGoodsInfo">
    update inventory_goods_info
    <set>
      <if test="name != null">
        name = #{name,jdbcType=VARCHAR},
      </if>
      <if test="barCode != null">
        bar_code = #{barCode,jdbcType=VARCHAR},
      </if>
      <if test="unit != null">
        unit = #{unit,jdbcType=VARCHAR},
      </if>
      <if test="scale != null">
        scale = #{scale,jdbcType=INTEGER},
      </if>
      <if test="price != null">
        price = #{price,jdbcType=DECIMAL},
      </if>
      <if test="image != null">
        image = #{image,jdbcType=VARCHAR},
      </if>
      <if test="onSale != null">
        on_sale = #{onSale,jdbcType=INTEGER},
      </if>
      <if test="orgId != null">
        org_id = #{orgId,jdbcType=INTEGER},
      </if>
      <if test="shopId != null">
        shop_id = #{shopId,jdbcType=INTEGER},
      </if>
      <if test="cateId != null">
        cate_id = #{cateId,jdbcType=INTEGER},
      </if>
      <if test="deleted != null">
        deleted = #{deleted,jdbcType=INTEGER},
      </if>
      <if test="isStock != null">
        is_stock = #{isStock,jdbcType=INTEGER},
      </if>
      <if test="priority != null">
        priority = #{priority,jdbcType=INTEGER},
      </if>
      <if test="isThirdparty != null">
        is_thirdparty = #{isThirdparty,jdbcType=INTEGER},
      </if>
      <if test="createdTime != null">
        created_time = #{createdTime,jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        created_by = #{createdBy,jdbcType=INTEGER},
      </if>
      <if test="updatedTime != null">
        updated_time = #{updatedTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updatedBy != null">
        updated_by = #{updatedBy,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.neusoft.smart.pos.inventory.persistent.domain.InventoryGoodsInfo">
    update inventory_goods_info
    set name = #{name,jdbcType=VARCHAR},
      bar_code = #{barCode,jdbcType=VARCHAR},
      unit = #{unit,jdbcType=VARCHAR},
      scale = #{scale,jdbcType=INTEGER},
      price = #{price,jdbcType=DECIMAL},
      image = #{image,jdbcType=VARCHAR},
      on_sale = #{onSale,jdbcType=INTEGER},
      org_id = #{orgId,jdbcType=INTEGER},
      shop_id = #{shopId,jdbcType=INTEGER},
      cate_id = #{cateId,jdbcType=INTEGER},
      deleted = #{deleted,jdbcType=INTEGER},
      is_stock = #{isStock,jdbcType=INTEGER},
      priority = #{priority,jdbcType=INTEGER},
      is_thirdparty = #{isThirdparty,jdbcType=INTEGER},
      created_time = #{createdTime,jdbcType=TIMESTAMP},
      created_by = #{createdBy,jdbcType=INTEGER},
      updated_time = #{updatedTime,jdbcType=TIMESTAMP},
      updated_by = #{updatedBy,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <insert id="batchInsert">
    <if test="items.get(0) != null">
            insert into inventory_goods_info  (name, bar_code, unit, 
        scale, price, image, 
        on_sale, org_id, shop_id, 
        cate_id, deleted, is_stock, 
        priority, is_thirdparty, created_time, 
        created_by, updated_time, updated_by
        )
      values
      <foreach collection="items" item="item" index="index" separator=",">
      (#{item.name,jdbcType=VARCHAR}, #{item.barCode,jdbcType=VARCHAR}, #{item.unit,jdbcType=VARCHAR}, 
        #{item.scale,jdbcType=INTEGER}, #{item.price,jdbcType=DECIMAL}, #{item.image,jdbcType=VARCHAR}, 
        #{item.onSale,jdbcType=INTEGER}, #{item.orgId,jdbcType=INTEGER}, #{item.shopId,jdbcType=INTEGER}, 
        #{item.cateId,jdbcType=INTEGER}, #{item.deleted,jdbcType=INTEGER}, #{item.isStock,jdbcType=INTEGER}, 
        #{item.priority,jdbcType=INTEGER}, #{item.isThirdparty,jdbcType=INTEGER}, #{item.createdTime,jdbcType=TIMESTAMP}, 
        #{item.createdBy,jdbcType=INTEGER}, #{item.updatedTime,jdbcType=TIMESTAMP}, #{item.updatedBy,jdbcType=INTEGER}
        )
      </foreach>
    </if>
  </insert>
</mapper>