123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- <?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.UserNoteQuestionRelationMapper">
- <resultMap id="IdMap" type="com.qxgmat.data.dao.entity.UserNoteQuestion">
- <!--
- WARNING - @mbg.generated
- -->
- <id column="id" jdbcType="INTEGER" property="id" />
- </resultMap>
- <sql id="Id_Column_List">
- <!--
- WARNING - @mbg.generated
- -->
- DISTINCT(unq.`id`)
- </sql>
- <select id="listExercise" resultMap="IdMap">
- <if test="keyword != null">
- <bind name="keywordLike" value="'%' + keyword + '%'" />
- </if>
- select
- <include refid="Id_Column_List" />,
- unq.`update_time` as `update_time`
- from `user_note_question` unq
- left join `question` q on q.`id` = unq.`question_id`
- and (q.`question_module` = 'base' or q.`question_module` = 'sentence')
- <if test="questionTypes != null">
- and
- <foreach collection="questionTypes" item="item" index="index" open="(" close=")" separator=" or ">
- q.`question_type` = #{item}
- </foreach>
- </if>
- left join `question_no` qn on qn.`id` = unq.`question_no_id` and qn.`module` = 'exercise' and qn.`delete_time` is null
- and (q.`question_module` = 'base')
- <if test="structIds != null">
- and
- <foreach collection="structIds" item="item" index="index" open="(" close=")" separator=" or ">
- find_in_set(#{item}, qn.`module_struct`)
- </foreach>
- </if>
- left join `sentence_question` sq on sq.`question_id` = q.`id`
- and (q.`question_module` = 'sentence')
- left join `user_question` uq on uq.`question_id` = unq.`question_id`
- left join `user_report` ur on ur.`id` = uq.`report_id`
- left join `preview_assign` pa on ur.`paper_origin` = 'preview' and pa.`id` = ur.`origin_id` and ur.`paper_origin` = 'preview'
- <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
- q.`id` > 0 and unq.`user_id` = #{userId,jdbcType=VARCHAR}
- <if test="keyword != null">
- and (q.`stem` like #{keywordLike,jdbcType=VARCHAR}
- or qn.`title` like #{keywordLike,jdbcType=VARCHAR}
- or sq.`title` like #{keywordLike,jdbcType=VARCHAR}
- or unq.`question_content` like #{keywordLike,jdbcType=VARCHAR})
- </if>
- <if test="structIds != null">
- and qn.`id` > 0
- </if>
- <if test="courseModules != null">
- and (pa.`id` > 0)
- </if>
- <if test="structIds == null">
- and (qn.`id` > 0 or sq.`id` > 0)
- </if>
- <if test="startTime != null">
- and unq.`update_time` > #{startTime,jdbcType=TIMESTAMP}
- </if>
- <if test="endTime != null">
- and unq.`update_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
- <include refid="Id_Column_List" />,
- unq.`update_time`
- from `user_note_question` unq
- left join `question` q on q.`id` = unq.`question_id`
- and (q.`question_module` = 'base' or q.`question_module` = 'textbook')
- <if test="questionTypes != null">
- and
- <foreach collection="questionTypes" item="item" index="index" open="(" close=")" separator=" or ">
- q.`question_type` = #{item}
- </foreach>
- </if>
- left join `question_no` qn on qn.`id` = unq.`question_no_id` and qn.`module` = 'examination'
- and (q.`question_module` = 'base')
- <if test="structIds != null">
- and
- <foreach collection="structIds" item="item" index="index" open="(" close=")" separator=" or ">
- find_in_set(#{item}, qn.`module_struct`)
- </foreach>
- </if>
- left join `textbook_question` tq on tq.`question_id` = q.`id`
- and (q.`question_module` = 'textbook')
- <if test="libraryId != null and libraryId > 0">
- and tq.`library_id` = #{libraryId,jdbcType=VARCHAR}
- </if>
- <if test="year != null">
- and tq.`year` = #{year,jdbcType=VARCHAR}
- </if>
- where
- q.`id` > 0 and unq.`user_id` = #{userId,jdbcType=VARCHAR}
- <if test="keyword != null">
- and (q.`stem` like #{keywordLike,jdbcType=VARCHAR}
- or qn.`title` like #{keywordLike,jdbcType=VARCHAR}
- or tq.`title` like #{keywordLike,jdbcType=VARCHAR}
- or unq.`question_content` like #{keywordLike,jdbcType=VARCHAR})
- </if>
- <if test="structIds != null">
- and qn.`id` > 0
- </if>
- <if test="structIds == null">
- and (qn.`id` > 0 or tq.`id` > 0)
- </if>
- <if test="libraryId != null">
- and (tq.`id` > 0)
- </if>
- <if test="year != null">
- and (tq.`id` > 0)
- </if>
- <if test="startTime != null">
- and unq.`update_time` > #{startTime,jdbcType=TIMESTAMP}
- </if>
- <if test="endTime != null">
- and unq.`update_time` < #{endTime,jdbcType=TIMESTAMP}
- </if>
- <if test="order != null">
- order by ${order}
- </if>
- </select>
- </mapper>
|