<?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.InventoryGoodsThirdpartyAuthMapper">
  <resultMap id="BaseResultMap" type="com.neusoft.smart.pos.inventory.persistent.domain.InventoryGoodsThirdpartyAuth">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="org_id" jdbcType="INTEGER" property="orgId" />
    <result column="shop_id" jdbcType="INTEGER" property="shopId" />
    <result column="bean_name" jdbcType="VARCHAR" property="beanName" />
  </resultMap>
  <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.neusoft.smart.pos.inventory.persistent.domain.InventoryGoodsThirdpartyAuth">
    <result column="auth_data" jdbcType="LONGVARCHAR" property="authData" />
  </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, org_id, shop_id, bean_name
  </sql>
  <sql id="Blob_Column_List">
    auth_data
  </sql>
  <select id="selectByExampleWithBLOBs" parameterType="com.neusoft.smart.pos.inventory.persistent.domain.InventoryGoodsThirdpartyAuthExample" resultMap="ResultMapWithBLOBs">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from inventory_goods_thirdparty_auth
    <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.InventoryGoodsThirdpartyAuthExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from inventory_goods_thirdparty_auth
    <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_thirdparty_auth
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from inventory_goods_thirdparty_auth
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="com.neusoft.smart.pos.inventory.persistent.domain.InventoryGoodsThirdpartyAuthExample">
    delete from inventory_goods_thirdparty_auth
    <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.InventoryGoodsThirdpartyAuth" useGeneratedKeys="true">
    insert into inventory_goods_thirdparty_auth (org_id, shop_id, bean_name, 
      auth_data)
    values (#{orgId,jdbcType=INTEGER}, #{shopId,jdbcType=INTEGER}, #{beanName,jdbcType=VARCHAR}, 
      #{authData,jdbcType=LONGVARCHAR})
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.neusoft.smart.pos.inventory.persistent.domain.InventoryGoodsThirdpartyAuth" useGeneratedKeys="true">
    insert into inventory_goods_thirdparty_auth
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="orgId != null">
        org_id,
      </if>
      <if test="shopId != null">
        shop_id,
      </if>
      <if test="beanName != null">
        bean_name,
      </if>
      <if test="authData != null">
        auth_data,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="orgId != null">
        #{orgId,jdbcType=INTEGER},
      </if>
      <if test="shopId != null">
        #{shopId,jdbcType=INTEGER},
      </if>
      <if test="beanName != null">
        #{beanName,jdbcType=VARCHAR},
      </if>
      <if test="authData != null">
        #{authData,jdbcType=LONGVARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.neusoft.smart.pos.inventory.persistent.domain.InventoryGoodsThirdpartyAuthExample" resultType="java.lang.Integer">
    select count(*) from inventory_goods_thirdparty_auth
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update inventory_goods_thirdparty_auth
    <set>
      <if test="record.id != null">
        id = #{record.id,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.beanName != null">
        bean_name = #{record.beanName,jdbcType=VARCHAR},
      </if>
      <if test="record.authData != null">
        auth_data = #{record.authData,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_thirdparty_auth
    set id = #{record.id,jdbcType=INTEGER},
      org_id = #{record.orgId,jdbcType=INTEGER},
      shop_id = #{record.shopId,jdbcType=INTEGER},
      bean_name = #{record.beanName,jdbcType=VARCHAR},
      auth_data = #{record.authData,jdbcType=LONGVARCHAR}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update inventory_goods_thirdparty_auth
    set id = #{record.id,jdbcType=INTEGER},
      org_id = #{record.orgId,jdbcType=INTEGER},
      shop_id = #{record.shopId,jdbcType=INTEGER},
      bean_name = #{record.beanName,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.InventoryGoodsThirdpartyAuth">
    update inventory_goods_thirdparty_auth
    <set>
      <if test="orgId != null">
        org_id = #{orgId,jdbcType=INTEGER},
      </if>
      <if test="shopId != null">
        shop_id = #{shopId,jdbcType=INTEGER},
      </if>
      <if test="beanName != null">
        bean_name = #{beanName,jdbcType=VARCHAR},
      </if>
      <if test="authData != null">
        auth_data = #{authData,jdbcType=LONGVARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.neusoft.smart.pos.inventory.persistent.domain.InventoryGoodsThirdpartyAuth">
    update inventory_goods_thirdparty_auth
    set org_id = #{orgId,jdbcType=INTEGER},
      shop_id = #{shopId,jdbcType=INTEGER},
      bean_name = #{beanName,jdbcType=VARCHAR},
      auth_data = #{authData,jdbcType=LONGVARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.neusoft.smart.pos.inventory.persistent.domain.InventoryGoodsThirdpartyAuth">
    update inventory_goods_thirdparty_auth
    set org_id = #{orgId,jdbcType=INTEGER},
      shop_id = #{shopId,jdbcType=INTEGER},
      bean_name = #{beanName,jdbcType=VARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <insert id="batchInsert">
    <if test="items.get(0) != null">
            insert into inventory_goods_thirdparty_auth  (org_id, shop_id, bean_name, 
        auth_data)
      values
      <foreach collection="items" item="item" index="index" separator=",">
      (#{item.orgId,jdbcType=INTEGER}, #{item.shopId,jdbcType=INTEGER}, #{item.beanName,jdbcType=VARCHAR}, 
        #{item.authData,jdbcType=LONGVARCHAR})
      </foreach>
    </if>
  </insert>
</mapper>