<?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.TpRentalHouseMapper">

    <select id="getRentalList" resultType="com.community.huiju.model.TpRentalHouse">
        SELECT
            t.id,
            t.house_name,
            t.rental_price,
            t.rental_type,
            t.house_type,
            t.house_status,
            t.sort,
            t.update_date,
            u.user_name
        FROM
            tp_rental_house t
        LEFT JOIN tp_user u ON t.update_user = u.id
        where 1=1
        and t.community_id = #{tpRentalHouse.communityId}
        <if test="tpRentalHouse.id != null and tpRentalHouse.id != ''">
            and t.id like concat('%',#{tpRentalHouse.id},'%')
        </if>
        <if test="tpRentalHouse.houseName != null and tpRentalHouse.houseName != ''">
            and t.house_name like concat('%',#{tpRentalHouse.houseName},'%')
        </if>
        <if test="tpRentalHouse.rentalType != null and tpRentalHouse.rentalType != ''">
            and t.rental_type  = #{tpRentalHouse.rentalType}
        </if>
        <if test="tpRentalHouse.houseType != null and tpRentalHouse.houseType != ''">
            and t.house_type  = #{tpRentalHouse.houseType}
        </if>
        <if test="tpRentalHouse.houseStatus != null and tpRentalHouse.houseStatus != ''">
            and t.house_status  = #{tpRentalHouse.houseStatus}
        </if>
        <if test="tpRentalHouse.startPrice != null and tpRentalHouse.startPrice != ''">
            and t.rental_price  >= #{tpRentalHouse.startPrice,jdbcType=INTEGER}
        </if>
        <if test="tpRentalHouse.endPrice != null and tpRentalHouse.endPrice != ''">
            and t.rental_price  &lt;= #{tpRentalHouse.endPrice,jdbcType=INTEGER}
        </if>
        order by t.sort desc, t.update_date desc
    </select>
</mapper>
