<?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.CityRegionDictionaryMapper">
    <resultMap id="BaseResultMap" type="com.neusoft.smart.pos.org.persistent.domain.CityRegionDictionary">
        <id column="transaction_id" jdbcType="INTEGER" property="transactionId"/>
        <result column="region_number" jdbcType="INTEGER" property="regionNumber"/>
        <result column="parent_number" jdbcType="INTEGER" property="parentNumber"/>
        <result column="region_name" jdbcType="VARCHAR" property="regionName"/>
        <result column="short_name" jdbcType="VARCHAR" property="shortName"/>
        <result column="level" jdbcType="INTEGER" property="level"/>
        <result column="is_enable" jdbcType="INTEGER" property="isEnable"/>
    </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">
    transaction_id , region_number , parent_number , region_name , short_name , level , is_enable
  </sql>
    <select id="selectByExample" parameterType="com.neusoft.smart.pos.org.persistent.domain.CityRegionDictionaryExample"
            resultMap="BaseResultMap">
        select
        <if test="distinct">
            distinct
        </if>
        <include refid="Base_Column_List"/>
        from `city_region_dictionary`
        <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 `city_region_dictionary`
        where transaction_id = #{transaction_id,jdbcType=INTEGER}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from `city_region_dictionary`
    where transaction_id = #{transaction_id,jdbcType=INTEGER}
  </delete>
    <delete id="deleteByExample" parameterType="com.neusoft.smart.pos.org.persistent.domain.CityRegionDictionaryExample">
        delete from `city_region_dictionary`
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
    </delete>
    <insert id="insert" parameterType="com.neusoft.smart.pos.org.persistent.domain.CityRegionDictionary">
    insert into `city_region_dictionary` (transaction_id , region_number , parent_number , region_name , short_name , level , is_enable)
    values (#{transactionId,jdbcType=INTEGER}, #{regionNumber,jdbcType=INTEGER}, #{parentNumber,jdbcType=INTEGER}, 
      #{regionName,jdbcType=VARCHAR}, #{shortName,jdbcType=VARCHAR}, #{level,jdbcType=INTEGER}, #{isEnable,jdbcType=INTEGER})
  </insert>
    <insert id="insertSelective" parameterType="com.neusoft.smart.pos.org.persistent.domain.CityRegionDictionary">
    	<selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="id">
          SELECT LAST_INSERT_ID()
      	</selectKey>
        insert into `city_region_dictionary`
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="transactionId != null">
                transaction_id,
            </if>
            <if test="regionNumber != null">
                region_number,
            </if>
            <if test="parentNumber != null">
                parent_number,
            </if>
            <if test="regionName != null">
                region_name,
            </if>
            <if test="shortName != null">
                short_name,
            </if>
            <if test="level != null">
                level,
            </if>
            <if test="isEnable != null">
                is_enable,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="transactionId != null">
                #{transactionId,jdbcType=INTEGER},
            </if>
            <if test="regionNumber != null">
                #{regionNumber,jdbcType=INTEGER},
            </if>
            <if test="parentNumber != null">
                #{parentNumber,jdbcType=INTEGER},
            </if>
            <if test="regionName != null">
                #{regionName,jdbcType=VARCHAR},
            </if>
            <if test="shortName">
                #{shortName,jdbcType=VARCHAR},
            </if>
            <if test="level != null">
                #{level,jdbcType=INTEGER},
            </if>
            <if test="isEnable != null">
                #{isEnable,jdbcType=INTEGER},
            </if>
        </trim>
    </insert>
    <select id="countByExample" parameterType="com.neusoft.smart.pos.org.persistent.domain.CityRegionDictionaryExample"
            resultType="java.lang.Integer">
        select count(*) from `city_region_dictionary`
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
    </select>
    <update id="updateByExampleSelective" parameterType="map">
        update `city_region_dictionary`
        <set>
            <if test="record.transactionId != null">
                transaction_id = #{record.transactionId,jdbcType=INTEGER},
            </if>
            <if test="record.regionNumber != null">
                region_number = #{record.regionNumber,jdbcType=INTEGER},
            </if>
            <if test="record.parentNumber != null">
                parent_number = #{record.parentNumber,jdbcType=INTEGER},
            </if>
            <if test="record.regionName != null">
                region_name = #{record.regionName,jdbcType=VARCHAR},
            </if>
            <if test="record.shortName != null">
                short_name = #{record.shortName,jdbcType=VARCHAR},
            </if>
            <if test="record.level != null">
                level = #{record.level,jdbcType=INTEGER},
            </if>
            <if test="record.isEnable != null">
                is_enable = #{record.isEnable,jdbcType=INTEGER},
            </if>
        </set>
        <if test="_parameter != null">
            <include refid="Update_By_Example_Where_Clause"/>
        </if>
    </update>
    <update id="updateByExample" parameterType="map">
        update `city_region_dictionary`
        set transaction_id = #{record.transactionId,jdbcType=INTEGER},
        region_number = #{record.regionNumber,jdbcType=INTEGER},
        parent_number = #{record.parentNumber,jdbcType=INTEGER},
        region_name = #{record.regionName,jdbcType=VARCHAR},
        short_name = #{record.shortName,jdbcType=VARCHAR},
        level = #{record.level,jdbcType=INTEGER},
        is_enable = #{record.isEnable,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.CityRegionDictionary">
        update `city_region_dictionary`
        <set>
            <if test="regionNumber != null">
                region_number = #{regionNumber,jdbcType=INTEGER},
            </if>
            <if test="parentNumber != null">
                parent_number = #{parentNumber,jdbcType=INTEGER},
            </if>
            <if test="regionName != null">
                region_name = #{regionName,jdbcType=VARCHAR},
            </if>
            <if test="shortName != null">
                short_name = #{shortName,jdbcType=VARCHAR},
            </if>
            <if test="level != null">
                level = #{level,jdbcType=INTEGER},
            </if>
            <if test="isEnable != null">
                is_enable = #{isEnable,jdbcType=INTEGER},
            </if>
        </set>
        where transaction_id = #{transactionId,jdbcType=INTEGER}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.neusoft.smart.pos.org.persistent.domain.CityRegionDictionary">
    update `city_region_dictionary`
    set region_number = #{regionNumber,jdbcType=INTEGER},
      parent_number = #{parentNumber,jdbcType=INTEGER},
      region_name = #{regionName,jdbcType=VARCHAR},
      short_name = #{shortName,jdbcType=VARCHAR},
      level = #{level,jdbcType=INTEGER},
      is_enable = #{isEnable,jdbcType=INTEGER}
    where transaction_id = #{transactionId,jdbcType=INTEGER}
  </update>
</mapper>