<?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.mapper.TaOrgMapper">

    <select id="listOrgForContract" resultType="com.huiju.estateagents.entity.TaOrg">
        SELECT
            *,
            t2.`name` miniAppName,
            t4.channel_proxy_name
        FROM
            ta_org t
            LEFT JOIN ta_miniapp t2 ON t.org_id = t2.org_id
            left join ta_channel_app_relation t3 on t.org_id =t3.org_id
            left join ta_channel_proxy t4 on t3.channel_id = t4.channel_id
        <where>
            <if test = "orgName != null and orgName != ''">
                t.`name` like concat('%',#{orgName},'%')
            </if>
            <if test = "miniAppName != null and miniAppName != ''">
                AND t2.`name` like concat('%',#{miniAppName},'%')
            </if>
        </where>
        ORDER BY
            t.create_date DESC
    </select>

</mapper>
