<?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.goafanti.common.dao.DistrictGlossoryMapper" >
  <resultMap id="BaseResultMap" type="com.goafanti.common.model.DistrictGlossory" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="name" property="name" jdbcType="VARCHAR" />
    <result column="pid" property="pid" jdbcType="INTEGER" />
    <result column="level" property="level" jdbcType="INTEGER" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, name, pid, level
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from district_glossory
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from district_glossory
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.goafanti.common.model.DistrictGlossory" >
    insert into district_glossory (id, name, pid, 
      level)
    values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{pid,jdbcType=INTEGER}, 
      #{level,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" parameterType="com.goafanti.common.model.DistrictGlossory" >
    insert into district_glossory
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="name != null" >
        name,
      </if>
      <if test="pid != null" >
        pid,
      </if>
      <if test="level != null" >
        level,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="name != null" >
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="pid != null" >
        #{pid,jdbcType=INTEGER},
      </if>
      <if test="level != null" >
        #{level,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.DistrictGlossory" >
    update district_glossory
    <set >
      <if test="name != null" >
        name = #{name,jdbcType=VARCHAR},
      </if>
      <if test="pid != null" >
        pid = #{pid,jdbcType=INTEGER},
      </if>
      <if test="level != null" >
        level = #{level,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.DistrictGlossory" >
    update district_glossory
    set name = #{name,jdbcType=VARCHAR},
      pid = #{pid,jdbcType=INTEGER},
      level = #{level,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>
  
  <select id="findByPid" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from district_glossory
    where pid = #{pid,jdbcType=INTEGER}
  </select>
  
  <select id="selectNameById" parameterType="java.lang.Integer" resultType="String">
    select name from aft.district_glossory where id=#{id,jdbcType=INTEGER}
  </select>
  
  <select id="getProvince" resultType="com.goafanti.common.bo.ProvinceBo">
    select 
    id,name,pid,level
    from district_glossory
    where level=1
  </select>
  
  <select id="getCity" resultType="com.goafanti.common.bo.CityBo" >
    select 
    id,name,pid,level
    from district_glossory
    where level=2
  </select>
  
  <select id="getArea" resultType="com.goafanti.common.bo.AreaBo" >
    select 
    id,name,pid,level
    from district_glossory
    where level=3
  </select>
</mapper>