spokenServer/out/production/pcserver/sqlmap/UnivFinishLessonStat.xml
2026-03-10 14:30:24 +08:00

156 lines
6.1 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="UnivFinishLessonStat">
<insert id="insertUnivFinishLessonStat" parameterType="UnivFinishLessonStat">
INSERT INTO UnivFinishLessonStat ( uid, unitId, content, lessonCount, completeCount, created, howmuch, maxScore, avgScore , areaid ) Values ( #{uid}, #{unitId}, #{content}, #{lessonCount}, #{completeCount},current_timestamp, #{howmuch}, #{maxScore}, #{avgScore} , #{areaid} )
</insert>
<update id="updateUnivFinishLessonStat" parameterType="UnivFinishLessonStat">
UPDATE UnivFinishLessonStat SET
uid = #{uid}, unitId = #{unitId}, content = #{content}, lessonCount = #{lessonCount}, completeCount = #{completeCount}, created = #{created}, howmuch = #{howmuch}, maxScore = #{maxScore}, avgScore = #{avgScore} , areaid = #{areaid}
where uid=#{uid} and areaid = #{areaid}
</update>
<select id="getUnivFinishLessonStatByKey" parameterType="java.util.Map" resultType="UnivFinishLessonStat">
SELECT uid , unitId , content , lessonCount , completeCount , created , howmuch , maxScore , avgScore , areaid
FROM UnivFinishLessonStat WHERE uid=#{uid} and unitId = #{unitId} and areaid = #{areaid}
</select>
<select id="getSeqUnivFinishLessonStat" resultType="Integer" useCache="false" flushCache="true">
SELECT nextval('seq_univfinishLessonStatId') ;
</select>
<select id="getUnivFinishLessonStatsCountByUid" parameterType="java.util.Map" resultType="Integer">
SELECT count(*) as howmuch from UnivFinishLessonStat
WHERE uid=#{uid} and areaid = #{areaid}
</select>
<select id="getUnivFinishLessonStatsByUid" parameterType="java.util.Map" resultType="UnivFinishLessonStat">
SELECT uid , unitId , content , lessonCount , completeCount , created , howmuch , maxScore , avgScore , areaid
FROM UnivFinishLessonStat
WHERE uid=#{uid} and areaid = #{areaid}
<if test="pageSize!=null">
LIMIT #{pageSize}
</if>
<if test="offset!=null">
OFFSET #{offset}
</if>
</select>
<select id="getUnivFinishLessonStatsCountByUnitId" parameterType="java.lang.Integer" resultType="Integer">
SELECT count(*) as howmuch from UnivFinishLessonStat
WHERE unitId=#{unitId}
</select>
<select id="getUnivFinishLessonStatsByUnitId" parameterType="java.util.Map" resultType="UnivFinishLessonStat">
SELECT uid , unitId , content , lessonCount , completeCount , created , howmuch , maxScore , avgScore , areaid
FROM UnivFinishLessonStat
WHERE unitId=#{unitId}
ORDER BY finishLessonStatId desc
<if test="pageSize!=null">
LIMIT #{pageSize}
</if>
<if test="offset!=null">
OFFSET #{offset}
</if>
</select>
<delete id="deleteOldUnivFinishLessons" parameterType="java.util.List">
delete from UnivFinishLessonStat where 1=0
<foreach collection="list" index="index" item="item">
or (uid = #{item.uid} and unitid = #{item.unitId})
</foreach>
</delete>
<insert id="insertNewUnivFinishLessons" parameterType="java.util.List">
Insert into UnivFinishLessonStat ( uid , unitId , content , lessonCount ,
completeCount , created , howmuch , maxScore , avgScore , areaid )
select l.uid , l.unitId , m.lessonName , n.lessonCount ,
l.finishCount , current_timestamp , l.howmuch , l.maxScore , l.avgScore , l.areaid
from
( select a.uid , c.parentId as unitId , count( distinct c.lessonId ) as finishCount ,
count(*) as howmuch , max( score ) as maxScore , avg( score ) as avgScore , a.areaid
from UnivAchivement a
inner join Lesson c
on a.achiveType = 'L' and a.pointCaseType in ( 5, 6 ,7 , 8 )
and a.objectId = c.lessonId
group by a.uid , c.parentId , a.areaid) l
inner join Lesson m
on l.unitId = m.lessonId
inner join ( select parentId , count(*) as lessonCount
from Lesson
group by parentId ) n
on l.unitId = n.parentId
where 1=0
<foreach collection="list" index="index" item="item">
or (uid = #{item.uid} and unitid = #{item.unitId})
</foreach>
</insert>
<select id="UnivlessonQueryStatForUser" parameterType="java.util.Map" resultType="UnivFinishLessonStat">
Select b.uid , a.lessonId as unitId , a.lessonName as content , b.lessonCount ,
b.completeCount ,b.created ,b.howmuch ,b.maxScore , b.avgScore , b.areaid
from Lesson a
left join UnivFinishLessonStat b
on b.uid = #{uid} and a.lessonId = b.unitId
where a.parentId = #{bookId}
order by a.orderId
</select>
<select id="getUnivFinishLessonsByYes" resultType="UnivFinishLessonStat">
select l.uid , l.unitId , m.lessonName , n.lessonCount ,
l.finishCount , current_timestamp , l.howmuch , l.maxScore , l.avgScore , l.areaid
from
( select a.uid , c.parentId as unitId , count( distinct c.lessonId ) as finishCount ,
count(*) as howmuch , max( score ) as maxScore , avg( score ) as avgScore , a.areaid
from UnivAchivement a
inner join Lesson c
on a.achiveType = 'L' and a.pointCaseType in ( 5, 6 ,7 , 8 )
and a.objectId = c.lessonId
where a.created &lt; current_date and a.created &gt; current_date - interval '1 day'
group by a.uid , c.parentId , a.areaid) l
inner join Lesson m
on l.unitId = m.lessonId
inner join ( select parentId , count(*) as lessonCount
from Lesson
group by parentId ) n
on l.unitId = n.parentId
</select>
</mapper>