<?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.wzj.soopin.im.mapper.SysMessageMapper">

    <resultMap type="com.wzj.soopin.im.domain.vo.SysMessageVo" id="SysMessageResult">
        <id     property="id"           column="id"            />
        <result property="title"        column="title"         />
        <result property="content"      column="content"       />
        <result property="msgType"      column="msg_type"      />
        <result property="subType"      column="sub_type"      />
        <result property="senderId"     column="sender_id"     />
        <result property="scheduledTime" column="scheduled_time"/>
        <result property="status"       column="status"        />
        <result property="createBy"     column="create_by"     />
        <result property="createTime"   column="create_time"   />
        <result property="updateBy"     column="update_by"     />
        <result property="updateTime"   column="update_time"   />
    </resultMap>

    <select id="selectPageUnreadMessages" resultMap="SysMessageResult">
        SELECT m.*
        FROM sys_message m
        INNER JOIN sys_message_user mu ON m.id = mu.message_id
        WHERE mu.user_id = #{userId}
        AND mu.is_read = 0
        AND m.status = '0'
        ORDER BY m.create_time DESC
    </select>

</mapper>
