<?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.hssx.pcbms.mapper.NewsNoticeMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.hssx.pcbms.entity.NewsNotice">
        <id column="id" property="id" />
        <result column="raf_name" property="rafName" />
        <result column="ref_id" property="refId" />
        <result column="notice_type" property="noticeType" />
        <result column="content" property="content" />
        <result column="indate" property="indate" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, raf_name, ref_id, notice_type, content, indate
    </sql>

    <select id="selectListByCondition" resultMap="BaseResultMap">
        select
              nn.id, nn.notice_type, nn.content, nn.indate
          from
              news_notice nn
          left join news_notice_user nnu
          on nn.id = nnu.news_id
          where nnu.user_id = #{uid}
    </select>
    
    <select id="getNoReadNewsCount" resultType="int">
        select
              count(nn.id)
          from
              news_notice nn
          left join news_notice_user nnu
          on nn.id = nnu.news_id
          where nnu.user_id = #{uid}
          and nnu.is_read = 0
    </select>

</mapper>
