<?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.testor.module.messageNotice.dao.TMsgNoticeDao">
    <!-- 开启二级缓存 -->
    <!-- <cache type="org.mybatis.caches.ehcache.LoggingEhcache"/> -->
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.testor.module.messageNotice.model.domain.TMsgNotice">
        <id column="id" property="id"/>
        <id column="business_key" property="businessKey"/>
        <id column="business_id" property="businessId"/>
        <id column="title" property="title"/>
        <id column="content" property="content"/>
        <id column="is_read" property="isRead"/>
        <id column="tenant_id" property="tenantId"/>
        <id column="user_id" property="userId"/>
    </resultMap>

    <resultMap id="countUnReadResult" type="java.util.HashMap">
        <result column="num" property="num" javaType="java.lang.String"/>
        <result column="businessKey" property="businessKey" javaType="java.lang.String"/>
    </resultMap>

    <select id="countUnRead" resultMap="countUnReadResult">
        select count(id) num, business_key businessKey
        FROM
         t_msg_notice
        WHERE
            user_id= #{userId}
          and status = 0 and is_read = 0
        group by business_key
    </select>
</mapper>