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

    <select id="getAvailableList" resultType="com.huiju.estateagents.entity.TaMpTemplate">
        SELECT DISTINCT
            t.*,
            s.name as evt_name,
            s.evt_date,
            s.is_solar,
            s.wishes
        FROM
            ta_mp_template t
            INNER JOIN tp_message_event s ON t.org_id = s.org_id
            AND t.type_code = s.evt_type
        WHERE
            t.org_id = #{orgId}
            AND t.type_code = #{typeCode}
            AND t.`status` = 1
            AND s.`status` = 1
    </select>
    <select id="getByCode" resultType="com.huiju.estateagents.entity.TaMpTemplate">
        SELECT
            t.*
        FROM
            ta_mp_template t
        WHERE
            t.org_id = #{orgId}
            AND t.type_code = #{typeCode}
            AND t.`status` = 1
    </select>
</mapper>
