<?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.huiju.estateagents.property.dao.TpBuildingMapper" >
  <sql id="Base_Column_List" >
    id, org_id, phase, building, unit, `level`, room_no, create_date
  </sql>
  <select id="buildinglist" resultType="com.huiju.estateagents.property.model.TpBuilding">
    select
    <include refid="Base_Column_List" />
    from tp_building
    <where>
      <if test="tpBuilding.phase != null and tpBuilding.phase != ''" >
        phase = #{tpBuilding.phase,jdbcType=VARCHAR}
      </if>
      <if test="tpBuilding.building != null and tpBuilding.building != ''" >
        and building = #{tpBuilding.building,jdbcType=VARCHAR}
      </if>
      <if test="tpBuilding.unit != null and tpBuilding.unit != ''" >
        and unit = #{tpBuilding.unit,jdbcType=VARCHAR}
      </if>
      <if test="tpBuilding.level != null and tpBuilding.level != ''" >
        and `level` = #{tpBuilding.level,jdbcType=VARCHAR}
      </if>
      <if test="tpBuilding.roomNo != null and tpBuilding.roomNo != ''" >
       and room_no = #{tpBuilding.roomNo,jdbcType=VARCHAR}
      </if>
    </where>
    ORDER BY
    phase ASC,
    building ASC,
    unit ASC,
    `level` ASC,
    room_no ASC
  </select>
</mapper>