2024-11-28 16:05:52 +08:00
|
|
|
<?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">
|
2025-01-08 18:55:05 +08:00
|
|
|
<mapper namespace="com.zsc.edu.gateway.modules.message.repo.UserNoticeRepository">
|
|
|
|
<resultMap id="userNoticeMap" type="com.zsc.edu.gateway.modules.message.vo.UserNoticeVo">
|
2024-12-06 13:09:20 +08:00
|
|
|
<id column="message_id" jdbcType="BIGINT" property="messageId"/>
|
2024-11-28 16:05:52 +08:00
|
|
|
<result column="is_read" jdbcType="BOOLEAN" property="isRead"/>
|
|
|
|
<result column="read_time" jdbcType="TIMESTAMP" property="readTime"/>
|
|
|
|
<result column="username" jdbcType="VARCHAR" property="username"/>
|
|
|
|
<result column="type" jdbcType="INTEGER" property="type"/>
|
|
|
|
<result column="system" jdbcType="BOOLEAN" property="system"/>
|
|
|
|
<result column="email" jdbcType="BOOLEAN" property="email"/>
|
|
|
|
<result column="sms" jdbcType="BOOLEAN" property="sms"/>
|
|
|
|
<result column="html" jdbcType="BOOLEAN" property="html"/>
|
|
|
|
<result column="title" jdbcType="VARCHAR" property="title"/>
|
|
|
|
<result column="content" jdbcType="VARCHAR" property="content"/>
|
|
|
|
<result column="create_by" jdbcType="VARCHAR" property="createBy"/>
|
|
|
|
<result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
|
|
|
|
<result column="create_time" jdbcType="DATE" property="createTime"/>
|
|
|
|
<result column="update_time" jdbcType="DATE" property="updateTime"/>
|
|
|
|
<result column="remark" jdbcType="VARCHAR" property="remark"/>
|
2024-12-06 13:09:20 +08:00
|
|
|
</resultMap>
|
|
|
|
|
2025-01-08 18:55:05 +08:00
|
|
|
<resultMap id="AdminNoticeMap" type="com.zsc.edu.gateway.modules.message.vo.AdminNoticeVo">
|
2024-12-06 13:09:20 +08:00
|
|
|
<id column="id" jdbcType="BIGINT" property="id"/>
|
|
|
|
<result column="type" jdbcType="INTEGER" property="type"/>
|
|
|
|
<result column="system" jdbcType="BOOLEAN" property="system"/>
|
|
|
|
<result column="email" jdbcType="BOOLEAN" property="email"/>
|
|
|
|
<result column="sms" jdbcType="BOOLEAN" property="sms"/>
|
|
|
|
<result column="html" jdbcType="BOOLEAN" property="html"/>
|
|
|
|
<result column="title" jdbcType="VARCHAR" property="title"/>
|
|
|
|
<result column="content" jdbcType="VARCHAR" property="content"/>
|
|
|
|
<result column="remark" jdbcType="VARCHAR" property="remark"/>
|
|
|
|
<result column="user_count" jdbcType="INTEGER" property="userCount"/>
|
|
|
|
<result column="read_count" jdbcType="INTEGER" property="readCount"/>
|
2024-11-28 16:05:52 +08:00
|
|
|
</resultMap>
|
2025-01-08 18:55:05 +08:00
|
|
|
<select id="selectByNoticeIdAndUserId" resultType="com.zsc.edu.gateway.modules.message.vo.UserNoticeVo"
|
|
|
|
resultMap="userNoticeMap">
|
|
|
|
select sun.*,sn.*,su.username,su.address,su.avatar,su.name
|
|
|
|
from sys_user_notice sun
|
|
|
|
left join sys_user su on sun.user_id = su.id
|
|
|
|
left join sys_notice sn on sn.id = sun.notice_id
|
2024-11-28 16:05:52 +08:00
|
|
|
<where>
|
2025-01-08 18:55:05 +08:00
|
|
|
sun.notice_id=#{noticeId}
|
|
|
|
and sun.user_id=#{userId}
|
2024-11-28 16:05:52 +08:00
|
|
|
</where>
|
|
|
|
</select>
|
|
|
|
|
2025-01-08 18:55:05 +08:00
|
|
|
<select id="page" resultType="com.zsc.edu.gateway.modules.message.vo.UserNoticeVo" resultMap="userNoticeMap">
|
|
|
|
select sun.*,sn.*,su.username,su.address,su.avatar,su.name
|
|
|
|
from sys_user_notice sun
|
|
|
|
left join sys_user su on sun.user_id = su.id
|
|
|
|
left join sys_notice sn on sn.id = sun.notice_id
|
2024-12-06 13:09:20 +08:00
|
|
|
<where>
|
|
|
|
<if test="query.userId != null">
|
2025-01-08 18:55:05 +08:00
|
|
|
AND sun.user_id = #{query.userId}
|
2024-12-06 13:09:20 +08:00
|
|
|
</if>
|
|
|
|
<if test="query.title != null and query.title != ''">
|
2025-01-08 18:55:05 +08:00
|
|
|
AND sn.title LIKE CONCAT('%', #{query.title}, '%')
|
2024-12-06 13:09:20 +08:00
|
|
|
</if>
|
|
|
|
<if test="query.type != null">
|
2025-01-08 18:55:05 +08:00
|
|
|
AND sn.type = #{query.type}
|
2024-12-06 13:09:20 +08:00
|
|
|
</if>
|
|
|
|
<if test="query.name != null and query.name != ''">
|
|
|
|
AND su.username LIKE CONCAT('%', #{query.name}, '%')
|
|
|
|
</if>
|
|
|
|
<if test="query.system != null">
|
2025-01-08 18:55:05 +08:00
|
|
|
AND sn.system = #{query.system}
|
2024-12-06 13:09:20 +08:00
|
|
|
</if>
|
|
|
|
<if test="query.isRead != null">
|
2025-01-08 18:55:05 +08:00
|
|
|
AND sun.is_read = #{query.isRead}
|
2024-12-06 13:09:20 +08:00
|
|
|
</if>
|
|
|
|
<if test="query.createAtBegin != null and query.createAtEnd != null">
|
2025-01-08 18:55:05 +08:00
|
|
|
AND sn.create_time BETWEEN #{query.createAtBegin} AND #{query.createAtEnd}
|
2024-12-06 13:09:20 +08:00
|
|
|
</if>
|
|
|
|
</where>
|
2024-11-28 16:05:52 +08:00
|
|
|
ORDER BY
|
2025-01-08 18:55:05 +08:00
|
|
|
sn.create_time DESC
|
2024-11-28 16:05:52 +08:00
|
|
|
</select>
|
2024-12-06 13:09:20 +08:00
|
|
|
|
2025-01-08 18:55:05 +08:00
|
|
|
<select id="pageAdmin" resultMap="userNoticeMap">
|
2024-12-06 13:09:20 +08:00
|
|
|
SELECT
|
2025-01-08 18:55:05 +08:00
|
|
|
sn.*, -- 获取消息详情
|
|
|
|
COUNT(DISTINCT sun.user_id) AS user_count, -- 统计用户的关联数量
|
|
|
|
SUM(CASE WHEN sun.is_read = true THEN 1 ELSE 0 END) AS read_count -- 统计已读数量
|
2024-12-06 13:09:20 +08:00
|
|
|
FROM
|
2025-01-08 18:55:05 +08:00
|
|
|
sys_user_notice sun
|
2024-12-06 13:09:20 +08:00
|
|
|
LEFT JOIN
|
2025-01-08 18:55:05 +08:00
|
|
|
sys_user su ON sun.user_id = su.id
|
2024-12-06 13:09:20 +08:00
|
|
|
LEFT JOIN
|
2025-01-08 18:55:05 +08:00
|
|
|
sys_notice sn ON sn.id = sun.notice_id
|
2024-12-06 13:09:20 +08:00
|
|
|
GROUP BY
|
2025-01-08 18:55:05 +08:00
|
|
|
sn.id
|
2024-12-06 13:09:20 +08:00
|
|
|
<where>
|
|
|
|
<if test="query.userId != null">
|
2025-01-08 18:55:05 +08:00
|
|
|
AND sun.user_id = #{query.userId}
|
2024-12-06 13:09:20 +08:00
|
|
|
</if>
|
|
|
|
<if test="query.title != null and query.title != ''">
|
2025-01-08 18:55:05 +08:00
|
|
|
AND sn.title LIKE CONCAT('%', #{query.title}, '%')
|
2024-12-06 13:09:20 +08:00
|
|
|
</if>
|
|
|
|
<if test="query.createAtBegin != null and query.createAtEnd != null">
|
2025-01-08 18:55:05 +08:00
|
|
|
AND sn.create_time BETWEEN #{query.createAtBegin} AND #{query.createAtEnd}
|
2024-12-06 13:09:20 +08:00
|
|
|
</if>
|
|
|
|
</where>
|
|
|
|
</select>
|
|
|
|
|
2024-11-28 16:05:52 +08:00
|
|
|
</mapper>
|