123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- <?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.qxgmat.data.relation.UserPaperRelationMapper">
- <resultMap id="IdMap" type="com.qxgmat.data.dao.entity.UserPaper">
- <!--
- WARNING - @mbg.generated
- -->
- <id column="id" jdbcType="INTEGER" property="id" />
- </resultMap>
- <sql id="Id_Column_List">
- <!--
- WARNING - @mbg.generated
- -->
- up.`id`
- </sql>
- <!--累加做题记录-->
- <update id="accumulation">
- UPDATE `user_paper`
- <trim prefix="set" suffixOverrides=",">
- `total_number`=`total_number`+#{number, jdbcType=INTEGER},
- `total_time`=`total_time`+#{time, jdbcType=INTEGER},
- `total_correct`=`total_correct`+#{correct, jdbcType=INTEGER},
- `times` = `times`+#{times, jdbcType=INTEGER},
- `finish_times` = `finish_times`+#{finish, jdbcType=INTEGER},
- `latest_time` = #{latestTime, jdbcType=DATE},
- `latest_report_id` = #{latestReportId, jdbcType=INTEGER},
- </trim>
- WHERE `id` = #{id, jdbcType=VARCHAR}
- </update>
- <select id="list" resultMap="IdMap">
- <if test="keyword != null">
- <bind name="keywordLike" value="'%' + keyword + '%'" />
- </if>
- select
- DISTINCT(up.`id`),
- up.`title` as `title`,
- up.`latest_time` as `latest_time`,
- ur.`user_correct` / up.`question_number` as `correct`,
- ur.`user_time` / up.`question_number` as `time`,
- ur.`user_number` / up.`question_number` as `progress`
- from `user_paper` up
- left join `user_report` ur on ur.`id`= up.`latest_report_id`
- where up.`user_id` = #{userId,jdbcType=VARCHAR} and ur.`id` is not null
- <if test="paperOrigin != null">
- and up.`paper_origin` = #{paperOrigin,jdbcType=VARCHAR}
- </if>
- <if test="startTime != null">
- and uq.`create_time` > #{startTime,jdbcType=TIMESTAMP}
- </if>
- <if test="endTime != null">
- and uq.`create_time` < #{endTime,jdbcType=TIMESTAMP}
- </if>
- <if test="order != null">
- order by ${order}
- </if>
- </select>
- <select id="listExercise" resultMap="IdMap">
- <if test="keyword != null">
- <bind name="keywordLike" value="'%' + keyword + '%'" />
- </if>
- select
- DISTINCT(up.`id`),
- up.`title` as `title`,
- up.`latest_time` as `latest_time`,
- ur.`user_correct` / up.`question_number` as `correct`,
- ur.`user_time` / up.`question_number` as `time`,
- ur.`user_number` / up.`question_number` as `progress`
- from `user_paper` up
- left join `user_report` ur on ur.`id`= up.`latest_report_id`
- left join `exercise_paper` ep on up.`paper_origin` = 'exercise' and ep.`id` = up.`origin_id`
- <if test="questionTypes != null">
- and
- <foreach collection="questionTypes" item="item" index="index" open="(" close=")" separator=" or ">
- ep.`question_type` = #{item}
- </foreach>
- </if>
- <if test="structIds != null">
- and (ep.`struct_four` in
- <foreach collection="structIds" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- or ep.`struct_three` in
- <foreach collection="structIds" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- )
- </if>
- left join `sentence_paper` sp on up.`paper_origin` = 'sentence' and sp.`id` = up.`origin_id`
- <if test="questionTypes != null">
- and
- <foreach collection="questionTypes" item="item" index="index" open="(" close=")" separator=" or ">
- 'sentence' = #{item}
- </foreach>
- </if>
- left join `preview_assign` pa on up.`paper_origin` = 'preview' and pa.`id` = up.`origin_id`
- <if test="courseModules != null">
- and pa.`course_module` in
- <foreach collection="courseModules" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- left join `preview_paper` pp on pa.`paper_id` = pp.`id`
- <if test="questionTypes != null">
- and
- <foreach collection="questionTypes" item="item" index="index" open="(" close=")" separator=" or ">
- pp.`question_type` = #{item}
- </foreach>
- </if>
- where up.`user_id` = #{userId,jdbcType=VARCHAR} and ur.`id` is not null
- <if test="keyword != null">
- and (ep.`title` like #{keywordLike,jdbcType=VARCHAR}
- or pa.`title like #{keywordLike,jdbcType=VARCHAR}`
- or pp.`title like #{keywordLike,jdbcType=VARCHAR}`)
- </if>
- <if test="structIds != null">
- and ep.`id` > 0
- </if>
- <if test="structIds == null">
- and (ep.`id` > 0 or sp.`id` > 0 or pp.`id` > 0)
- </if>
- <if test="courseModules != null">
- and (pa.`id` > 0)
- </if>
- <if test="startTime != null">
- and uq.`create_time` > #{startTime,jdbcType=TIMESTAMP}
- </if>
- <if test="endTime != null">
- and uq.`create_time` < #{endTime,jdbcType=TIMESTAMP}
- </if>
- <if test="order != null">
- order by ${order}
- </if>
- </select>
- <select id="listExamination" resultMap="IdMap">
- <if test="keyword != null">
- <bind name="keywordLike" value="'%' + keyword + '%'" />
- </if>
- select
- DISTINCT(up.`id`),
- up.`title` as `title`,
- up.`latest_time` as `latest_time`,
- ur.`user_correct` / up.`question_number` as `correct`,
- ur.`user_time` / up.`question_number` as `time`,
- ur.`user_number` / up.`question_number` as `progress`
- from `user_paper` up
- left join `user_report` ur on ur.`id`= up.`latest_report_id`
- left join `examination_paper` ep on up.`paper_origin` = 'examination' and ep.`id` = up.`origin_id`
- <if test="structIds != null and structIds.length>0">
- and (ep.`struct_two` in
- <foreach collection="structIds" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- or ep.`struct_three` in
- <foreach collection="structIds" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- )
- </if>
- left join `textbook_paper` tp on up.`paper_origin` = 'textbook' and tp.`id` = up.`origin_id`
- <if test="libraryId != null and libraryId > 0">
- and tp.`library_id` = #{libraryId,jdbcType=VARCHAR}
- </if>
- <if test="year != null">
- and tp.`year` = #{year,jdbcType=VARCHAR}
- </if>
- where up.`user_id` = #{userId,jdbcType=VARCHAR} and ur.`id` is not null
- <if test="keyword != null">
- and (ep.`title` like #{keywordLike,jdbcType=VARCHAR}
- or tp.`title like #{keywordLike,jdbcType=VARCHAR}`)
- </if>
- <if test="structIds != null">
- and ep.`id` > 0
- </if>
- <if test="structIds == null">
- and (ep.`id` > 0 or tp.`id` > 0)
- </if>
- <if test="libraryId == null">
- and (ep.`id` > 0)
- </if>
- <if test="libraryId != null">
- and (tp.`id` > 0)
- </if>
- <if test="year != null">
- and (tp.`id` > 0)
- </if>
- <if test="startTime != null">
- and uq.`create_time` > #{startTime,jdbcType=TIMESTAMP}
- </if>
- <if test="endTime != null">
- and uq.`create_time` < #{endTime,jdbcType=TIMESTAMP}
- </if>
- <if test="order != null">
- order by ${order}
- </if>
- </select>
- </mapper>
|