<?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="org.springblade.modules.warn.mapper.OutsideWarnInfoMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="entityResultMap" type="org.springblade.modules.warn.entity.OutsideWarnInfoEntity">
        <result column="business_id" property="warnId"/>
        <result column="dept_name" property="deptName"/>
        <result column="sender_name" property="senderName"/>
        <result column="MESSAGE_INFO" property="messageInfo"/>
    </resultMap>

    <!--SELECT_ZHSL_USER-->
    <select id="selectList" resultMap="entityResultMap">
            select
            message.*,
            com.name,
            com.posi_tion,
            CASE message.send_object WHEN '2' THEN
            '社会公众' ELSE '责任人' END sendObjectName,
            case when message.send_type='0' then info.USER_NAME else
            message.send_user_name end sender_name,
            dept.dept_name
            from
            SELECT_ZHSL_USER.st_message_send message
            LEFT JOIN SELECT_ZHSL_USER.st_communication com ON message.user_name_id = com.id
            left join SELECT_ZHSL_USER.ST_INFORMATION info on info.warn_id=message.business_id
            left join SELECT_ZHSL_USER.st_dept_new dept on dept.dept_code=com.DEPT_CODE
            where message.business_id = #{dto.warnId}
            and message.send_type='1'
    </select>

</mapper>
