<?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.pengzu.dao.PengzuRegionDao">
  <resultMap id="BaseResultMap" type="com.pengzu.entity.PengzuRegion">
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="code" jdbcType="VARCHAR" property="code" />
    <result column="parent_code" jdbcType="VARCHAR" property="parentCode" />
    <result column="region_name" jdbcType="VARCHAR" property="regionName" />
    <result column="abb_name" jdbcType="VARCHAR" property="abbName" />
    <result column="region_type" jdbcType="VARCHAR" property="regionType" />
    <result column="zip" jdbcType="VARCHAR" property="zip" />
    <result column="creater_id" jdbcType="VARCHAR" property="createrId" />
    <result column="creater" jdbcType="VARCHAR" property="creater" />
    <result column="gmt_create" jdbcType="TIMESTAMP" property="gmtCreate" />
    <result column="modifier_id" jdbcType="VARCHAR" property="modifierId" />
    <result column="modifier" jdbcType="VARCHAR" property="modifier" />
    <result column="gmt_modifier" jdbcType="TIMESTAMP" property="gmtModifier" />
    <result column="is_deleted" jdbcType="INTEGER" property="isDeleted" />
  </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, code, parent_code, region_name, abb_name, region_type, zip, creater_id, creater, 
    gmt_create, modifier_id, modifier, gmt_modifier, is_deleted
  </sql>
  <select id="selectByExample" parameterType="com.pengzu.entity.PengzuRegionExample" resultMap="BaseResultMap">
    select
    <if test="distinct">
      distinct
    </if>
    'true' as QUERYID,
    <include refid="Base_Column_List" />
    from pengzucms.pengzu_region
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from pengzucms.pengzu_region
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from pengzucms.pengzu_region
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByExample" parameterType="com.pengzu.entity.PengzuRegionExample">
    delete from pengzucms.pengzu_region
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.pengzu.entity.PengzuRegion">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into pengzucms.pengzu_region (code, parent_code, region_name,
      abb_name, region_type, zip, 
      creater_id, creater, gmt_create, 
      modifier_id, modifier, gmt_modifier, 
      is_deleted)
    values (#{code,jdbcType=VARCHAR}, #{parentCode,jdbcType=VARCHAR}, #{regionName,jdbcType=VARCHAR}, 
      #{abbName,jdbcType=VARCHAR}, #{regionType,jdbcType=VARCHAR}, #{zip,jdbcType=VARCHAR}, 
      #{createrId,jdbcType=VARCHAR}, #{creater,jdbcType=VARCHAR}, #{gmtCreate,jdbcType=TIMESTAMP}, 
      #{modifierId,jdbcType=VARCHAR}, #{modifier,jdbcType=VARCHAR}, #{gmtModifier,jdbcType=TIMESTAMP}, 
      #{isDeleted,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" parameterType="com.pengzu.entity.PengzuRegion">
    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
      SELECT LAST_INSERT_ID()
    </selectKey>
    insert into pengzucms.pengzu_region
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="code != null">
        code,
      </if>
      <if test="parentCode != null">
        parent_code,
      </if>
      <if test="regionName != null">
        region_name,
      </if>
      <if test="abbName != null">
        abb_name,
      </if>
      <if test="regionType != null">
        region_type,
      </if>
      <if test="zip != null">
        zip,
      </if>
      <if test="createrId != null">
        creater_id,
      </if>
      <if test="creater != null">
        creater,
      </if>
      <if test="gmtCreate != null">
        gmt_create,
      </if>
      <if test="modifierId != null">
        modifier_id,
      </if>
      <if test="modifier != null">
        modifier,
      </if>
      <if test="gmtModifier != null">
        gmt_modifier,
      </if>
      <if test="isDeleted != null">
        is_deleted,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="code != null">
        #{code,jdbcType=VARCHAR},
      </if>
      <if test="parentCode != null">
        #{parentCode,jdbcType=VARCHAR},
      </if>
      <if test="regionName != null">
        #{regionName,jdbcType=VARCHAR},
      </if>
      <if test="abbName != null">
        #{abbName,jdbcType=VARCHAR},
      </if>
      <if test="regionType != null">
        #{regionType,jdbcType=VARCHAR},
      </if>
      <if test="zip != null">
        #{zip,jdbcType=VARCHAR},
      </if>
      <if test="createrId != null">
        #{createrId,jdbcType=VARCHAR},
      </if>
      <if test="creater != null">
        #{creater,jdbcType=VARCHAR},
      </if>
      <if test="gmtCreate != null">
        #{gmtCreate,jdbcType=TIMESTAMP},
      </if>
      <if test="modifierId != null">
        #{modifierId,jdbcType=VARCHAR},
      </if>
      <if test="modifier != null">
        #{modifier,jdbcType=VARCHAR},
      </if>
      <if test="gmtModifier != null">
        #{gmtModifier,jdbcType=TIMESTAMP},
      </if>
      <if test="isDeleted != null">
        #{isDeleted,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.pengzu.entity.PengzuRegionExample" resultType="java.lang.Long">
    select count(*) from pengzucms.pengzu_region
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    update pengzucms.pengzu_region
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=BIGINT},
      </if>
      <if test="record.code != null">
        code = #{record.code,jdbcType=VARCHAR},
      </if>
      <if test="record.parentCode != null">
        parent_code = #{record.parentCode,jdbcType=VARCHAR},
      </if>
      <if test="record.regionName != null">
        region_name = #{record.regionName,jdbcType=VARCHAR},
      </if>
      <if test="record.abbName != null">
        abb_name = #{record.abbName,jdbcType=VARCHAR},
      </if>
      <if test="record.regionType != null">
        region_type = #{record.regionType,jdbcType=VARCHAR},
      </if>
      <if test="record.zip != null">
        zip = #{record.zip,jdbcType=VARCHAR},
      </if>
      <if test="record.createrId != null">
        creater_id = #{record.createrId,jdbcType=VARCHAR},
      </if>
      <if test="record.creater != null">
        creater = #{record.creater,jdbcType=VARCHAR},
      </if>
      <if test="record.gmtCreate != null">
        gmt_create = #{record.gmtCreate,jdbcType=TIMESTAMP},
      </if>
      <if test="record.modifierId != null">
        modifier_id = #{record.modifierId,jdbcType=VARCHAR},
      </if>
      <if test="record.modifier != null">
        modifier = #{record.modifier,jdbcType=VARCHAR},
      </if>
      <if test="record.gmtModifier != null">
        gmt_modifier = #{record.gmtModifier,jdbcType=TIMESTAMP},
      </if>
      <if test="record.isDeleted != null">
        is_deleted = #{record.isDeleted,jdbcType=INTEGER},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    update pengzucms.pengzu_region
    set id = #{record.id,jdbcType=BIGINT},
      code = #{record.code,jdbcType=VARCHAR},
      parent_code = #{record.parentCode,jdbcType=VARCHAR},
      region_name = #{record.regionName,jdbcType=VARCHAR},
      abb_name = #{record.abbName,jdbcType=VARCHAR},
      region_type = #{record.regionType,jdbcType=VARCHAR},
      zip = #{record.zip,jdbcType=VARCHAR},
      creater_id = #{record.createrId,jdbcType=VARCHAR},
      creater = #{record.creater,jdbcType=VARCHAR},
      gmt_create = #{record.gmtCreate,jdbcType=TIMESTAMP},
      modifier_id = #{record.modifierId,jdbcType=VARCHAR},
      modifier = #{record.modifier,jdbcType=VARCHAR},
      gmt_modifier = #{record.gmtModifier,jdbcType=TIMESTAMP},
      is_deleted = #{record.isDeleted,jdbcType=INTEGER}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.pengzu.entity.PengzuRegion">
    update pengzucms.pengzu_region
    <set>
      <if test="code != null">
        code = #{code,jdbcType=VARCHAR},
      </if>
      <if test="parentCode != null">
        parent_code = #{parentCode,jdbcType=VARCHAR},
      </if>
      <if test="regionName != null">
        region_name = #{regionName,jdbcType=VARCHAR},
      </if>
      <if test="abbName != null">
        abb_name = #{abbName,jdbcType=VARCHAR},
      </if>
      <if test="regionType != null">
        region_type = #{regionType,jdbcType=VARCHAR},
      </if>
      <if test="zip != null">
        zip = #{zip,jdbcType=VARCHAR},
      </if>
      <if test="createrId != null">
        creater_id = #{createrId,jdbcType=VARCHAR},
      </if>
      <if test="creater != null">
        creater = #{creater,jdbcType=VARCHAR},
      </if>
      <if test="gmtCreate != null">
        gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
      </if>
      <if test="modifierId != null">
        modifier_id = #{modifierId,jdbcType=VARCHAR},
      </if>
      <if test="modifier != null">
        modifier = #{modifier,jdbcType=VARCHAR},
      </if>
      <if test="gmtModifier != null">
        gmt_modifier = #{gmtModifier,jdbcType=TIMESTAMP},
      </if>
      <if test="isDeleted != null">
        is_deleted = #{isDeleted,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.pengzu.entity.PengzuRegion">
    update pengzucms.pengzu_region
    set code = #{code,jdbcType=VARCHAR},
      parent_code = #{parentCode,jdbcType=VARCHAR},
      region_name = #{regionName,jdbcType=VARCHAR},
      abb_name = #{abbName,jdbcType=VARCHAR},
      region_type = #{regionType,jdbcType=VARCHAR},
      zip = #{zip,jdbcType=VARCHAR},
      creater_id = #{createrId,jdbcType=VARCHAR},
      creater = #{creater,jdbcType=VARCHAR},
      gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},
      modifier_id = #{modifierId,jdbcType=VARCHAR},
      modifier = #{modifier,jdbcType=VARCHAR},
      gmt_modifier = #{gmtModifier,jdbcType=TIMESTAMP},
      is_deleted = #{isDeleted,jdbcType=INTEGER}
    where id = #{id,jdbcType=BIGINT}
  </update>
</mapper>