139 lines
5.7 KiB
XML
139 lines
5.7 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="com._3e.dao.WrongBookDao">
|
||
|
|
|
||
|
|
<!--查询已经订正的错题数量,没有订正的错题数量,当天订正的错题数量-->
|
||
|
|
<select id="findMyWrongBookNum" parameterType="map" resultType="com._3e.http.wrongbook.dto.WrongBookNum">
|
||
|
|
SELECT count(iscorrect='1' or null) sumReviseWrong,
|
||
|
|
count(iscorrect='0' or null) sumUnreviseWrong,
|
||
|
|
count(iscorrect='1' and TO_CHAR(created,'yyyy-MM-dd')=TO_CHAR(current_timestamp,'yyyy-MM-dd') or null) daySumReviseWrong
|
||
|
|
from wrongbook where uid=#{uid}
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<!--查询当天订正的错题数量-->
|
||
|
|
<select id="findMyDaySumReviseWrong" parameterType="map" resultType="com._3e.http.wrongbook.dto.WrongBookNum">
|
||
|
|
with temp as(
|
||
|
|
SELECT distinct uid,guid from wrongbook where uid=#{uid} and iscorrect='1' and TO_CHAR(created,'yyyy-MM-dd')=TO_CHAR(current_timestamp,'yyyy-MM-dd')
|
||
|
|
)
|
||
|
|
SELECT count(1) daySumReviseWrong from temp
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<!--查询每个题型的错题数量,已订正的数量-->
|
||
|
|
<select id="findMyEveryWrongBookNum" parameterType="map" resultType="com._3e.http.wrongbook.dto.WrongBookNum">
|
||
|
|
with temp as(
|
||
|
|
SELECT guid,parttype,iscorrect
|
||
|
|
from wrongbook where uid=#{uid} GROUP BY guid,iscorrect,parttype
|
||
|
|
)
|
||
|
|
SELECT parttype,count(1) sumAllWrong,count(iscorrect='1' or null) sumReviseWrong from temp
|
||
|
|
GROUP BY parttype
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<!--查询大题下面小题错题数量,已订正的数量-->
|
||
|
|
<select id="findMyEveryWrongBookNumByqerstype" parameterType="map" resultType="com._3e.http.wrongbook.dto.WrongBookNum">
|
||
|
|
with temp as(
|
||
|
|
SELECT guid,questype,iscorrect
|
||
|
|
from wrongbook where uid=#{uid} and parttype = #{parttype} GROUP BY guid,iscorrect,questype
|
||
|
|
)
|
||
|
|
SELECT questype,count(1) sumAllWrong,count(iscorrect='1' or null) sumReviseWrong from temp
|
||
|
|
GROUP BY questype
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<!--查询单类型的已订正或者未订正的错题或者全部数据-->
|
||
|
|
<select id="findMyOneTypeWrongByIscorrect" parameterType="map" resultType="com._3e.http.wrongbook.dto.WrongBook">
|
||
|
|
<!--select uid,guid,parttype,exampaperid,examanswerid,origiscore,truescore,multiques,iscorrect,created from wrongbook where uid=#{uid} and parttype=#{parttype}
|
||
|
|
<if test="iscorrect!=2">
|
||
|
|
and iscorrect=#{iscorrect}
|
||
|
|
</if>
|
||
|
|
order by created desc,iscorrect desc-->
|
||
|
|
select * from (
|
||
|
|
select uid,guid,parttype,exampaperid,examanswerid,origiscore,truescore,multiques,iscorrect,created,examid
|
||
|
|
,row_number() over(partition by guid ORDER BY created desc,iscorrect desc) new_index
|
||
|
|
from wrongbook where uid=#{uid} and parttype=#{parttype}
|
||
|
|
<if test="iscorrect!=2">
|
||
|
|
and iscorrect=#{iscorrect}
|
||
|
|
</if>
|
||
|
|
) s where s.new_index=1
|
||
|
|
<if test="page !=null">
|
||
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
||
|
|
</if>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="findMyOneTypeWrongByIscorrect_1" parameterType="map" resultType="com._3e.http.wrongbook.dto.WrongBook">
|
||
|
|
<!--select uid,guid,parttype,exampaperid,examanswerid,origiscore,truescore,multiques,iscorrect,created from wrongbook where uid=#{uid} and parttype=#{parttype}
|
||
|
|
<if test="iscorrect!=2">
|
||
|
|
and iscorrect=#{iscorrect}
|
||
|
|
</if>
|
||
|
|
order by created desc,iscorrect desc-->
|
||
|
|
select * from (
|
||
|
|
select uid,guid,parttype,exampaperid,examanswerid,origiscore,truescore,multiques,iscorrect,created,examid
|
||
|
|
,row_number() over(partition by guid ORDER BY created desc,iscorrect desc) new_index
|
||
|
|
from wrongbook where uid=#{uid} and parttype=#{parttype}
|
||
|
|
<if test="questype==1">
|
||
|
|
and (questype = #{questype} or questype = 0)
|
||
|
|
</if>
|
||
|
|
<if test="questype!=1">
|
||
|
|
and questype = #{questype}
|
||
|
|
</if>
|
||
|
|
<if test="iscorrect!=2">
|
||
|
|
and iscorrect=#{iscorrect}
|
||
|
|
</if>
|
||
|
|
) s where s.new_index=1
|
||
|
|
<if test="page !=null">
|
||
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
||
|
|
</if>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<select id="findMyOneTypeWrongByIscorrect_2" parameterType="map" resultType="com._3e.http.wrongbook.dto.WrongBook">
|
||
|
|
<!--select uid,guid,parttype,exampaperid,examanswerid,origiscore,truescore,multiques,iscorrect,created from wrongbook where uid=#{uid} and parttype=#{parttype}
|
||
|
|
<if test="iscorrect!=2">
|
||
|
|
and iscorrect=#{iscorrect}
|
||
|
|
</if>
|
||
|
|
order by created desc,iscorrect desc-->
|
||
|
|
select * from (
|
||
|
|
select uid,guid,parttype,exampaperid,examanswerid,origiscore,truescore,multiques,iscorrect,created,examid
|
||
|
|
,row_number() over(partition by guid ORDER BY created desc,iscorrect desc) new_index
|
||
|
|
from wrongbook where uid=#{uid} and parttype=#{parttype} and (questype = 0 or questype = 1)
|
||
|
|
<if test="iscorrect!=2">
|
||
|
|
and iscorrect=#{iscorrect}
|
||
|
|
</if>
|
||
|
|
) s where s.new_index=1
|
||
|
|
<if test="page !=null">
|
||
|
|
LIMIT #{page.limit} OFFSET #{page.offset}
|
||
|
|
</if>
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<!--更新错题表的状态和答案和时间-->
|
||
|
|
<update id="doUpdateMyWrongBookStatus" parameterType="map">
|
||
|
|
update wrongbook set iscorrect=#{iscorrect},
|
||
|
|
multiques=#{multiques,typeHandler=com._3e.http.wrongbook.typehandler.JSONTypeHandlerPg},
|
||
|
|
created=#{created}
|
||
|
|
where uid=#{uid} and guid=#{guid}
|
||
|
|
</update>
|
||
|
|
|
||
|
|
<!--添加订正错题表记录-->
|
||
|
|
<insert id="doSaveMyWrongBookReco" parameterType="map">
|
||
|
|
insert into wrongbookreco(wrongbookrecoid,uid,guid,origiscore,truescore,multiques,created,examid)
|
||
|
|
values (
|
||
|
|
<if test="wrongbookrecoid==0">
|
||
|
|
(SELECT NEXTVAL('seq_wrongbookrecoid')),
|
||
|
|
</if>
|
||
|
|
<if test="wrongbookrecoid!=0">
|
||
|
|
#{wrongbookrecoid}
|
||
|
|
</if>
|
||
|
|
|
||
|
|
#{uid},#{guid},#{origiscore},#{truescore},
|
||
|
|
#{multiques,typeHandler=com._3e.http.wrongbook.typehandler.JSONTypeHandlerPg},
|
||
|
|
#{created},#{examid}
|
||
|
|
)
|
||
|
|
</insert>
|
||
|
|
|
||
|
|
<select id="findExamByUidAndGuid" parameterType="map" resultType="com._3e.http.wrongbook.dto.ExamNameDto">
|
||
|
|
select e.examid,e.title,e.examtype from wrongbook w
|
||
|
|
INNER JOIN exam e on w.examid = e.examid
|
||
|
|
and w.uid=#{uid} and w.guid=#{guid}
|
||
|
|
ORDER BY w.created desc
|
||
|
|
</select>
|
||
|
|
</mapper>
|