125 lines
4.4 KiB
XML
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>#{startTime} and created<#{endTime}
|
||
|
|
and endTime>now() or
|
||
|
|
( starttime<(now()+interval '1 day') and startTime>(now()+interval '${temp} second')
|
||
|
|
and extract(day from (starttime-created))>=3 )),
|
||
|
|
temp1 as (select examId,-1 as isOral from hearexam
|
||
|
|
where
|
||
|
|
(created>#{startTime} and created<#{endTime}
|
||
|
|
and endTime>now()) or
|
||
|
|
( starttime<(now()+interval '1 day') and startTime>(now()+interval '${temp} second')
|
||
|
|
and extract(day from (starttime-created))>=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>#{startTime} and created<#{endTime})
|
||
|
|
|
||
|
|
<if test="isThree">
|
||
|
|
or
|
||
|
|
( starttime<(current_date + interval '1 day') and startTime>=current_date and
|
||
|
|
(extract(day from starttime)-extract(day from created))>0 )
|
||
|
|
|
||
|
|
</if>),
|
||
|
|
temp1 as (select examId,-1 as isOral from hearexam
|
||
|
|
where
|
||
|
|
(created>#{startTime} and created<#{endTime})
|
||
|
|
|
||
|
|
<if test="isThree">
|
||
|
|
or
|
||
|
|
( starttime<(current_date + interval '1 day') and startTime>=current_date and
|
||
|
|
(extract(day from starttime)-extract(day from created))>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 > #{startTime}
|
||
|
|
and e.endtime <#{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') <e.endtime))
|
||
|
|
order by e.created desc
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
</mapper>
|