学工发布通知功能代码

This commit is contained in:
MDSMO
2025-08-04 15:10:47 +08:00
parent 78a19c07ce
commit 28383d3a94
7 changed files with 756 additions and 0 deletions

View File

@@ -0,0 +1,139 @@
<?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.srs.routine.mapper.NotificationManagementMapper">
<resultMap type="NotificationManagement" id="NotificationManagementResult">
<result property="id" column="id" />
<result property="sender" column="sender" />
<result property="receiver" column="receiver" />
<result property="content" column="content" />
<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">
select id, sender, receiver, content, create_by, create_time, update_by, update_time from cph_msg
</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"/>
<where>
<if test="sender != null "> and sender = #{sender}</if>
<if test="receiver != null "> and receiver = #{receiver}</if>
<if test="content != null and content != ''"> and content = #{content}</if>
</where>
</select>
<!-- 查询当前用户发送的通知列表 -->
<select id="selectNotificationManagementListBySender" resultMap="NotificationManagementResult">
<include refid="selectNotificationManagementVo"/>
<where>
sender = #{senderId}
<if test="notification.receiver != null "> and receiver = #{notification.receiver}</if>
<if test="notification.content != null and notification.content != ''"> and content = #{notification.content}</if>
</where>
order by create_time desc
</select>
<select id="selectNotificationManagementById" parameterType="Long" resultMap="NotificationManagementResult">
<include refid="selectNotificationManagementVo"/>
where id = #{id}
</select>
<insert id="insertNotificationManagement" parameterType="NotificationManagement" useGeneratedKeys="true" keyProperty="id">
insert into cph_msg
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="sender != null">sender,</if>
<if test="receiver != null">receiver,</if>
<if test="content != null">content,</if>
<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>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sender != null">#{sender},</if>
<if test="receiver != null">#{receiver},</if>
<if test="content != null">#{content},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateNotificationManagement" parameterType="NotificationManagement">
update cph_msg
<trim prefix="SET" suffixOverrides=",">
<if test="sender != null">sender = #{sender},</if>
<if test="receiver != null">receiver = #{receiver},</if>
<if test="content != null">content = #{content},</if>
<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">
delete from cph_msg where id = #{id}
</delete>
<delete id="deleteNotificationManagementByIds" parameterType="String">
delete from cph_msg where id in
<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>
<!-- 批量插入通知记录 -->
<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>
</mapper>