<?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.TpBuildingOwnerInfoMapper" >
  <resultMap id="BaseResultMap" type="com.community.huiju.model.TpBuildingOwnerInfo" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="community_id" property="communityId" jdbcType="INTEGER" />
    <result column="id_card" property="idCard" jdbcType="VARCHAR" />
    <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="unit_id" property="unitId" jdbcType="INTEGER" />
    <result column="unit_name" property="unitName" jdbcType="VARCHAR" />
    <result column="level_id" property="levelId" jdbcType="INTEGER" />
    <result column="level_name" property="levelName" jdbcType="VARCHAR" />
    <result column="room_no_id" property="roomNoId" jdbcType="INTEGER" />
    <result column="room_no_name" property="roomNoName" jdbcType="VARCHAR" />
    <result column="owner_name" property="ownerName" jdbcType="VARCHAR" />
    <result column="owner_tel" property="ownerTel" jdbcType="VARCHAR" />
    <result column="gender" property="gender" jdbcType="CHAR" />
    <result column="pair_status" property="pairStatus" jdbcType="CHAR" />
    <result column="verify_status" property="verifyStatus" jdbcType="CHAR" />
    <result column="sort" property="sort" jdbcType="VARCHAR" />
    <result column="create_user" property="createUser" jdbcType="INTEGER" />
    <result column="create_date" property="createDate" jdbcType="TIMESTAMP" />
    <result column="update_user" property="updateUser" jdbcType="INTEGER" />
    <result column="update_date" property="updateDate" jdbcType="TIMESTAMP" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, community_id, id_card, phase_id, phase_name, building_id, building_name, unit_id, 
    unit_name, level_id, level_name, room_no_id, room_no_name, owner_name, owner_tel, 
    gender, pair_status, verify_status, sort, create_user, create_date, update_user, 
    update_date
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select
    <include refid="Base_Column_List" />
    from tp_building_owner_info
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from tp_building_owner_info
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.community.huiju.model.TpBuildingOwnerInfo"  keyProperty="id" useGeneratedKeys="true"  >
    insert into tp_building_owner_info (id, community_id, id_card, 
      phase_id, phase_name, building_id, 
      building_name, unit_id, unit_name, 
      level_id, level_name, room_no_id, 
      room_no_name, owner_name, owner_tel, 
      gender, pair_status, verify_status, 
      sort, create_user, create_date, 
      update_user, update_date)
    values (#{id,jdbcType=INTEGER}, #{communityId,jdbcType=INTEGER}, #{idCard,jdbcType=VARCHAR}, 
      #{phaseId,jdbcType=INTEGER}, #{phaseName,jdbcType=VARCHAR}, #{buildingId,jdbcType=INTEGER}, 
      #{buildingName,jdbcType=VARCHAR}, #{unitId,jdbcType=INTEGER}, #{unitName,jdbcType=VARCHAR}, 
      #{levelId,jdbcType=INTEGER}, #{levelName,jdbcType=VARCHAR}, #{roomNoId,jdbcType=INTEGER}, 
      #{roomNoName,jdbcType=VARCHAR}, #{ownerName,jdbcType=VARCHAR}, #{ownerTel,jdbcType=VARCHAR}, 
      #{gender,jdbcType=CHAR}, #{pairStatus,jdbcType=CHAR}, #{verifyStatus,jdbcType=CHAR}, 
      #{sort,jdbcType=VARCHAR}, #{createUser,jdbcType=INTEGER}, #{createDate,jdbcType=TIMESTAMP}, 
      #{updateUser,jdbcType=INTEGER}, #{updateDate,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" parameterType="com.community.huiju.model.TpBuildingOwnerInfo" keyProperty="id" useGeneratedKeys="true" >
    insert into tp_building_owner_info
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="communityId != null" >
        community_id,
      </if>
      <if test="idCard != null" >
        id_card,
      </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="unitId != null" >
        unit_id,
      </if>
      <if test="unitName != null" >
        unit_name,
      </if>
      <if test="levelId != null" >
        level_id,
      </if>
      <if test="levelName != null" >
        level_name,
      </if>
      <if test="roomNoId != null" >
        room_no_id,
      </if>
      <if test="roomNoName != null" >
        room_no_name,
      </if>
      <if test="ownerName != null" >
        owner_name,
      </if>
      <if test="ownerTel != null" >
        owner_tel,
      </if>
      <if test="gender != null" >
        gender,
      </if>
      <if test="pairStatus != null" >
        pair_status,
      </if>
      <if test="verifyStatus != null" >
        verify_status,
      </if>
      <if test="sort != null" >
        sort,
      </if>
      <if test="createUser != null" >
        create_user,
      </if>
      <if test="createDate != null" >
        create_date,
      </if>
      <if test="updateUser != null" >
        update_user,
      </if>
      <if test="updateDate != null" >
        update_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="idCard != null" >
        #{idCard,jdbcType=VARCHAR},
      </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="unitId != null" >
        #{unitId,jdbcType=INTEGER},
      </if>
      <if test="unitName != null" >
        #{unitName,jdbcType=VARCHAR},
      </if>
      <if test="levelId != null" >
        #{levelId,jdbcType=INTEGER},
      </if>
      <if test="levelName != null" >
        #{levelName,jdbcType=VARCHAR},
      </if>
      <if test="roomNoId != null" >
        #{roomNoId,jdbcType=INTEGER},
      </if>
      <if test="roomNoName != null" >
        #{roomNoName,jdbcType=VARCHAR},
      </if>
      <if test="ownerName != null" >
        #{ownerName,jdbcType=VARCHAR},
      </if>
      <if test="ownerTel != null" >
        #{ownerTel,jdbcType=VARCHAR},
      </if>
      <if test="gender != null" >
        #{gender,jdbcType=CHAR},
      </if>
      <if test="pairStatus != null" >
        #{pairStatus,jdbcType=CHAR},
      </if>
      <if test="verifyStatus != null" >
        #{verifyStatus,jdbcType=CHAR},
      </if>
      <if test="sort != null" >
        #{sort,jdbcType=VARCHAR},
      </if>
      <if test="createUser != null" >
        #{createUser,jdbcType=INTEGER},
      </if>
      <if test="createDate != null" >
        #{createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="updateUser != null" >
        #{updateUser,jdbcType=INTEGER},
      </if>
      <if test="updateDate != null" >
        #{updateDate,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.community.huiju.model.TpBuildingOwnerInfo" >
    update tp_building_owner_info
    <set >
      <if test="communityId != null" >
        community_id = #{communityId,jdbcType=INTEGER},
      </if>
      <if test="idCard != null" >
        id_card = #{idCard,jdbcType=VARCHAR},
      </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="unitId != null" >
        unit_id = #{unitId,jdbcType=INTEGER},
      </if>
      <if test="unitName != null" >
        unit_name = #{unitName,jdbcType=VARCHAR},
      </if>
      <if test="levelId != null" >
        level_id = #{levelId,jdbcType=INTEGER},
      </if>
      <if test="levelName != null" >
        level_name = #{levelName,jdbcType=VARCHAR},
      </if>
      <if test="roomNoId != null" >
        room_no_id = #{roomNoId,jdbcType=INTEGER},
      </if>
      <if test="roomNoName != null" >
        room_no_name = #{roomNoName,jdbcType=VARCHAR},
      </if>
      <if test="ownerName != null" >
        owner_name = #{ownerName,jdbcType=VARCHAR},
      </if>
      <if test="ownerTel != null" >
        owner_tel = #{ownerTel,jdbcType=VARCHAR},
      </if>
      <if test="gender != null" >
        gender = #{gender,jdbcType=CHAR},
      </if>
      <if test="pairStatus != null" >
        pair_status = #{pairStatus,jdbcType=CHAR},
      </if>
      <if test="verifyStatus != null" >
        verify_status = #{verifyStatus,jdbcType=CHAR},
      </if>
      <if test="sort != null" >
        sort = #{sort,jdbcType=VARCHAR},
      </if>
      <if test="createUser != null" >
        create_user = #{createUser,jdbcType=INTEGER},
      </if>
      <if test="createDate != null" >
        create_date = #{createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="updateUser != null" >
        update_user = #{updateUser,jdbcType=INTEGER},
      </if>
      <if test="updateDate != null" >
        update_date = #{updateDate,jdbcType=TIMESTAMP},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.community.huiju.model.TpBuildingOwnerInfo" >
    update tp_building_owner_info
    set community_id = #{communityId,jdbcType=INTEGER},
      id_card = #{idCard,jdbcType=VARCHAR},
      phase_id = #{phaseId,jdbcType=INTEGER},
      phase_name = #{phaseName,jdbcType=VARCHAR},
      building_id = #{buildingId,jdbcType=INTEGER},
      building_name = #{buildingName,jdbcType=VARCHAR},
      unit_id = #{unitId,jdbcType=INTEGER},
      unit_name = #{unitName,jdbcType=VARCHAR},
      level_id = #{levelId,jdbcType=INTEGER},
      level_name = #{levelName,jdbcType=VARCHAR},
      room_no_id = #{roomNoId,jdbcType=INTEGER},
      room_no_name = #{roomNoName,jdbcType=VARCHAR},
      owner_name = #{ownerName,jdbcType=VARCHAR},
      owner_tel = #{ownerTel,jdbcType=VARCHAR},
      gender = #{gender,jdbcType=CHAR},
      pair_status = #{pairStatus,jdbcType=CHAR},
      verify_status = #{verifyStatus,jdbcType=CHAR},
      sort = #{sort,jdbcType=VARCHAR},
      create_user = #{createUser,jdbcType=INTEGER},
      create_date = #{createDate,jdbcType=TIMESTAMP},
      update_user = #{updateUser,jdbcType=INTEGER},
      update_date = #{updateDate,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updatOwnerTel" parameterType="com.community.huiju.model.TpBuildingOwnerInfo" >
    update tp_building_owner_info
    <set >
      <if test="communityId != null" >
        community_id = #{communityId,jdbcType=INTEGER},
      </if>
      <if test="idCard != null" >
        id_card = #{idCard,jdbcType=VARCHAR},
      </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="unitId != null" >
        unit_id = #{unitId,jdbcType=INTEGER},
      </if>
      <if test="unitName != null" >
        unit_name = #{unitName,jdbcType=VARCHAR},
      </if>
      <if test="levelId != null" >
        level_id = #{levelId,jdbcType=INTEGER},
      </if>
      <if test="levelName != null" >
        level_name = #{levelName,jdbcType=VARCHAR},
      </if>
      <if test="name != null" >
        name = #{name,jdbcType=VARCHAR},
      </if>
      <if test="ownerName != null" >
        owner_name = #{ownerName,jdbcType=VARCHAR},
      </if>
      <if test="ownerTel != null" >
        owner_tel = #{ownerTel,jdbcType=VARCHAR},
      </if>
      <if test="gender != null" >
        gender = #{gender,jdbcType=CHAR},
      </if>
      <if test="pairStatus != null" >
        pair_status = #{pairStatus,jdbcType=CHAR},
      </if>
      <if test="verifyStatus != null" >
        verify_status = #{verifyStatus,jdbcType=CHAR},
      </if>
      <if test="sort != null" >
        sort = #{sort,jdbcType=VARCHAR},
      </if>
      <if test="createUser != null" >
        create_user = #{createUser,jdbcType=INTEGER},
      </if>
      <if test="createDate != null" >
        create_date = #{createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="updateUser != null" >
        update_user = #{updateUser,jdbcType=INTEGER},
      </if>
      <if test="updateDate != null" >
        update_date = #{updateDate,jdbcType=TIMESTAMP},
      </if>
    </set>
    where community_id = #{communityId,jdbcType=INTEGER} and wnerTel =  owner_tel = #{ownerTel,jdbcType=VARCHAR}
  </update>

  <select id="selectOwnerTel" resultMap="BaseResultMap" parameterType="string">
    select
    <include refid="Base_Column_List"/>
    from
    tp_building_owner_info
    where  owner_tel = #{ownerTel,jdbcType=VARCHAR}
  </select>

</mapper>