423 lines
16 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="UnivSuperHero">
<select id="UnivnetSuperHeros" parameterType="java.util.Map" resultType="SuperHero">
select a.uid , a.truename , d.schoolId , d.schoolName , a.avgScore ,
a.userLevel , a.levelName , 0 as isFollowed
From ( select l.uid , Round( l.totalScore / l.howmuch ) as avgScore , l.howmuch ,
l.userLevel , l.levelName , m.truename ,l.totalScore , m.lastsignIn , m.schoolId
from UnivUserHonor l
inner join univStudent m
on l.uid = m.studentId
where howmuch &gt; 1
order by Round( l.totalScore / l.howmuch ) desc , l.totalScore desc , m.lastsignIn desc
<if test="pageSize!=null">
LIMIT #{pageSize}
</if>
<if test="offset!=null">
OFFSET #{offset}
</if>
) a
inner join university d
on a.schoolId = d.schoolId
order by a.avgScore desc , a.totalScore desc , a.lastsignIn desc
</select>
<select id="UnivnetSuperHerosCount" resultType="Integer">
select count(*)
From ( select uid , Round( totalScore / howmuch ) as avgScore , howmuch
userLevel , levelName
from univUserHonor
where howmuch &gt; 1
order by avgScore desc , howmuch desc
) a
inner join UnivStudent m
on a.uid = m.studentId
inner join university d
on m.schoolId = d.schoolId
</select>
<select id="UnivnetSuperVoices" parameterType="java.util.Map" resultType="SuperVoice">
select a.uid , c.truename , b.schoolId , b.schoolName , a.uuid as voice , a.created ,
0 as isFollowed ,a.score , 0 as bookId , '' as bookName , 0 as unitId ,
'' as unitName , 0 as lessonId , '' as lessonName
from ( select p.uid , p.score , p.tempId , p.uuid , p.created , q.schoolId
from ( select uid , score , uuid , created ,
max( achivementId ) OVER (PARTITION BY uid order by score desc ) as tempId ,
row_number() OVER (PARTITION BY uid order by score desc ) as rn
from univAchivement
where pointcasetype = 5 and length( uuid ) &gt; 0
and achiveType = 'L'
and created &lt; ( current_date +interval '-0 day')
) p
inner join univStudent q
on p.uid = q.studentId and p.rn =1
order by p.score desc , p.tempId desc
<if test="pageSize!=null">
LIMIT #{pageSize}
</if>
<if test="offset!=null">
OFFSET #{offset}
</if>
) a
inner join university b
on a.schoolId = b.schoolId
inner join univStudent c
on a.uid = c.studentId
order by a.score desc , a.created desc
</select>
<select id="UnivnetSuperVoicesCount" resultType="Integer">
select count(distinct(a.uid))
from ( select p.uid , p.score , p.uuid , q.schoolId , p.created
from univAchivement p
inner join univStudent q
on p.pointcasetype = 5 and length( p.uuid ) &gt; 0
and p.achiveType = 'L' and p.uid = q.studentId
inner join (select max(achivementid) as achivementid, uid , max(score) from univAchivement a where pointcasetype = 5 and length( uuid ) &gt; 0
and achiveType = 'L'
and created &lt; ( current_date +interval '-0 day') group by uid) m on p.achivementid = m.achivementid
where p.created &lt; ( current_date +interval '-0 day')
) a
inner join university b
on a.schoolId = b.schoolId
inner join univStudent c
on a.uid = c.studentId
</select>
<select id="UnivprivateVoicesCount" parameterType="java.util.Map" resultType="Integer">
select count(*)
from UnivAchivement p
where length( p.uuid ) &gt; 0 and p.achiveType = 'L'
and p.pointCaseType = 5 and p.uid = #{uid}
AND p.created &gt; #{startTime} and p.created &lt;= #{endTime};
</select>
<select id="UnivprivateVoices" parameterType="java.util.Map" resultType="SuperVoice">
select a.uid ,'' as truename , 0 as schoolId , '' as schoolName ,
a.uuid as voice , 0 as isFollowed , a.score , a.created ,
d.lessonId as bookId , d.lessonName as bookName ,
c.lessonId as unitId , c.lessonName as unitName ,
b.lessonId , b.lessonName
from ( select p.uid , p.score , p.uuid , p.objectId , p.created
from UnivAchivement p
where length( p.uuid ) &gt; 0 and p.achiveType = 'L'
AND p.created &gt; #{startTime} and p.created &lt;= #{endTime}
and p.pointCaseType = 5 and p.uid = #{uid}
order by p.score desc , p.achivementId desc
<if test="pageSize!=null">
LIMIT #{pageSize}
</if>
<if test="offset!=null">
OFFSET #{offset}
</if>
) a
inner join Lesson b
on a.objectId = b.lessonId
inner join Lesson c
on b.parentId = c.lessonId
inner join Lesson d
on c.parentId = d.lessonId ;
</select>
<select id="UnivprivateRaceVoices" parameterType="java.util.Map" resultType="SuperVoice">
select a.uid ,'' as truename , 0 as schoolId , '' as schoolName ,
a.uuid as voice , 0 as isFollowed , a.score , a.created ,
a.raceId as bookId, r.raceName as bookName ,
0 as unitId , '' as unitName ,
0 as lessonId , '' as lessonName
from ( select p.uid , p.score , p.uuid , p.raceId , p.created
from UnivRaceScore p
where length( p.uuid ) &gt; 0
and p.created &gt; #{startTime} and p.created &lt;= #{endTime}
and p.uid = #{uid}
order by p.score desc , p.raceScoreId desc
<if test="pageSize!=null">
LIMIT #{pageSize}
</if>
<if test="offset!=null">
OFFSET #{offset}
</if>
) a
inner join Univrace r on r.raceId = a.raceId ;
</select>
<select id="UnivprivateRaceVoicesCount" parameterType="java.util.Map" resultType="Integer">
select count(*)
from UnivRaceScore p
where length( p.uuid ) &gt; 0
and p.uid = #{uid}
and p.created &gt; #{startTime} and p.created &lt;= #{endTime};
</select>
<select id="UnivprivateRaceRank" parameterType="long" resultType="java.util.HashMap">
select r.raceid , #{uid} as uid , sum( case when ( r.maxScore &gt; m.selfMaxScore ) and ( r.uid &lt;&gt; m.uid ) then
1
else 0 end ) + 1 as rank
from UnivraceMaxScore r
inner join ( select raceId , uid , maxScore as selfMaxScore
from UnivraceMaxScore
where uid =#{uid} ) m
on r.raceId = m.raceId
group by r.raceId ;
</select>
<select id="UnivclassSuperHeros" parameterType="java.util.Map" resultType="SuperHero">
<if test="timeType==null">
select a.uid , b.truename , 0 as schoolId , '' as schoolName , a.avgScore ,
a.userLevel , a.levelName , 0 as isFollowed
From ( select q.uid , q.totalScore::numeric/q.howmuch as avgScore ,
userLevel , levelName
from UnivStudentOwnClass p
inner join UnivUserHonor q
on p.classesId = #{classesId} and p.studentId = q.uid
where q.howmuch &gt; 1 and p.status =1
order by avgScore desc , q.howmuch desc
<if test="pageSize!=null">
LIMIT #{pageSize}
</if>
<if test="offset!=null">
OFFSET #{offset}
</if>
) a
inner join UnivStudent b
on a.uid = b.studentId and b.status=1
order by a.avgScore desc
</if>
<if test="timeType!=null">
SELECT a.uid,
avg(a.score) AS avgScore,st.truename
FROM univachivement a
inner join univstudentownclass s on a.uid=s.studentId and s.status=1 and s.classesId=#{classesId}
and (a.pointcasetype = ANY (ARRAY[3, 5, 6, 7, 8]))
<if test='timeType=="week"'>
AND a.created&gt; ( current_date + interval '-1 week') and a.created&lt;current_date
</if>
<if test='timeType=="month"'>
AND a.created&gt; ( current_date + interval '-1 month') and a.created&lt;current_date
</if>
inner join univstudent st on a.uid=st.studentid
GROUP BY a.uid ,st.truename
order by avgScore desc ,a.uid
limit 10
</if>
</select>
<select id="UnivclassSuperHerosCount" parameterType="java.util.Map" resultType="Integer">
select count(*)
from UnivStudentOwnClass p
inner join UnivUserHonor q
on p.classesId = #{classesId} and p.studentId = q.uid
where q.howmuch &gt; 1 and p.status =1
</select>
<select id="UnivclassSuperVoices" parameterType="java.util.Map" resultType="SuperVoice">
select a.uid , 0 as schoolId , '' as schoolName , a.uuid as voice , a.created ,
0 as isFollowed , a.score ,
d.lessonId as bookId , d.lessonName as bookName ,
c.lessonId as unitId , c.lessonName as unitName ,
b.lessonId , b.lessonName
from ( select p.uid , p.score , p.uuid , p.objectId , p.created
from UnivStudentOwnClass q
inner join UnivAchivement p
on q.classesId = #{classesId} and q.studentId = p.uid
and length( p.uuid ) &gt; 0 and p.achiveType = 'L'
and p.pointCaseType = 5 and p.uid = q.studentId
where p.created &gt; (now() + interval '-1 month') and q.status =1
and p.created &lt; ( current_date +interval '-0 day')
) a
inner join Lesson b
on a.objectId = b.lessonId
inner join Lesson c
on b.parentId = c.lessonId
inner join Lesson d
on c.parentId = d.lessonId
order by a.score desc , a.created desc
<if test="pageSize!=null">
LIMIT #{pageSize}
</if>
<if test="offset!=null">
OFFSET #{offset}
</if>
</select>
<select id="UnivclassSuperVoicesCount" parameterType="Long" resultType="Integer">
select count(*)
from ( select p.uid , p.score , p.uuid , p.objectId , p.created
from UnivStudentOwnClass q
inner join UnivAchivement p
on q.classesId = #{classesId} and q.studentId = p.uid
and length( p.uuid ) &gt; 0 and p.achiveType = 'L'
and p.pointCaseType = 5 and p.uid = q.studentId
where
<if test='timeType == "week"'>
p.created &gt; (now() + interval '-1 week') and q.status =1
and p.created &lt; ( current_date +interval '-0 day')
</if>
<if test='timeType == "month"'>
p.created &gt; (now() + interval '-1 month') and q.status =1
and p.created &lt; ( current_date +interval '-0 day')
</if>
) a
inner join Lesson b
on a.objectId = b.lessonId
inner join Lesson c
on b.parentId = c.lessonId
inner join Lesson d
on c.parentId = d.lessonId
</select>
<select id="UnivclassSuperGoldens" parameterType="java.util.Map" resultType="SuperHero">
select a.uid , b.truename , 0 as schoolId , '' as schoolName , a.avgScore ,
a.userLevel , a.levelName , 0 as isFollowed
From ( select q.uid , q.goldmedalcount as avgScore ,
userLevel , levelName
from UnivStudentOwnClass p
inner join UnivUserHonor q
on p.classesId = #{classesId} and p.studentId = q.uid
where q.goldmedalcount &gt; 0 and p.status =1
order by q.goldmedalcount desc
<if test="pageSize!=null">
LIMIT #{pageSize}
</if>
<if test="offset!=null">
OFFSET #{offset}
</if>
) a
inner join UnivStudent b
on a.uid = b.studentId
order by a.avgScore desc
</select>
<select id="UnivclassSuperFollows" parameterType="java.util.Map" resultType="SuperHero">
select a.uid , b.truename , 0 as schoolId , '' as schoolName , m.avgScore ,
a.userLevel , a.levelName , 0 as isFollowed
From ( select p.studentId , count(*) as avgScore
from UnivStudentOwnClass p
inner join UnivFollowShip q
on p.classesId = #{classesId} and p.studentId = q.beFollower
where p.status =1
group by p.studentId
order by avgScore desc , p.studentId asc
<if test="pageSize!=null">
LIMIT #{pageSize}
</if>
<if test="offset!=null">
OFFSET #{offset}
</if>
) m
inner join UnivUserHonor a
on m.studentId = a.uid
inner join UnivStudent b
on a.uid = b.studentId
order by m.avgScore desc
</select>
<select id="univClassSuperGoldensByTime" parameterType="java.util.Map" resultType="SuperHero" >
WITH temp AS (
SELECT b.userid AS uid,
count(*) AS howmuch
FROM univbadgelog b inner join univstudentownclass s on b.userid=s.studentid and s.classesid=#{classesId}
and s.status=1
and b.badgetype = 1 AND b.badgecaseid = 4
<if test='timeType=="week"'>
AND b.created&gt; ( current_date + interval '-1 week') and b.created&lt;current_date
</if>
<if test='timeType=="month"'>
AND b.created&gt; ( current_date + interval '-1 month') and b.created&lt;current_date
</if>
GROUP BY b.userid
order by howmuch desc limit 10
)
select t.howmuch numCount,t.uid,s.truename from
temp t inner join univstudent s on t.uid=s.studentid
order by numCount desc,uid desc
</select>
<select id="univClassSuperHerosByTime" parameterType="java.util.Map" resultType="SuperHero" >
SELECT a.uid,
count(a.objectid) AS numCount,st.truename
FROM univachivement a
inner join univstudentownclass s on a.uid=s.studentId and s.status=1 and s.classesId=#{classesId}
and (a.pointcasetype = ANY (ARRAY[3, 5, 6, 7, 8]))
<if test='timeType=="week"'>
AND a.created&gt; ( current_date + interval '-1 week') and a.created&lt;current_date
</if>
<if test='timeType=="month"'>
AND a.created&gt; ( current_date + interval '-1 month') and a.created&lt;current_date
</if>
inner join univstudent st on a.uid=st.studentid
GROUP BY a.uid ,st.truename
order by numCount desc ,a.uid
limit 10
</select>
</mapper>