<?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.org.persistent.mapper.OrganizationGroupMapper">
  <resultMap id="BaseResultMap" type="com.neusoft.smart.pos.org.persistent.domain.OrganizationGroup">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="description" jdbcType="VARCHAR" property="description" />
    <result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
    <result column="status" jdbcType="VARCHAR" property="status" />
    <result column="reserved1" jdbcType="VARCHAR" property="reserved1" />
    <result column="reserved2" jdbcType="VARCHAR" property="reserved2" />
    <result column="reserved3" jdbcType="VARCHAR" property="reserved3" />
    <result column="entity_table_name" jdbcType="VARCHAR" property="entityTableName" />
    <result column="entity_table_id" jdbcType="INTEGER" property="entityTableId" />
  </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, description, create_date, status, reserved1, reserved2, reserved3, entity_table_name, 
    entity_table_id
  </sql>
  <select id="selectByExample" parameterType="com.neusoft.smart.pos.org.persistent.domain.OrganizationGroupExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from organization_group
    <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 organization_group
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from organization_group
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="com.neusoft.smart.pos.org.persistent.domain.OrganizationGroupExample">
    delete from organization_group
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.neusoft.smart.pos.org.persistent.domain.OrganizationGroup" useGeneratedKeys="true">
    insert into organization_group (name, description, create_date, 
      status, reserved1, reserved2, 
      reserved3, entity_table_name, entity_table_id
      )
    values (#{name,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{createDate,jdbcType=TIMESTAMP}, 
      #{status,jdbcType=VARCHAR}, #{reserved1,jdbcType=VARCHAR}, #{reserved2,jdbcType=VARCHAR}, 
      #{reserved3,jdbcType=VARCHAR}, #{entityTableName,jdbcType=VARCHAR}, #{entityTableId,jdbcType=INTEGER}
      )
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.neusoft.smart.pos.org.persistent.domain.OrganizationGroup" useGeneratedKeys="true">
    insert into organization_group
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="name != null">
        name,
      </if>
      <if test="description != null">
        description,
      </if>
      <if test="createDate != null">
        create_date,
      </if>
      <if test="status != null">
        status,
      </if>
      <if test="reserved1 != null">
        reserved1,
      </if>
      <if test="reserved2 != null">
        reserved2,
      </if>
      <if test="reserved3 != null">
        reserved3,
      </if>
      <if test="entityTableName != null">
        entity_table_name,
      </if>
      <if test="entityTableId != null">
        entity_table_id,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="name != null">
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="description != null">
        #{description,jdbcType=VARCHAR},
      </if>
      <if test="createDate != null">
        #{createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="status != null">
        #{status,jdbcType=VARCHAR},
      </if>
      <if test="reserved1 != null">
        #{reserved1,jdbcType=VARCHAR},
      </if>
      <if test="reserved2 != null">
        #{reserved2,jdbcType=VARCHAR},
      </if>
      <if test="reserved3 != null">
        #{reserved3,jdbcType=VARCHAR},
      </if>
      <if test="entityTableName != null">
        #{entityTableName,jdbcType=VARCHAR},
      </if>
      <if test="entityTableId != null">
        #{entityTableId,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.neusoft.smart.pos.org.persistent.domain.OrganizationGroupExample" resultType="java.lang.Integer">
    select count(*) from organization_group
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update organization_group
    <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.description != null">
        description = #{record.description,jdbcType=VARCHAR},
      </if>
      <if test="record.createDate != null">
        create_date = #{record.createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="record.status != null">
        status = #{record.status,jdbcType=VARCHAR},
      </if>
      <if test="record.reserved1 != null">
        reserved1 = #{record.reserved1,jdbcType=VARCHAR},
      </if>
      <if test="record.reserved2 != null">
        reserved2 = #{record.reserved2,jdbcType=VARCHAR},
      </if>
      <if test="record.reserved3 != null">
        reserved3 = #{record.reserved3,jdbcType=VARCHAR},
      </if>
      <if test="record.entityTableName != null">
        entity_table_name = #{record.entityTableName,jdbcType=VARCHAR},
      </if>
      <if test="record.entityTableId != null">
        entity_table_id = #{record.entityTableId,jdbcType=INTEGER},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update organization_group
    set id = #{record.id,jdbcType=INTEGER},
      name = #{record.name,jdbcType=VARCHAR},
      description = #{record.description,jdbcType=VARCHAR},
      create_date = #{record.createDate,jdbcType=TIMESTAMP},
      status = #{record.status,jdbcType=VARCHAR},
      reserved1 = #{record.reserved1,jdbcType=VARCHAR},
      reserved2 = #{record.reserved2,jdbcType=VARCHAR},
      reserved3 = #{record.reserved3,jdbcType=VARCHAR},
      entity_table_name = #{record.entityTableName,jdbcType=VARCHAR},
      entity_table_id = #{record.entityTableId,jdbcType=INTEGER}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.neusoft.smart.pos.org.persistent.domain.OrganizationGroup">
    update organization_group
    <set>
      <if test="name != null">
        name = #{name,jdbcType=VARCHAR},
      </if>
      <if test="description != null">
        description = #{description,jdbcType=VARCHAR},
      </if>
      <if test="createDate != null">
        create_date = #{createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="status != null">
        status = #{status,jdbcType=VARCHAR},
      </if>
      <if test="reserved1 != null">
        reserved1 = #{reserved1,jdbcType=VARCHAR},
      </if>
      <if test="reserved2 != null">
        reserved2 = #{reserved2,jdbcType=VARCHAR},
      </if>
      <if test="reserved3 != null">
        reserved3 = #{reserved3,jdbcType=VARCHAR},
      </if>
      <if test="entityTableName != null">
        entity_table_name = #{entityTableName,jdbcType=VARCHAR},
      </if>
      <if test="entityTableId != null">
        entity_table_id = #{entityTableId,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.neusoft.smart.pos.org.persistent.domain.OrganizationGroup">
    update organization_group
    set name = #{name,jdbcType=VARCHAR},
      description = #{description,jdbcType=VARCHAR},
      create_date = #{createDate,jdbcType=TIMESTAMP},
      status = #{status,jdbcType=VARCHAR},
      reserved1 = #{reserved1,jdbcType=VARCHAR},
      reserved2 = #{reserved2,jdbcType=VARCHAR},
      reserved3 = #{reserved3,jdbcType=VARCHAR},
      entity_table_name = #{entityTableName,jdbcType=VARCHAR},
      entity_table_id = #{entityTableId,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <insert id="batchInsert">
    <if test="items.get(0) != null">
            insert into organization_group  (name, description, create_date, 
        status, reserved1, reserved2, 
        reserved3, entity_table_name, entity_table_id
        )
      values
      <foreach collection="items" item="item" index="index" separator=",">
      (#{item.name,jdbcType=VARCHAR}, #{item.description,jdbcType=VARCHAR}, #{item.createDate,jdbcType=TIMESTAMP}, 
        #{item.status,jdbcType=VARCHAR}, #{item.reserved1,jdbcType=VARCHAR}, #{item.reserved2,jdbcType=VARCHAR}, 
        #{item.reserved3,jdbcType=VARCHAR}, #{item.entityTableName,jdbcType=VARCHAR}, #{item.entityTableId,jdbcType=INTEGER}
        )
      </foreach>
    </if>
  </insert>
</mapper>