418 lines
15 KiB
XML
Raw 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="Lesson">
<select id="UnivUserOwnBooksByUid" parameterType="java.lang.Long" resultType="UserOwnBook">
SELECT uid, lessonid, lessonname, courseType,
coursecode, orderid, packagePic , version,
versionNo, url, isrecommend
FROM V_UserOwnBook
WHERE uid = #{uid}
</select>
<select id="UnivRecommBooksByUid" parameterType="java.lang.Long" resultType="UserOwnBook">
SELECT uid, lessonid, lessonname, courseType,
coursecode, orderid, packagePic , version,
versionNo, url, isrecommend
FROM V_RecommBook
</select>
<select id="UnivUserOwnMaterialsByUid" parameterType="java.lang.Long" resultType="UserOwnMaterial">
SELECT uid , materialId ,
title , teacherId , origiVoice , isNetMate , picture
FROM V_UserOwnMaterial
WHERE uid = #{uid} and isnetmate = 0
</select>
<select id="UnivUserOwnMaterialsByTeacherId" parameterType="java.lang.Long" resultType="UserOwnMaterial">
SELECT uid , materialId ,
title , teacherId , origiVoice , isNetMate , picture
FROM V_TeacherOwnMaterial
WHERE uid = #{uid} and isnetmate = 0
</select>
<select id="UnivUserOwnMaterialsByUidByNet" resultType="UserOwnMaterial">
SELECT uid , materialId , title ,
teacherId , origiVoice , isNetMate , picture
FROM V_TeacherOwnMaterial
where isnetmate = 1
</select>
<select id="UnivsimulatedExamByStudentId" parameterType="java.util.Map" resultType="UnivExam">
SELECT e.examId , e.examType , e.isRecommend , e.title , e.description ,
e.examPaperCount , e.examPapers , e.created , e.startTime , e.endTime , e.isOral
FROM UnivExam e
inner join UnivclassownExam c
on e.examid = c.examid
inner join Univstudentownclass s
on s.classesid = c.classesid and s.status = 1
WHERE s.studentId=#{studentId}
AND e.examType = 'S' and e.startTime &lt; now()
and e.endTime &gt; now() and e.isOral=#{isOral}
union
SELECT e.examId , e.examType , e.isRecommend , e.title , e.description ,
e.examPaperCount , e.examPapers , e.created , e.startTime , e.endTime , e.isOral
FROM UnivExam e
inner join UnivTeacherOwnExam te
on e.examid = te.examid
WHERE te.teacherId=#{studentId}
AND e.examType = 'S' and e.startTime &lt; now()
and e.endTime &gt; now() and e.isOral=#{isOral}
order by created desc
</select>
<select id="UnivsimulatedExamByNet" resultType="UnivExam" parameterType="java.lang.Integer">
SELECT examId , examType , isRecommend , title , description ,
examPaperCount , examPapers , created , startTime , endTime ,
isNetExam
FROM UnivExam
WHERE isNetExam = 1 AND examType = 'S'
and startTime &lt; now() and endTime &gt; now()
and isOral=#{isOral}
ORDER BY created DESC,title DESC
</select>
<select id="UnivofficialExam" parameterType="java.util.Map" resultType="UnivExam">
SELECT e.examId , e.examType , e.isRecommend , e.title , e.description ,
e.examPaperCount , e.examPapers , e.created , e.startTime , e.endTime
FROM UnivExam e
inner join UnivClassOwnExam uc
on uc.examid = e.examid
inner join UnivStudentownClass usc
on uc.classesId = usc.classesId
WHERE usc.studentId=#{studentId}
AND examType = 'O' and startTime &lt; now() and endTime &gt; now()
and e.isOral = #{isOral}
union
SELECT e.examId , e.examType , e.isRecommend , e.title , e.description ,
e.examPaperCount , e.examPapers , e.created , e.startTime , e.endTime
FROM UnivExam e
inner join UnivTeacherOwnExam te
on e.examid = te.examid
WHERE te.teacherId=#{studentId}
AND e.examType = 'O' and e.startTime &lt; now()
and e.endTime &gt; now()
and e.isOral = #{isOral}
order by created desc
</select>
<select id="UnivrecommendExamByNet" resultType="UnivExam">
SELECT examId , examType , isRecommend , title , description ,
examPaperCount , examPapers , created , startTime , endTime ,
isNetExam
FROM UnivExam
WHERE isNetExam = 1 AND isRecommend = 1
and startTime &lt; now() and endTime &gt; now()
order by created desc,title desc
</select>
<select id="UnivrecommendExamByStudentId" parameterType="java.lang.Long" resultType="UnivExam">
SELECT e.examId , examType , isRecommend , title , description ,
examPaperCount , examPapers , created , startTime , endTime
FROM UnivExam e
inner join UnivclassownExam c
on e.examid = c.examid
inner join Univstudentownclass s
on s.classesid = c.classesid and s.status = 1
WHERE s.studentId=#{studentId}
AND e.isRecommend = 1 and e.startTime &lt; now()
and e.endTime &gt; now()
order by examId desc
</select>
<select id="UnivunFinishedRacesCount" resultType="Integer">
select count(*)
from Race
where status = 1
and current_timestamp &lt; endTime
</select>
<select id="UnivunFinishedRaces" parameterType="java.util.Map" resultType="RaceStatDto">
SELECT a.raceId , a.raceName , a.startTime , a.endTime ,
c.joinTotal , b.uid , b.score , d.truename
FROM
( select raceId , raceName , startTime , endTime
from UnivRace
where status = 1
and current_timestamp &lt; endTime
order by raceId desc
<if test="pageSize!=null">
LIMIT #{pageSize}
</if>
<if test="offset!=null">
OFFSET #{offset}
</if>
) a
left join
(SELECT DISTINCT ON (raceId)
uid, raceId, score
FROM UnivraceScore
ORDER BY raceId , score DESC ) b
on a.raceId = b.raceId
left join
( SELECT raceId , count(*) joinTotal
FROM raceScore
GROUP BY raceId ) c
ON a.raceId = c.raceId
LEFT JOIN UnivStudent d
on b.uid = d.studentId
</select>
<select id="UnivfinishedRacesCount" resultType="Integer">
select count(*)
from UnivRace
where status = 0
or current_timestamp &gt; endTime
</select>
<select id="UnivfinishedRaces" parameterType="java.util.Map" resultType="RaceStatDto">
SELECT a.raceId , a.raceName , a.startTime , a.endTime ,
c.joinTotal , b.uid , b.score , d.truename
FROM
( select raceId , raceName , startTime , endTime
from UnivRace
where status = 0
or current_timestamp &gt; endTime
order by raceId desc
<if test="pageSize!=null">
LIMIT #{pageSize}
</if>
<if test="offset!=null">
OFFSET #{offset}
</if>
) a
left join
(SELECT DISTINCT ON (raceId)
uid, raceId, score
FROM UnivraceScore
ORDER BY raceId , score DESC ) b
on a.raceId = b.raceId
left join
( SELECT raceId , count(*) joinTotal
FROM UnivraceScore
GROUP BY raceId ) c
ON a.raceId = c.raceId
LEFT JOIN UnivStudent d
on b.uid = d.studentId
order by a.endTime desc, a.raceId desc ;
</select>
<select id="getUnivRacesByRaceType" parameterType="java.lang.Integer" resultType="Race">
SELECT raceId , raceName , holder , raceType , '' as description ,
startTime , endTime , joinRace , credential , badge , '' as reward ,
timeLength , '' as content , status , created , raceAreaId , banner ,title
FROM UnivRace
WHERE status = 1 and raceType = #{raceType}
and current_timestamp &lt; endTime
order by endTime ,raceId
</select>
<select id="simulatedUnivHearExamByStudentId" parameterType="java.lang.Long" resultType="UnivHearExam">
SELECT h.examid, h.examtype, h.isrecommend, h.title, h.description,
h.hearpaperid,
h.created, h.starttime, h.endtime, h.isnetexam
FROM Univhearexam h
inner join Univclassownhear c
on c.examid = h.examid
inner join Univstudentownclass s
on s.classesid = c.classesid and s.status = 1
WHERE s.studentId=#{studentId}
AND h.examType = 'S' and h.startTime &lt; now()
and h.endTime &gt; now()
union
SELECT h.examid, h.examtype, h.isrecommend, h.title, h.description,
h.hearpaperid,
h.created, h.starttime, h.endtime, h.isnetexam
FROM Univhearexam h
WHERE h.teacherId=#{studentId}
AND h.examType = 'S' and h.startTime &lt; now()
and h.endTime &gt; now()
</select>
<select id="simulatedUnivHearExamByNet" resultType="UnivHearExam">
SELECT examid, examtype, isrecommend, title, description,
hearpaperid,
created, starttime, endtime, isnetexam
FROM Univhearexam h
WHERE isNetExam = 1 AND examType = 'S'
and startTime &lt; now() and endTime &gt; now()
</select>
<select id="officialUnivHearExam" parameterType="java.lang.Long" resultType="UnivHearExam">
SELECT h.examid, h.examtype, h.isrecommend, h.title, h.description,
h.hearpaperid,
h.created, h.starttime, h.endtime, h.isnetexam
FROM Univhearexam h
inner join Univclassownhear c
on c.examid = h.examid
inner join Univstudentownclass s
on s.classesid = c.classesid and s.status = 1
WHERE s.studentId=#{studentId}
AND h.examType = 'O' and h.startTime &lt; now()
and h.endTime &gt; now()
union
SELECT h.examid, h.examtype, h.isrecommend, h.title, h.description,
h.hearpaperid,
h.created, h.starttime, h.endtime, h.isnetexam
FROM Univhearexam h
WHERE h.teacherId=#{studentId}
AND h.examType = 'O' and h.startTime &lt; now()
and h.endTime &gt; now()
order by created desc,examid desc
</select>
<select id="recommendUnivHearExamByNet" resultType="HearExam">
SELECT examid, examtype, isrecommend, title, description, hearpaperid,
created, starttime, endtime, isnetexam
FROM Univhearexam h
WHERE isNetExam = 1 AND isRecommend = 1
and startTime &lt; now() and endTime &gt; now()
</select>
<select id="recommendUnivHearExamByStudentId" parameterType="java.lang.Long" resultType="HearExam">
SELECT h.examid, h.examtype, h.isrecommend, h.title, h.description,
h.hearpaperid,
h.created, h.starttime, h.endtime, h.isnetexam
FROM Univhearexam h
inner join Univclassownhear c
on c.examid = h.examid
inner join Univstudentownclass s
on s.classesid = c.classesid and s.status = 1
WHERE s.studentId=#{studentId}
AND h.isRecommend = 1 and h.startTime &lt; now()
and h.endTime &gt; now()
</select>
<select id="getUnivExamsByClassesIdAndType" parameterType="java.util.Map" resultType="UnivExam">
SELECT b.examId , b.examType , b.isRecommend , b.title , b.description ,
b.examPaperCount , b.examPapers , b.created , b.startTime , b.endTime ,
b.isNetExam,b.isOral
FROM univClassOwnExam a
INNER join univExam b
ON a.classesId = #{classesId} and a.examId = b.examId
AND a.objectType = #{objectType} and b.isOral=#{isOral}
WHERE
b.startTime &lt;= current_timestamp and b.endTime &gt;= current_timestamp
ORDER BY b.examId DESC
</select>
<select id="getUnivHearsByClassesIdAndType" parameterType="java.util.Map" resultType="UnivExam">
SELECT h.examId , h.examType , h.isRecommend , h.title , h.description ,
h.examPaperCount , h.examPapers , h.created , h.startTime , h.endTime ,
h.isNetExam , h.isOral
FROM v_univhearexam h
INNER JOIN univclassownhear c
ON c.classesId = #{classesId} AND c.examid = h.examid
AND c.objectType = #{objectType} and h.isOral=-1
and h.startTime &lt;= current_timestamp and h.endTime &gt;= current_timestamp
union
SELECT h.examId , h.examType , h.isRecommend , h.title , h.description ,
h.examPaperCount , h.examPapers , h.created , h.startTime , h.endTime ,
h.isNetExam , h.isOral
FROM v_univhearexam h
INNER JOIN univclassownexam c
ON c.classesId = #{classesId} AND c.examid = h.examid
AND c.objectType = #{objectType} and h.isOral=2
and h.startTime &lt;= current_timestamp and h.endTime &gt;= current_timestamp
ORDER BY created DESC,examid desc
</select>
<select id="simulatedNewUnivHearExamByNet" resultType="UnivExam">
SELECT h.examId , h.examType , h.isRecommend , h.title , h.description ,
h.examPaperCount , h.examPapers , h.created , h.startTime , h.endTime ,
h.isNetExam , h.isOral
FROM v_univhearexam h
WHERE isNetExam = 1 AND examType = 'S' and startTime &lt; now() and endTime &gt; now()
ORDER BY h.created DESC,h.title DESC, h.isoral
</select>
<select id="newUnivHearExam" parameterType="java.util.Map" resultType="UnivExam">
select
h.examId , h.examType , h.isRecommend , h.title , h.description ,
h.examPaperCount , h.examPapers , h.created , h.startTime , h.endTime ,
h.isNetExam , h.isOral
FROM v_univhearexam h inner join univclassownhear c on c.examid = h.examid and h.isOral=-1
inner join univstudentownclass s on s.classesid = c.classesid and s.status = 1
WHERE s.studentId=#{uid} and c.objectType = 1
AND h.examType = #{examType} and h.startTime &lt; now() and h.endTime &gt; now()
union
SELECT h.examId , h.examType , h.isRecommend , h.title , h.description ,
h.examPaperCount , h.examPapers , h.created , h.startTime , h.endTime ,
h.isNetExam , h.isOral
FROM v_univhearexam h
WHERE h.teacherId=#{uid} and h.examType = #{examType} and
h.startTime &lt; now() and h.endTime &gt; now()
union
select
h.examId , h.examType , h.isRecommend , h.title , h.description ,
h.examPaperCount , h.examPapers , h.created , h.startTime , h.endTime ,
h.isNetExam , h.isOral
FROM v_univhearexam h inner join univclassownexam c on c.examid = h.examid and isOral=2
inner join univstudentownclass s on s.classesid = c.classesid and s.status = 1
WHERE s.studentId=#{uid} and c.objectType = 1
and h.examType = #{examType} and h.startTime &lt; now() and h.endTime &gt; now()
order by created desc ,title desc,isOral
</select>
</mapper>