2026-03-10 14:30:24 +08:00

125 lines
4.4 KiB
XML

<?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="ClassOwnExam">
<insert id="insertClassOwnExam" parameterType="ClassOwnExam">
INSERT INTO ClassOwnExam ( classesId, examId , areaid ) Values ( #{classesId}, #{examId} , #{areaid} )
</insert>
<update id="updateClassOwnExam" parameterType="ClassOwnExam">
UPDATE ClassOwnExam SET
classesId = #{classesId}, examId = #{examId} , areaid = #{areaid}
where classesId=#{classesId} and examId=#{examId} and areaid = #{areaid}
</update>
<delete id="deleteByMap" parameterType="java.util.Map">
delete from ClassOwnExam where 1=1
<if test="classesId != null and classesId !=''">
and classesId=#{classesId}
</if>
<if test="examId != null and examId !=''">
and examId= #{examId}
</if>
<if test="areaid != null and areaid !=''">
and areaid = #{areaid}
</if>
</delete>
<select id="getClassOwnExamByKey" parameterType="java.util.Map" resultType="ClassOwnExam">
SELECT classesId , examId , areaid
FROM ClassOwnExam WHERE 1=1
<if test="classesId != null and classesId !=''">
and classesId=#{classesId}
</if>
<if test="examId != null and examId !=''">
and examId= #{examId}
</if>
<if test="areaid != null and areaid !=''">
and areaid = #{areaid}
</if>
</select>
<select id="getSeqClassOwnExam" resultType="Integer" useCache="false" flushCache="true">
SELECT nextval('seq_classOwnExamId') ;
</select>
<insert id="insertClassOwnExamBatch" parameterType="java.util.List">
INSERT INTO ClassOwnExam ( classesId, examId , areaid ) Values
<foreach collection="list" index="index" item="item" separator=",">
( #{item.classesId}, #{item.examId} , #{item.areaid} )
</foreach>
</insert>
<select id="getClassOwnExamDtosByTime" parameterType="java.util.Map" resultType="ClassOwnExamDto" >
<!-- with temp as (select examId,isOral from exam where
created&gt;#{startTime} and created&lt;#{endTime}
and endTime&gt;now() or
( starttime&lt;(now()+interval '1 day') and startTime&gt;(now()+interval '${temp} second')
and extract(day from (starttime-created))&gt;=3 )),
temp1 as (select examId,-1 as isOral from hearexam
where
(created&gt;#{startTime} and created&lt;#{endTime}
and endTime&gt;now()) or
( starttime&lt;(now()+interval '1 day') and startTime&gt;(now()+interval '${temp} second')
and extract(day from (starttime-created))&gt;=3 ))
select a.classesid , a.examId , areaId ,isOral
from classownexam a inner join temp t on t.examid=a.examid
union all
select a.classesId , a.examId , areaId ,isOral
from classownhear a inner join temp1 t on t.examid=a.examid -->
with temp as (select examId,isOral from exam where type = #{type} and
(created&gt;#{startTime} and created&lt;#{endTime})
<if test="isThree">
or
( starttime&lt;(current_date + interval '1 day') and startTime&gt;=current_date and
(extract(day from starttime)-extract(day from created))&gt;0 )
</if>),
temp1 as (select examId,-1 as isOral from hearexam
where
(created&gt;#{startTime} and created&lt;#{endTime})
<if test="isThree">
or
( starttime&lt;(current_date + interval '1 day') and startTime&gt;=current_date and
(extract(day from starttime)-extract(day from created))&gt;0
)
</if>)
select a.classesid , a.examId , areaId ,isOral
from classownexam a inner join temp t on t.examid=a.examid
union all
select a.classesId , a.examId , areaId ,isOral
from classownhear a inner join temp1 t on t.examid=a.examid
</select>
<select id="getExampaperByTeacherIdAndTime" parameterType="java.util.Map" resultType="java.util.Map">
select c.classesid,e.exampapers from classes c
INNER JOIN classownexam ce on c.classesid = ce.classesid and c.teacherid = #{teacherId} and c.status = 1
INNER JOIN exam e on ce.examid = e.examid and e.teacherid = #{teacherId} and e.starttime &gt; #{startTime}
and e.endtime &lt;#{endTime} and e.isOral = #{isOral}
<if test="type != null">
and e.type = #{type}
</if>
and (e.status = 1 or (e.status =0 and (e.starttime::timestamp + '15 min') &lt;e.endtime))
order by e.created desc
</select>
</mapper>