<?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.community.huiju.dao.TpUnitMapper" >
  <resultMap id="BaseResultMap" type="com.community.huiju.model.TpUnit" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="community_id" property="communityId" jdbcType="INTEGER" />
    <result column="phase_id" property="phaseId" jdbcType="INTEGER" />
    <result column="phase_name" property="phaseName" jdbcType="VARCHAR" />
    <result column="building_id" property="buildingId" jdbcType="INTEGER" />
    <result column="building_name" property="buildingName" jdbcType="VARCHAR" />
    <result column="name" property="name" jdbcType="VARCHAR" />
    <result column="sort" property="sort" jdbcType="VARCHAR" />
    <result column="create_date" property="createDate" jdbcType="TIMESTAMP" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, community_id, phase_id, phase_name, building_id, building_name, name, sort, create_date
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from tp_unit
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from tp_unit
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.community.huiju.model.TpUnit"  keyColumn="id" useGeneratedKeys="true" >
    insert into tp_unit (id, community_id, phase_id, 
      phase_name, building_id, building_name, 
      name, sort, create_date
      )
    values (#{id,jdbcType=INTEGER}, #{communityId,jdbcType=INTEGER}, #{phaseId,jdbcType=INTEGER}, 
      #{phaseName,jdbcType=VARCHAR}, #{buildingId,jdbcType=INTEGER}, #{buildingName,jdbcType=VARCHAR}, 
      #{name,jdbcType=VARCHAR}, #{sort,jdbcType=VARCHAR}, #{createDate,jdbcType=TIMESTAMP}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.community.huiju.model.TpUnit"  keyColumn="id" useGeneratedKeys="true" >
    insert into tp_unit
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="communityId != null" >
        community_id,
      </if>
      <if test="phaseId != null" >
        phase_id,
      </if>
      <if test="phaseName != null" >
        phase_name,
      </if>
      <if test="buildingId != null" >
        building_id,
      </if>
      <if test="buildingName != null" >
        building_name,
      </if>
      <if test="name != null" >
        name,
      </if>
      <if test="sort != null" >
        sort,
      </if>
      <if test="createDate != null" >
        create_date,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="communityId != null" >
        #{communityId,jdbcType=INTEGER},
      </if>
      <if test="phaseId != null" >
        #{phaseId,jdbcType=INTEGER},
      </if>
      <if test="phaseName != null" >
        #{phaseName,jdbcType=VARCHAR},
      </if>
      <if test="buildingId != null" >
        #{buildingId,jdbcType=INTEGER},
      </if>
      <if test="buildingName != null" >
        #{buildingName,jdbcType=VARCHAR},
      </if>
      <if test="name != null" >
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="sort != null" >
        #{sort,jdbcType=VARCHAR},
      </if>
      <if test="createDate != null" >
        #{createDate,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.community.huiju.model.TpUnit" >
    update tp_unit
    <set >
      <if test="communityId != null" >
        community_id = #{communityId,jdbcType=INTEGER},
      </if>
      <if test="phaseId != null" >
        phase_id = #{phaseId,jdbcType=INTEGER},
      </if>
      <if test="phaseName != null" >
        phase_name = #{phaseName,jdbcType=VARCHAR},
      </if>
      <if test="buildingId != null" >
        building_id = #{buildingId,jdbcType=INTEGER},
      </if>
      <if test="buildingName != null" >
        building_name = #{buildingName,jdbcType=VARCHAR},
      </if>
      <if test="name != null" >
        name = #{name,jdbcType=VARCHAR},
      </if>
      <if test="sort != null" >
        sort = #{sort,jdbcType=VARCHAR},
      </if>
      <if test="createDate != null" >
        create_date = #{createDate,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.community.huiju.model.TpUnit" >
    update tp_unit
    set community_id = #{communityId,jdbcType=INTEGER},
      phase_id = #{phaseId,jdbcType=INTEGER},
      phase_name = #{phaseName,jdbcType=VARCHAR},
      building_id = #{buildingId,jdbcType=INTEGER},
      building_name = #{buildingName,jdbcType=VARCHAR},
      name = #{name,jdbcType=VARCHAR},
      sort = #{sort,jdbcType=VARCHAR},
      create_date = #{createDate,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>
</mapper>