<?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.ads.business.dao.DocTypeConversationRelDao">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ads.business.entity.DocTypeConversationRel">
        <id column="id" property="id" />
        <result column="type_id" property="typeId" />
        <result column="chat_id" property="chatId" />
        <result column="open_conversation_id" property="openConversationId" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, type_id, chat_id, open_conversation_id
    </sql>

    <select id="getList" resultMap="BaseResultMap">
        select  hdcr.id,
                hdcr.type_id,
                hdcr.chat_id,
                hdcr.open_conversation_id
        from    hsay_doc_type_conversation_rel hdcr right join hsay_conversation hc on hdcr.chat_id = hc.chat_id and hc.status = 1
        where   hdcr.type_id = #{typeId}
    </select>

    <select id="getListByTypeId" resultType="java.lang.String">
        SELECT
            hcur.phone
        FROM
            hsay_doc_type_conversation_rel hdtcr
            LEFT JOIN hsay_conversation_user_rel hcur ON hdtcr.chat_id = hcur.chat_id
        WHERE
            hdtcr.type_id =  #{typeId}
    </select>



</mapper>
