<?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.dgtis.dorm.manager.db.dao.AlumniRegionMapper" >
  <resultMap id="BaseResultMap" type="com.dgtis.dorm.manager.db.domain.AlumniRegion" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="pid" property="pid" jdbcType="INTEGER" />
    <result column="name" property="name" jdbcType="VARCHAR" />
    <result column="type" property="type" jdbcType="TINYINT" />
    <result column="code" property="code" jdbcType="INTEGER" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, pid, name, type, code
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from zhll_region
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from zhll_region
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.dgtis.dorm.manager.db.domain.AlumniRegion" >
    insert into zhll_region (id, pid, name,
      type, code)
    values (#{id,jdbcType=INTEGER}, #{pid,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, 
      #{type,jdbcType=TINYINT}, #{code,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" parameterType="com.dgtis.dorm.manager.db.domain.AlumniRegion" >
    insert into zhll_region
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="pid != null" >
        pid,
      </if>
      <if test="name != null" >
        name,
      </if>
      <if test="type != null" >
        type,
      </if>
      <if test="code != null" >
        code,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="pid != null" >
        #{pid,jdbcType=INTEGER},
      </if>
      <if test="name != null" >
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="type != null" >
        #{type,jdbcType=TINYINT},
      </if>
      <if test="code != null" >
        #{code,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.dgtis.dorm.manager.db.domain.AlumniRegion" >
    update zhll_region
    <set >
      <if test="pid != null" >
        pid = #{pid,jdbcType=INTEGER},
      </if>
      <if test="name != null" >
        name = #{name,jdbcType=VARCHAR},
      </if>
      <if test="type != null" >
        type = #{type,jdbcType=TINYINT},
      </if>
      <if test="code != null" >
        code = #{code,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.dgtis.dorm.manager.db.domain.AlumniRegion" >
    update zhll_region
    set pid = #{pid,jdbcType=INTEGER},
      name = #{name,jdbcType=VARCHAR},
      type = #{type,jdbcType=TINYINT},
      code = #{code,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>
  
  <select id="selectByPid" parameterType="java.lang.Integer" resultMap="BaseResultMap">
  	select distinct
    <include refid="Base_Column_List" />
    from zhll_region where
    pid = #{parentId,jdbcType=INTEGER} 
  </select>
</mapper>