229 lines
7.7 KiB
XML
Raw Permalink Normal View History

2026-03-10 14:30:24 +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">
<mapper namespace="ClassMessage">
<insert id="insertClassMessage" parameterType="ClassMessage">
INSERT INTO ClassMessage ( classMessageId, content, teacherId,
created, startTime, endTime, status , areaid ,source ,isExam )
Values ( #{classMessageId}, #{content}, #{teacherId},
current_timestamp, #{startTime}, #{endTime}, #{status} , #{areaid},#{source},#{isExam} )
</insert>
<update id="updateClassMessage" parameterType="ClassMessage">
UPDATE ClassMessage
SET content = #{content}, teacherId = #{teacherId}, created = #{created},
startTime = #{startTime}, endTime = #{endTime},
status = #{status} , areaid = #{areaid},source =#{source},isExam=#{isExam}
WHERE classMessageId=#{classMessageId}
</update>
<select id="getClassMessageByKey" parameterType="java.lang.Integer" resultType="ClassMessage">
SELECT classMessageId , content , teacherId , created ,
startTime , endTime , status ,source, areaid, isExam
FROM ClassMessage
WHERE classMessageId=#{classMessageId}
</select>
<select id="getSeqClassMessage" resultType="Integer" useCache="false" flushCache="true">
SELECT nextval('seq_classMessageId')
</select>
<select id="getClassMessagesCountByTeacherId" parameterType="java.util.Map" resultType="Integer">
SELECT count(*) as howmuch
FROM ClassMessage
WHERE teacherId=#{teacherId} and isExam=0
and status = 1 and areaid = #{areaid}
</select>
<select id="getClassMessagesByTeacherId" parameterType="java.util.Map" resultType="ClassMessage">
SELECT classMessageId , content , teacherId , created ,
startTime , endTime , status , areaid ,source
FROM ClassMessage
WHERE teacherId=#{teacherId}
and status = 1 and areaid = #{areaid} and isExam=0
ORDER BY classMessageId desc
LIMIT #{pageSize} OFFSET #{offset}
</select>
<update id="classMessageBatchUpdateByClassMessageId">
UPDATE ClassMessage
SET status = 0
WHERE classMessageId in
<foreach collection="list" index="index" item="item" separator="," close=")" open="(">
#{item}
</foreach>
</update>
<select id="getClassMessagesCountByClassesId" parameterType="java.util.Map" resultType="Integer">
SELECT count(*) as howmuch
FROM ClassOwnMessage a
INNER JOIN ClassMessage b
ON a.classesId = #{classesId}
and a.classMessageId = b.classMessageId and b.source=1
<if test="isExam!=null">
and b.isExam=#{isExam}
</if>
WHERE b.status = 1
</select>
<select id="getClassMessagesByClassesId" parameterType="java.util.Map" resultType="ClassMessage">
SELECT b.classMessageId , b.content , b.teacherId , b.created ,
b.startTime , b.endTime , b.status , b.areaid
FROM ClassOwnMessage a
INNER JOIN ClassMessage b
ON a.classesId = #{classesId}
and a.classMessageId = b.classMessageId and b.source=1
<if test="isExam!=null">
and b.isExam=#{isExam}
</if>
WHERE b.status = 1
ORDER BY b.classMessageId desc
LIMIT #{pageSize} OFFSET #{offset}
</select>
<select id="getLastClassMessage" parameterType="Long" resultType="ClassMessage">
SELECT b.classMessageId , b.content , b.teacherId , b.created ,
b.startTime , b.endTime , b.status , b.areaid
FROM ClassOwnMessage a
INNER JOIN ClassMessage b
ON a.classesId = #{classesId}
AND a.classMessageId = b.classMessageId and b.source=1
ORDER BY b.classMessageId desc
LIMIT 1
</select>
<select id="getLastMessageByStudentId" parameterType="Long" resultType="ClassMessage">
SELECT b.classMessageId , b.content , b.teacherId , b.created ,
b.startTime , b.endTime , b.status , b.areaid
FROM ClassOwnMessage a
INNER JOIN ClassMessage b
ON a.classMessageId = b.classMessageId and b.status = 1 and b.source=1
INNER JOIN StudentOwnClass s
ON s.classesid = a.classesid and s.studentid = #{studentId}
ORDER BY b.classMessageId desc
LIMIT 1
</select>
<select id="getClassMessagesBySystem" parameterType="java.util.Map" resultType="ClassMessage">
SELECT classMessageId , content , teacherId , created ,
startTime , endTime , status , areaid
FROM ClassMessage
WHERE teacherId=0
and status = 1 and source=2
ORDER BY classMessageId desc
LIMIT #{pageSize} OFFSET #{offset}
</select>
<select id="getClassMessagesBySystemCount" resultType="java.lang.Integer">
SELECT count(classMessageId)
FROM ClassMessage
WHERE teacherId=0
and status=1 and source=2
</select>
<select id="getClassMessagesCountByStudentId" parameterType="java.util.Map" resultType="Integer">
SELECT count(distinct b.classMessageId)
FROM ClassOwnMessage a
INNER JOIN ClassMessage b
ON a.classMessageId = b.classMessageId and b.status = 1 and b.source=1 and b.isExam=0
<if test="isAll==null">
and a.classMessageId &gt;58320
</if>
<if test="ids!=null">
and a.classMessageId in
<foreach collection="ids" item="item" separator="," close=")" open="(">
#{item}
</foreach>
</if>
INNER JOIN StudentOwnClass s
ON s.classesid = a.classesid and s.studentid = #{studentId}
</select>
<select id="getClassMessagesByStudentId" parameterType="java.util.Map" resultType="ClassMessage">
SELECT distinct on (b.classMessageId) b.classMessageId , b.content , b.teacherId , b.created ,
b.startTime , b.endTime , b.status , b.areaid
FROM ClassOwnMessage a
INNER JOIN ClassMessage b
ON a.classMessageId = b.classMessageId and b.status = 1 and b.source=1 and b.isExam=0
<if test="isAll==null">
and a.classMessageId &gt;58320
</if>
<if test="ids!=null">
and a.classMessageId in
<foreach collection="ids" item="item" separator="," close=")" open="(">
#{item}
</foreach>
</if>
INNER JOIN StudentOwnClass s
ON s.classesid = a.classesid and s.studentid = #{studentId}
ORDER BY b.classMessageId desc
<if test="pageSize!=null">
limit #{pageSize}
</if>
<if test="offset!=null">
offset #{offset}
</if>
</select>
<select id="getClassMessagesByTeacherIdNew" parameterType="java.util.Map" resultType="ClassMessage">
SELECT classMessageId , content , teacherId , created ,
startTime , endTime , status , areaid ,source
FROM ClassMessage
WHERE teacherId=#{teacherId}
and status = 1 and isExam=0
<if test="isAll==null">
and classMessageId &gt;58320
</if>
<if test="ids!=null">
and classMessageId not in
<foreach collection="ids" item="item" separator="," close=")" open="(">
#{item}
</foreach>
</if>
ORDER BY classMessageId desc
<if test="pageSize!=null">
limit #{pageSize}
</if>
<if test="offset!=null">
offset #{offset}
</if>
</select>
<select id="getClassMessagesCountByTeacherIdNew" parameterType="java.util.Map" resultType="java.lang.Integer">
SELECT count(classMessageId)
FROM ClassMessage
WHERE teacherId=#{teacherId}
and status = 1 and isExam=0
<if test="isAll==null">
and classMessageId &gt;58320
</if>
<if test="ids!=null">
and classMessageId in
<foreach collection="ids" item="item" separator="," close=")" open="(">
#{item}
</foreach>
</if>
</select>
</mapper>