2025-08-04 15:10:47 +08:00
|
|
|
<?xml version="1.0" encoding="UTF-8" ?>
|
|
|
|
<!DOCTYPE mapper
|
2025-08-11 15:25:53 +08:00
|
|
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
2025-08-04 15:10:47 +08:00
|
|
|
<mapper namespace="com.srs.routine.mapper.NotificationManagementMapper">
|
2025-08-11 15:25:53 +08:00
|
|
|
|
2025-08-04 15:10:47 +08:00
|
|
|
<resultMap type="NotificationManagement" id="NotificationManagementResult">
|
|
|
|
<result property="id" column="id" />
|
2025-08-11 15:25:53 +08:00
|
|
|
<result property="title" column="title" />
|
2025-08-04 15:10:47 +08:00
|
|
|
<result property="content" column="content" />
|
2025-08-11 15:25:53 +08:00
|
|
|
<result property="gradeIds" column="grade_ids" />
|
|
|
|
<result property="gradeName" column="grade_name" />
|
|
|
|
<result property="sender" column="sender" />
|
2025-08-04 15:10:47 +08:00
|
|
|
<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>
|
|
|
|
|
|
|
|
<resultMap type="SrsGrade" id="GradeResult">
|
|
|
|
<result property="gradeId" column="grade_id" />
|
|
|
|
<result property="gradeName" column="grade_name" />
|
|
|
|
<result property="gradeCode" column="grade_code" />
|
|
|
|
<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>
|
|
|
|
|
|
|
|
<sql id="selectNotificationManagementVo">
|
2025-08-11 15:25:53 +08:00
|
|
|
select id, title, content, grade_ids, sender, create_by, create_time, update_by, update_time from srs_notification
|
2025-08-04 15:10:47 +08:00
|
|
|
</sql>
|
|
|
|
|
|
|
|
<sql id="selectGradeVo">
|
|
|
|
select grade_id, grade_name, grade_code, status, create_by, create_time, update_by, update_time from srs_grade
|
|
|
|
</sql>
|
|
|
|
|
|
|
|
<select id="selectNotificationManagementList" parameterType="NotificationManagement" resultMap="NotificationManagementResult">
|
|
|
|
<include refid="selectNotificationManagementVo"/>
|
2025-08-11 15:25:53 +08:00
|
|
|
<where>
|
|
|
|
<if test="title != null and title != ''"> and title like concat('%', #{title}, '%')</if>
|
|
|
|
<if test="content != null and content != ''"> and content like concat('%', #{content}, '%')</if>
|
|
|
|
<if test="gradeIds != null and gradeIds != ''"> and grade_ids = #{gradeIds}</if>
|
|
|
|
<if test="sender != null"> and sender = #{sender}</if>
|
2025-08-04 15:10:47 +08:00
|
|
|
</where>
|
2025-08-11 15:25:53 +08:00
|
|
|
order by create_time desc
|
2025-08-04 15:10:47 +08:00
|
|
|
</select>
|
|
|
|
|
|
|
|
<!-- 查询当前用户发送的通知列表 -->
|
|
|
|
<select id="selectNotificationManagementListBySender" resultMap="NotificationManagementResult">
|
2025-08-11 15:25:53 +08:00
|
|
|
select n.id, n.title, n.content, n.grade_ids, n.sender, n.create_by, n.create_time, n.update_by, n.update_time,
|
|
|
|
GROUP_CONCAT(g.grade_name SEPARATOR ',') as grade_name
|
|
|
|
from srs_notification n
|
|
|
|
left join srs_grade g on FIND_IN_SET(g.grade_id, n.grade_ids) > 0
|
|
|
|
<where>
|
|
|
|
n.sender = #{senderId}
|
|
|
|
<if test="notification.title != null and notification.title != ''"> and n.title like concat('%', #{notification.title}, '%')</if>
|
|
|
|
<if test="notification.content != null and notification.content != ''"> and n.content like concat('%', #{notification.content}, '%')</if>
|
|
|
|
<if test="notification.gradeIds != null and notification.gradeIds != ''"> and n.grade_ids = #{notification.gradeIds}</if>
|
2025-08-04 15:10:47 +08:00
|
|
|
</where>
|
2025-08-11 15:25:53 +08:00
|
|
|
group by n.id, n.title, n.content, n.grade_ids, n.sender, n.create_by, n.create_time, n.update_by, n.update_time
|
|
|
|
order by n.create_time desc
|
2025-08-04 15:10:47 +08:00
|
|
|
</select>
|
2025-08-11 15:25:53 +08:00
|
|
|
|
|
|
|
|
2025-08-04 15:10:47 +08:00
|
|
|
<select id="selectNotificationManagementById" parameterType="Long" resultMap="NotificationManagementResult">
|
|
|
|
<include refid="selectNotificationManagementVo"/>
|
|
|
|
where id = #{id}
|
|
|
|
</select>
|
2025-08-11 15:25:53 +08:00
|
|
|
|
|
|
|
<!-- 插入数据到通知管理表-->
|
2025-08-04 15:10:47 +08:00
|
|
|
<insert id="insertNotificationManagement" parameterType="NotificationManagement" useGeneratedKeys="true" keyProperty="id">
|
2025-08-11 15:25:53 +08:00
|
|
|
insert into srs_notification
|
2025-08-04 15:10:47 +08:00
|
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
2025-08-11 15:25:53 +08:00
|
|
|
<if test="title != null">title,</if>
|
2025-08-04 15:10:47 +08:00
|
|
|
<if test="content != null">content,</if>
|
2025-08-11 15:25:53 +08:00
|
|
|
<if test="gradeIds != null">grade_ids,</if>
|
|
|
|
<if test="sender != null">sender,</if>
|
2025-08-04 15:10:47 +08:00
|
|
|
<if test="createBy != null">create_by,</if>
|
|
|
|
<if test="createTime != null">create_time,</if>
|
|
|
|
<if test="updateBy != null">update_by,</if>
|
|
|
|
<if test="updateTime != null">update_time,</if>
|
2025-08-11 15:25:53 +08:00
|
|
|
</trim>
|
2025-08-04 15:10:47 +08:00
|
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
2025-08-11 15:25:53 +08:00
|
|
|
<if test="title != null">#{title},</if>
|
2025-08-04 15:10:47 +08:00
|
|
|
<if test="content != null">#{content},</if>
|
2025-08-11 15:25:53 +08:00
|
|
|
<if test="gradeIds != null">#{gradeIds},</if>
|
|
|
|
<if test="sender != null">#{sender},</if>
|
2025-08-04 15:10:47 +08:00
|
|
|
<if test="createBy != null">#{createBy},</if>
|
|
|
|
<if test="createTime != null">#{createTime},</if>
|
|
|
|
<if test="updateBy != null">#{updateBy},</if>
|
|
|
|
<if test="updateTime != null">#{updateTime},</if>
|
2025-08-11 15:25:53 +08:00
|
|
|
</trim>
|
2025-08-04 15:10:47 +08:00
|
|
|
</insert>
|
|
|
|
|
|
|
|
<update id="updateNotificationManagement" parameterType="NotificationManagement">
|
2025-08-11 15:25:53 +08:00
|
|
|
update srs_notification
|
2025-08-04 15:10:47 +08:00
|
|
|
<trim prefix="SET" suffixOverrides=",">
|
2025-08-11 15:25:53 +08:00
|
|
|
<if test="title != null">title = #{title},</if>
|
2025-08-04 15:10:47 +08:00
|
|
|
<if test="content != null">content = #{content},</if>
|
2025-08-11 15:25:53 +08:00
|
|
|
<if test="gradeIds != null">grade_ids = #{gradeIds},</if>
|
|
|
|
<if test="sender != null">sender = #{sender},</if>
|
2025-08-04 15:10:47 +08:00
|
|
|
<if test="createBy != null">create_by = #{createBy},</if>
|
|
|
|
<if test="createTime != null">create_time = #{createTime},</if>
|
|
|
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
|
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
|
|
</trim>
|
|
|
|
where id = #{id}
|
|
|
|
</update>
|
|
|
|
|
|
|
|
<delete id="deleteNotificationManagementById" parameterType="Long">
|
2025-08-11 15:25:53 +08:00
|
|
|
delete from srs_notification where id = #{id}
|
2025-08-04 15:10:47 +08:00
|
|
|
</delete>
|
|
|
|
|
|
|
|
<delete id="deleteNotificationManagementByIds" parameterType="String">
|
2025-08-11 15:25:53 +08:00
|
|
|
delete from srs_notification where id in
|
2025-08-04 15:10:47 +08:00
|
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
|
|
#{id}
|
|
|
|
</foreach>
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
<!-- 查询年级列表 -->
|
|
|
|
<select id="selectGradeList" resultMap="GradeResult">
|
|
|
|
<include refid="selectGradeVo"/>
|
|
|
|
where status = '0'
|
|
|
|
order by grade_code desc
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<!-- 根据年级ID列表查询学生用户ID -->
|
|
|
|
<select id="selectStudentIdsByGrades" resultType="Long">
|
|
|
|
SELECT DISTINCT u.user_id
|
|
|
|
FROM srs_student ss
|
|
|
|
left JOIN srs_class sc ON ss.class_id = sc.class_id
|
|
|
|
left JOIN sys_user u ON ss.stu_no = u.user_name
|
|
|
|
WHERE u.user_id IS NOT NULL
|
|
|
|
AND sc.grade_id IN
|
|
|
|
<foreach item="gradeId" collection="gradeIds" open="(" separator="," close=")">
|
|
|
|
#{gradeId}
|
|
|
|
</foreach>
|
|
|
|
</select>
|
|
|
|
|
2025-08-11 15:25:53 +08:00
|
|
|
<!-- 根据年级ID列表查询学生学号列表 -->
|
|
|
|
<select id="selectStudentNosByGrades" resultType="String">
|
|
|
|
SELECT DISTINCT ss.stu_no
|
|
|
|
FROM srs_student ss
|
|
|
|
left JOIN srs_class sc ON ss.class_id = sc.class_id
|
|
|
|
WHERE ss.stu_no IS NOT NULL
|
|
|
|
AND sc.grade_id IN
|
|
|
|
<foreach item="gradeId" collection="gradeIds" open="(" separator="," close=")">
|
|
|
|
#{gradeId}
|
|
|
|
</foreach>
|
|
|
|
</select>
|
2025-08-04 15:10:47 +08:00
|
|
|
|
2025-08-11 15:25:53 +08:00
|
|
|
<!-- 批量插入通知记录到cph_msg表 -->
|
2025-08-04 15:10:47 +08:00
|
|
|
<insert id="batchInsertNotification" parameterType="java.util.List">
|
|
|
|
insert into cph_msg (sender, receiver, content, create_time)
|
|
|
|
values
|
|
|
|
<foreach collection="list" item="item" separator=",">
|
|
|
|
(#{item.sender}, #{item.receiver}, #{item.content}, #{item.createTime})
|
|
|
|
</foreach>
|
|
|
|
</insert>
|
|
|
|
|
2025-08-11 15:25:53 +08:00
|
|
|
<!-- 批量删除cph_msg表数据 -->
|
|
|
|
<delete id="batchDeleteCphMsg" parameterType="java.util.List">
|
|
|
|
delete from cph_msg where (content, sender, create_time) in
|
|
|
|
<foreach collection="list" item="item" open="(" separator="," close=")">
|
|
|
|
(#{item.content}, #{item.sender}, #{item.createTime})
|
|
|
|
</foreach>
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
<!-- 批量更新cph_msg表数据 -->
|
|
|
|
<update id="batchUpdateCphMsg" parameterType="java.util.Map">
|
|
|
|
update cph_msg
|
|
|
|
set content = #{newList[0].content}
|
|
|
|
where content = #{oldList[0].content}
|
|
|
|
and sender = #{oldList[0].sender}
|
|
|
|
and create_time = #{oldList[0].createTime}
|
|
|
|
</update>
|
|
|
|
|
|
|
|
</mapper>
|