224 lines
10 KiB
XML
224 lines
10 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="SouthExam">
|
|
|
|
<sql id="baseSqlForAlias">
|
|
a.examId,a.examType,a.isRecommend,a.title,a.description,a.examPaperCount,a.exampapers,a.created,a.startTime,a.endTime,a.isNetExam,a.isOral,a.teacherId,a.status
|
|
</sql>
|
|
<sql id="baseSql">
|
|
examId,examType,isRecommend,title,description,examPaperCount,exampapers,created,startTime,endTime,isNetExam,isOral,teacherId,status
|
|
</sql>
|
|
|
|
<resultMap id="southExamResultMap" type="SouthExamDto">
|
|
<id column="examId" property="examId"/>
|
|
<result column="examType" property="examType"/>
|
|
<result column="isRecommend" property="isRecommend"/>
|
|
<result column="title" property="title"/>
|
|
<result column="description" property="description"/>
|
|
<result column="examPaperCount" property="examPaperCount"/>
|
|
<result column="exampapers" property="exampapers"/>
|
|
<result column="created" property="created"/>
|
|
<result column="startTime" property="startTime"/>
|
|
<result column="endTime" property="endTime"/>
|
|
<result column="isNetExam" property="isNetExam"/>
|
|
<result column="isOral" property="isOral"/>
|
|
<result column="teacherId" property="teacherId"/>
|
|
<result column="status" property="status"/>
|
|
<collection property="southLessonNames" ofType="SouthLessonNames">
|
|
<result column="southPaperName" property="southPaperName"/>
|
|
<result column="unitName" property="unitName"/>
|
|
<result column="bookName" property="bookName"/>
|
|
</collection>
|
|
</resultMap>
|
|
|
|
|
|
<resultMap id="userOwnSouthExamResultMap" type="SouthExamDto">
|
|
<id column="examId" property="examId"/>
|
|
<result column="examType" property="examType"/>
|
|
<result column="isRecommend" property="isRecommend"/>
|
|
<result column="title" property="title"/>
|
|
<result column="description" property="description"/>
|
|
<result column="examPaperCount" property="examPaperCount"/>
|
|
<result column="exampapers" property="exampapers"/>
|
|
<result column="startTime" property="startTime"/>
|
|
<result column="endTime" property="endTime"/>
|
|
<result column="isNetExam" property="isNetExam"/>
|
|
<result column="isOral" property="isOral"/>
|
|
<result column="teacherId" property="teacherId"/>
|
|
<result column="status" property="status"/>
|
|
<result column="className" property="className"/>
|
|
<result column="created" property="created"/>
|
|
<result column="assigntime" property="assigntime"/>
|
|
|
|
<result column="score" property="score"/>
|
|
<result column="trueScore" property="trueScore"/>
|
|
<result column="avgScore" property="avgScore"/>
|
|
<result column="lastTime" property="lastTime"/>
|
|
<collection property="southLessonNames" ofType="SouthLessonNames">
|
|
<result column="examPaperId" property="examPaperId"/>
|
|
<result column="southPaperName" property="southPaperName"/>
|
|
<result column="southPaperType" property="southPaperType"/>
|
|
<result column="unitName" property="unitName"/>
|
|
<result column="bookName" property="bookName"/>
|
|
</collection>
|
|
</resultMap>
|
|
|
|
|
|
<select id="getSouthExamSeq" resultType="Integer" useCache="false" flushCache="true">
|
|
SELECT nextval('seq_southexamid') ;
|
|
</select>
|
|
|
|
<select id="getExamByExamId" resultType="SouthExam" parameterType="SouthExamDto">
|
|
select
|
|
<include refid="baseSql"/>
|
|
from southExam where examId = #{examId};
|
|
</select>
|
|
|
|
|
|
<insert id="insertSouthExam" parameterType="SouthExam">
|
|
insert into SouthExam (
|
|
<include refid="baseSql"/><if test="assigntime != null">
|
|
,assigntime
|
|
</if>
|
|
) values (
|
|
#{examId},#{examType},#{isRecommend},#{title},#{description},#{examPaperCount},#{exampapers},#{created},#{startTime},#{endTime},#{isNetExam},#{isOral},#{teacherId},#{status}
|
|
<if test="assigntime != null">
|
|
,#{assigntime}
|
|
</if>
|
|
)
|
|
</insert>
|
|
|
|
<select id="getSouthExamByClassesId" parameterType="ClassOwnSouthDto" resultType="SouthExam">
|
|
select
|
|
<include refid="baseSqlForAlias"/>
|
|
from SouthExam as a inner join ClassOwnSouth as b on a.examId = b.examId
|
|
<where>
|
|
<if test="classesId != null and classesId != ''">
|
|
and b.classesId = #{classesId}
|
|
</if>
|
|
<if test="examId != null and examId != ''">
|
|
and b.examId = #{examId}
|
|
</if>
|
|
</where>
|
|
order by a.examId desc
|
|
<if test="pageSize != null and offset != null ">
|
|
limit #{pageSize} offset #{offset}
|
|
</if>
|
|
|
|
</select>
|
|
|
|
|
|
<select id="getSouthExamAndSouthLessonByClassesId" parameterType="ClassOwnSouthDto" resultMap="southExamResultMap">
|
|
|
|
|
|
with temp1 as (select
|
|
<include refid="baseSqlForAlias"/>
|
|
from SouthExam as a inner join ClassOwnSouth as b on a.examId = b.examId
|
|
<where>
|
|
<if test="classesId != null and classesId != ''">
|
|
and b.classesId = #{classesId}
|
|
</if>
|
|
<if test="examId != null and examId != ''">
|
|
and b.examId = #{examId}
|
|
</if>
|
|
</where>
|
|
order by a.examId desc
|
|
<if test="pageSize != null and offset != null ">
|
|
limit #{pageSize} offset #{offset}
|
|
</if>
|
|
),
|
|
temp2 as (select examId,to_number(( json_array_elements (exampapers :: json) ->> 'paperId' ),'999999999999') AS
|
|
paperId from temp1)
|
|
|
|
select e.* ,b.title as southPaperName,c.lessonname as unitName ,d.lessonname as bookName from temp2 as a inner
|
|
join southPaper as b on a.paperId = b.exampaperid inner join southLesson as c on b.lessonId = c.lessonId and
|
|
c.lessonType = 'U' inner join southLesson as d on c.parentId = d.lessonId and d.lessonType = 'B' inner join
|
|
temp1 as e on e.examId = a.examId group by
|
|
e.examId,e.examType,e.isRecommend,e.title,e.description,e.examPaperCount,e.exampapers,e.created,e.startTime,e.endTime,e.isNetExam,e.isOral,e.teacherId,e.status,
|
|
southPaperName,unitName ,bookName order by e.examId desc
|
|
|
|
</select>
|
|
|
|
|
|
<update id="updateParamsByExamId" parameterType="SouthExamDto">
|
|
update SouthExam
|
|
<set>
|
|
<if test="title != null and title != ''">
|
|
title =#{title},
|
|
</if>
|
|
<if test="description != null and description != ''">
|
|
description =#{description},
|
|
</if>
|
|
<if test="examPaperCount != null">
|
|
examPaperCount =#{examPaperCount},
|
|
</if>
|
|
<if test="exampapers != null and exampapers != ''">
|
|
exampapers =#{exampapers},
|
|
</if>
|
|
<if test="startTime != null">
|
|
startTime =#{startTime},
|
|
</if>
|
|
<if test="endTime != null ">
|
|
endTime =#{endTime},
|
|
</if>
|
|
<if test="isNetExam != null">
|
|
isNetExam =#{isNetExam},
|
|
</if>
|
|
<if test="isOral != null">
|
|
isOral =#{isOral},
|
|
</if>
|
|
<if test="status != null">
|
|
status =#{status},
|
|
</if>
|
|
<if test="assigntime != null">
|
|
assigntime =#{assigntime}
|
|
</if>
|
|
</set>
|
|
where examId = #{examId}
|
|
</update>
|
|
|
|
|
|
<select id="getUserOwnSouthExamAndAchievement" parameterType="java.util.Map" resultMap="userOwnSouthExamResultMap">
|
|
<if test="userType == 2">
|
|
with classesids as (select classesid,className from classes where teacherid = #{uid} and status =1),
|
|
|
|
</if>
|
|
<if test="userType == 1">
|
|
with classesids as (select b.classesid ,c.className from student as a inner join studentownclass as b on
|
|
a.studentid = b.studentid and b.status = 1 inner join classes as c on c.classesid = b.classesid where
|
|
a.studentid =#{uid} group by b.classesid,c.className),
|
|
|
|
</if>
|
|
exams as ( select a.examId,a.classesId ,b.className from classownsouth as a INNER JOIN classesids as b on
|
|
a.classesid = b.classesid where a.areaid = #{areaId} ),
|
|
|
|
Answers as (select examId,score,trueScore,avgScore,lastTime from finishSouthStat where uid = #{uid}),
|
|
|
|
temp1 as ( select
|
|
a.examId,a.examType,a.isRecommend,a.title,a.description,a.examPaperCount,a.exampapers,a.created,a.startTime,a.endTime,a.isNetExam,a.isOral,a.teacherId,a.status,b.className,c.score,c.trueScore,c.avgScore,c.lastTime,a.assigntime
|
|
from SouthExam as a inner join exams as b on a.examId = b.examId left join Answers as c on a.examId = c.examId
|
|
where a.status = 1 and a.endTime > current_timestamp group by
|
|
a.examId,a.examType,a.isRecommend,a.title,a.description,a.examPaperCount,a.exampapers,a.created,a.startTime,a.endTime,a.isNetExam,a.isOral,a.teacherId,a.status,c.score,c.trueScore,c.avgScore,c.lastTime,b.className,a.assigntime
|
|
order by a.examId desc),
|
|
|
|
temp2 as (select examId,cast(( json_array_elements (exampapers :: json) ->> 'paperId' ) as INTEGER ) AS paperId
|
|
from temp1)
|
|
|
|
select
|
|
e.examId,e.examType,e.isRecommend,e.title,e.description,e.examPaperCount,e.exampapers,e.created,e.startTime,e.endTime,e.isNetExam,e.isOral,e.teacherId,e.status,e.score,e.trueScore,e.avgScore,e.lastTime,e.assigntime
|
|
,e.className,b.examPaperId as examPaperId,b.papertype as southPaperType,b.title as southPaperName,c.lessonname
|
|
as unitName ,d.lessonname as bookName from temp2 as a inner
|
|
join southPaper as b on a.paperId = b.exampaperid inner join southLesson as c on b.lessonId = c.lessonId and
|
|
c.lessonType = 'U' inner join southLesson as d on c.parentId = d.lessonId and d.lessonType = 'B' inner join
|
|
temp1 as e on e.examId = a.examId group by
|
|
e.examId,e.examType,e.isRecommend,e.title,e.description,e.examPaperCount,e.exampapers,e.created,e.startTime,e.endTime,e.isNetExam,e.isOral,e.teacherId,e.status,e.score,e.trueScore,e.avgScore,e.lastTime,e.assigntime,
|
|
southPaperName,unitName ,bookName,e.className,southPaperType,examPaperId
|
|
<if test="offset != null">
|
|
limit #{pageSize} offset #{offset}
|
|
</if>
|
|
|
|
|
|
</select>
|
|
|
|
</mapper> |