<?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.yunzhi.marketing.xlk.mapper.SearchHouseMapper">

    <select id="selectSearchHouseList" resultType="com.yunzhi.marketing.xlk.vo.SearchHouseVO">
        SELECT
            t.*,
            p.avatarurl,
            p.`nickname`,
            p.phone,
            p.gender,
            c.`name`
        FROM
            xlk_search_house t
            LEFT JOIN ta_person p ON t.person_id = p.person_id
            LEFT JOIN td_city c on t.intent_area = c.id
            WHERE t.ORG_ID = #{params.orgId}
                and t.type = #{params.type}
        <if test="params.nickname != null and params.nickname != ''">
            and p.nickname like concat('%', #{params.nickname}, '%')
        </if>
        <if test="params.phone != null and params.phone != ''">
            and p.phone like concat('%', #{params.phone}, '%')
        </if>
        <if test="params.status != null and params.status != ''">
            and t.status = #{params.status}
        </if>
    </select>
    <select id="selectSearchHouseDetail" resultType="com.yunzhi.marketing.xlk.vo.SearchHouseVO">
        SELECT
            t.*,
            p.avatarurl,
            p.`nickname`,
            p.phone,
            p.gender
        FROM
            xlk_search_house t
            LEFT JOIN ta_person p ON t.person_id = p.person_id
            WHERE t.id = #{id}
    </select>
</mapper>
