162 lines
6.4 KiB
XML
162 lines
6.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="UnivFinishwordsStat">
|
||
|
|
|
||
|
|
<insert id="insertUnivFinishwordsStat" parameterType="UnivFinishwordsStat">
|
||
|
|
INSERT INTO FinishwordsStat ( uid, unitId, content, wordsCount, completeCount, created, howmuch, maxScore, avgScore , areaid ) Values ( #{uid}, #{unitId}, #{content}, #{wordsCount}, #{completeCount},current_timestamp, #{howmuch}, #{maxScore}, #{avgScore} , #{areaid} )
|
||
|
|
|
||
|
|
</insert>
|
||
|
|
|
||
|
|
<update id="updateUnivFinishwordsStat" parameterType="UnivFinishwordsStat">
|
||
|
|
|
||
|
|
|
||
|
|
UPDATE UnivFinishwordsStat SET
|
||
|
|
|
||
|
|
uid = #{uid}, unitId = #{unitId}, content = #{content}, wordsCount = #{wordsCount}, completeCount = #{completeCount}, created = #{created}, howmuch = #{howmuch}, maxScore = #{maxScore}, avgScore = #{avgScore} , areaid= #{areaid}
|
||
|
|
where uid=#{uid} and unitId=#{unitId} and areaid = #{areaid}
|
||
|
|
|
||
|
|
</update>
|
||
|
|
|
||
|
|
<select id="getUnivFinishwordsStatByKey" parameterType="java.util.Map" resultType="UnivFinishwordsStat">
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
SELECT uid , unitId , content , wordsCount , completeCount , created , howmuch , maxScore , avgScore , areaid
|
||
|
|
FROM UnivFinishwordsStat WHERE uid=#{uid} and unitId=#{unitId} and areaid = #{areaid}
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="getSeqUnivFinishwordsStat" resultType="Integer" useCache="false" flushCache="true">
|
||
|
|
|
||
|
|
SELECT nextval('seq_univfinishwordsStatId') ;
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="getUnivFinishwordsStatsCountByUid" parameterType="java.util.Map" resultType="Integer">
|
||
|
|
|
||
|
|
SELECT count(*) as howmuch from UnivFinishwordsStat
|
||
|
|
WHERE uid=#{uid} and areaid = #{areaid}
|
||
|
|
|
||
|
|
</select>
|
||
|
|
<select id="getUnivFinishwordsStatsByUid" parameterType="java.util.Map" resultType="UnivFinishwordsStat">
|
||
|
|
|
||
|
|
|
||
|
|
SELECT uid , unitId , content , wordsCount , completeCount , created , howmuch , maxScore , avgScore , areaid
|
||
|
|
FROM UnivFinishwordsStat
|
||
|
|
WHERE uid=#{uid} and areaid = #{areaid}
|
||
|
|
<if test="pageSize!=null">
|
||
|
|
LIMIT #{pageSize}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
<if test="offset!=null">
|
||
|
|
OFFSET #{offset}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="getUnivFinishwordsStatsCountByUnitId" parameterType="java.lang.Integer" resultType="Integer">
|
||
|
|
|
||
|
|
SELECT count(*) as howmuch from FinishwordsStat
|
||
|
|
WHERE unitId=#{unitId}
|
||
|
|
|
||
|
|
</select>
|
||
|
|
<select id="getUnivFinishwordsStatsByUnitId" parameterType="java.util.Map" resultType="UnivFinishwordsStat">
|
||
|
|
|
||
|
|
|
||
|
|
SELECT uid , unitId , content , wordsCount , completeCount , created , howmuch , maxScore , avgScore , areaid
|
||
|
|
FROM FinishwordsStat
|
||
|
|
WHERE unitId=#{unitId}
|
||
|
|
ORDER BY finishwordsStatId desc
|
||
|
|
<if test="pageSize!=null">
|
||
|
|
LIMIT #{pageSize}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
<if test="offset!=null">
|
||
|
|
OFFSET #{offset}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<delete id="deleteOldUnivFinishWordss" parameterType="java.util.List">
|
||
|
|
with temp as ( select distinct a.uid , b.lessonId as unitId , a.areaId
|
||
|
|
from ( select uid , wordsId , areaId
|
||
|
|
from UnivWordAchive
|
||
|
|
where
|
||
|
|
created > current_date - interval '1 day'
|
||
|
|
and created < current_date
|
||
|
|
) as a
|
||
|
|
inner join words b
|
||
|
|
on a.wordsId = b.wordsId )
|
||
|
|
DELETE FROM UnivFinishwordsStat m
|
||
|
|
USING temp
|
||
|
|
WHERE m.uid = temp.uid and m.unitId = temp.UnitId
|
||
|
|
</delete>
|
||
|
|
|
||
|
|
<insert id="insertNewUnivFinishWordss" parameterType="java.util.List">
|
||
|
|
with temp as ( select distinct a.uid , b.lessonId as unitId , a.areaId
|
||
|
|
from ( select uid , wordsId , areaId
|
||
|
|
from UnivWordAchive
|
||
|
|
where
|
||
|
|
created > current_date - interval '1 day'
|
||
|
|
and created < current_date
|
||
|
|
) as a
|
||
|
|
inner join words b
|
||
|
|
on a.wordsId = b.wordsId )
|
||
|
|
insert into UnivFinishWordsStat ( uid , unitid , content , wordscount ,
|
||
|
|
completecount , created , howmuch , maxscore , avgscore , areaid )
|
||
|
|
select p.uid , p.unitId , s.lessonname as content , r.wordsCount ,
|
||
|
|
p.completeCount , current_timestamp , howmuch , maxScore , avgScore , areaid
|
||
|
|
from ( select temp.uid , temp.unitId , temp.areaid , count( distinct a.wordsId ) as completecount,
|
||
|
|
count(a.wordachiveid) as howmuch , max(a.score ) as maxscore ,
|
||
|
|
round(avg(a.score)) as avgscore
|
||
|
|
from temp
|
||
|
|
inner join words b
|
||
|
|
on temp.unitId = b.lessonId
|
||
|
|
inner join UnivWordAchive a
|
||
|
|
on temp.uid = a.uid and b.wordsId = a.wordsId
|
||
|
|
group by temp.uid , temp.unitId , temp.areaId ) as p
|
||
|
|
inner join ( select lessonId as unitId , count(*) as wordsCount
|
||
|
|
from Words
|
||
|
|
group by lessonId ) as r
|
||
|
|
on p.unitId = r.unitid
|
||
|
|
inner join Lesson s
|
||
|
|
on p.unitId = s.lessonId
|
||
|
|
</insert>
|
||
|
|
|
||
|
|
<select id="UnivwordsQueryStatForUser" parameterType="java.util.Map" resultType="UnivFinishwordsStat">
|
||
|
|
Select b.uid , a.lessonId as unitId , a.lessonName as content , b.wordsCount ,
|
||
|
|
b.completeCount ,b.created ,b.howmuch ,b.maxScore , b.avgScore , b.areaid
|
||
|
|
from Lesson a
|
||
|
|
left join UnivFinishWordsStat b
|
||
|
|
on b.uid = #{uid} and a.lessonId = b.unitId
|
||
|
|
where a.parentId = #{bookId}
|
||
|
|
order by a.orderId
|
||
|
|
|
||
|
|
</select>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="getUnivFinishWordsByYes" parameterType="java.util.Map" resultType="UnivFinishwordsStat">
|
||
|
|
select l.uid , l.unitId , m.lessonName , n.wordsCount ,
|
||
|
|
l.finishCount , current_timestamp , l.howmuch , l.maxScore , l.avgScore , l.areaid
|
||
|
|
from
|
||
|
|
( select a.uid , b.lessonId as unitId , count( distinct b.wordsId ) as finishCount ,
|
||
|
|
count(*) as howmuch , max( score ) as maxScore , avg( score ) as avgScore , a.areaid
|
||
|
|
from UnivWordAchive a
|
||
|
|
inner join Words b
|
||
|
|
on a.wordsId = b.wordsId
|
||
|
|
|
||
|
|
where a.created < current_date and a.created > current_date - interval '1 day'
|
||
|
|
|
||
|
|
group by a.uid , b.lessonId , a.areaid) l
|
||
|
|
inner join Lesson m
|
||
|
|
on l.unitId = m.lessonId
|
||
|
|
inner join ( select lessonId as unitId , count(*) as wordsCount
|
||
|
|
from Words
|
||
|
|
group by lessonId ) n
|
||
|
|
on l.unitId = n.unitId
|
||
|
|
</select>
|
||
|
|
</mapper>
|