123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257 |
- <?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.QuestionNoRelationMapper">
- <resultMap id="IdMap" type="com.qxgmat.data.dao.entity.QuestionNo">
- <!--
- WARNING - @mbg.generated
- -->
- <id column="id" jdbcType="INTEGER" property="id" />
- </resultMap>
- <resultMap id="DifficultMap" type="com.qxgmat.data.relation.entity.QuestionDifficultRelation">
- <!--
- WARNING - @mbg.generated
- -->
- <id column="id" jdbcType="INTEGER" property="id" />
- <id column="difficult" jdbcType="VARCHAR" property="difficult" />
- <id column="question_type" jdbcType="VARCHAR" property="questionType" />
- </resultMap>
- <sql id="Id_Column_List">
- qn.`id`
- </sql>
- <sql id="Difficult_Column_List">
- qn.`id`, q.`difficult`, q.`question_type`
- </sql>
- <!--累加做题记录-->
- <update id="accumulation">
- UPDATE `question_no`
- <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},
- </trim>
- WHERE `id` = #{id, jdbcType=VARCHAR}
- </update>
- <!--累加收藏记录-->
- <update id="accumulationCollect">
- UPDATE `question_no`
- <trim prefix="set" suffixOverrides=",">
- `collect_number`=`collect_number`+#{collect, jdbcType=INTEGER},
- </trim>
- WHERE `id` = #{id, jdbcType=VARCHAR}
- </update>
- <!--
- 按题干搜索相似度80%以上的
- -->
- <select id="searchStem" resultMap="IdMap">
- select
- <include refid="Id_Column_List" />
- from `question_no` qn
- left join `question` q on q.`id` = qn.`question_id`
- and MATCH (q.`description`) AGAINST (#{stem, jdbcType=VARCHAR} IN NATURAL LANGUAGE MODE) > 0.8
- where
- q.`id` > 0 and qn.`delete_time` is null
- </select>
- <!--
- 按题干搜索相似度或者题号完全匹配,过滤千行cat
- -->
- <select id="searchStemFulltext" resultMap="IdMap">
- select
- <include refid="Id_Column_List" />,
- <if test="keyword">
- if(qn.`title` = #{keyword, jdbcType=VARCHAR}, 1, MATCH (q.`description`) AGAINST (#{keyword, jdbcType=VARCHAR} IN NATURAL LANGUAGE MODE)) as `relation_score`,
- </if>
- qn.`collect_number` as `collect_number`,
- qn.`total_correct` / qn.`total_number` as `correct`,
- qn.`total_time` / qn.`total_number` as `time`
- from `question_no` qn
- left join `question` q on q.`id` = qn.`question_id`
- and (q.`question_module` = 'base')
- <if test="difficult != null">
- and q.`difficult` = #{difficult,jdbcType=VARCHAR}
- </if>
- <if test="place != null">
- and q.`place` = #{place,jdbcType=VARCHAR}
- </if>
- <if test="questionTypes != null">
- and
- <foreach collection="questionTypes" item="item" index="index" open="(" close=")" separator=" or ">
- q.`question_type` = #{item}
- </foreach>
- </if>
- where
- q.id > 0 and qn.question_id > 0 and qn.`delete_time` is null
- <if test="keyword">
- and (qn.`title` = #{keyword, jdbcType=VARCHAR} or MATCH (q.`description`) AGAINST (#{keyword, jdbcType=VARCHAR} IN NATURAL LANGUAGE MODE))
- </if>
- <if test="qxCatId != null">
- and (qn.module='examination' and find_in_set(#{qxCatId}, qn.`module_struct`) = 0)
- </if>
- <if test="module != null">
- and qn.`module` = #{module,jdbcType=VARCHAR}
- </if>
- <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>
- ORDER BY #{order} #{direction}, qn.`no` DESC
- </select>
- <!--
- 按题目id查询,过滤千行cat
- -->
- <select id="searchNoFulltext" resultMap="IdMap">
- <if test="keyword != null">
- <bind name="keywordLike" value="'%' + keyword + '%'" />
- </if>
- select
- <include refid="Id_Column_List" />,
- MATCH (qn.`title`) AGAINST (#{keyword, jdbcType=VARCHAR} IN NATURAL LANGUAGE MODE) as `relation_score`
- from `question_no` qn
- where qn.question_id > 0 and qn.`delete_time` is null and
- (MATCH (qn.`title`) AGAINST (#{keyword, jdbcType=VARCHAR} IN NATURAL LANGUAGE MODE) or qn.`title` like #{keywordLike,jdbcType=VARCHAR})
- <if test="module != null">
- and qn.`module` = #{module,jdbcType=VARCHAR}
- </if>
- <if test="qxCatId != null">
- and (qn.module='examination' and find_in_set(#{qxCatId}, qn.`module_struct`) = 0)
- </if>
- ORDER BY `relation_score` DESC
- </select>
- <!--
- 模考随机出题
- -->
- <select id="randomExamination" resultMap="IdMap">
- select
- <include refid="Id_Column_List" />
- from `question_no` qn
- left join `question` q on q.`id` = qn.`question_id`
- where
- q.id > 0 and qn.question_id > 0 and qn.`delete_time` is null
- and qn.`module` = 'examination'
- <if test="structId != null">
- and find_in_set(#{structId,jdbcType=VARCHAR}, qn.`module_struct`)
- </if>
- <if test="targetTypes != null">
- and q.`question_type` IN
- <foreach collection="targetTypes" item="item" index="index" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- <if test="filterIds != null">
- and qn.`id` NOT IN
- <foreach collection="filterIds" item="item" index="index" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- order by RAND()
- limit #{size,jdbcType=VARCHAR}
- </select>
- <!--
- 模考题目列表
- -->
- <select id="allExaminationByType" resultMap="DifficultMap">
- select
- <include refid="Difficult_Column_List" />
- from `question_no` qn
- left join `question` q on q.`id` = qn.`question_id`
- where
- q.id > 0 and qn.question_id > 0 and qn.`delete_time` is null
- and qn.`module` = 'examination'
- <if test="structId != null">
- and find_in_set(#{structId,jdbcType=VARCHAR}, qn.`module_struct`)
- </if>
- <if test="targetTypes != null">
- and q.`question_type` IN
- <foreach collection="targetTypes" item="item" index="index" open="(" separator="," close=")">
- #{item}
- </foreach>
- </if>
- </select>
- <!--
- 后台练习题目搜索
- -->
- <select id="listExerciseAdmin" resultMap="IdMap">
- select
- <include refid="Id_Column_List" />
- <if test="paperId != null">
- , find_in_set(qn.`id`, trim(TRAILING ']' from trim(LEADING '[' from ep.`question_no_ids`))) as `no`
- </if>
- from `question_no` qn
- left join `question` q on q.`id` = qn.`question_id`
- <if test="paperId != null">
- left join `exercise_paper` ep on find_in_set(qn.`id`, trim(TRAILING ']' from trim(LEADING '[' from ep.`question_no_ids`)))
- and ep.`id` = #{paperId,jdbcType=VARCHAR}
- </if>
- where q.`id` > 0 and qn.`question_id` > 0 and qn.`delete_time` is null
- and qn.`module` = "exercise"
- <if test="paperId != null">
- and ep.`id` > 0
- </if>
- <if test="structId != null">
- and find_in_set(#{structId,jdbcType=VARCHAR}, qn.`module_struct`)
- </if>
- <if test="questionNoId != null">
- and qn.`id` =#{questionNoId,jdbcType=VARCHAR}
- </if>
- <if test="questionType != null">
- and q.`question_type` =#{questionType,jdbcType=VARCHAR}
- </if>
- <if test="place != null">
- and q.`place` =#{place,jdbcType=VARCHAR}
- </if>
- <if test="difficult != null">
- and q.`difficult` =#{difficult,jdbcType=VARCHAR}
- </if>
- <if test="startTime != null">
- and hp.`update_time` > #{startTime,jdbcType=TIMESTAMP}
- </if>
- <if test="endTime != null">
- and hp.`update_time` < #{endTime,jdbcType=TIMESTAMP}
- </if>
- order by ${order} ${direction}
- </select>
- <!--
- 后台模考题目搜索
- -->
- <select id="listExaminationAdmin" resultMap="IdMap">
- select
- <include refid="Id_Column_List" />
- from `question_no` qn
- left join `question` q on q.`id` = qn.`question_id`
- <if test="paperId != null">
- left join `examination_paper` ep on find_in_set(qn.`id`, trim(TRAILING ']' from trim(LEADING '[' from ep.`question_no_ids`)))
- and ep.`id` = #{paperId,jdbcType=VARCHAR}
- </if>
- where q.`id` > 0 and qn.`question_id` > 0 and qn.`delete_time` is null
- and qn.`module` = "examination"
- <if test="paperId != null">
- and ep.`id` > 0
- </if>
- <if test="structId != null">
- and find_in_set(#{structId,jdbcType=VARCHAR}, qn.`module_struct`)
- </if>
- <if test="questionNoId != null">
- and qn.`id` =#{questionNoId,jdbcType=VARCHAR}
- </if>
- <if test="questionType != null">
- and q.`question_type` =#{questionType,jdbcType=VARCHAR}
- </if>
- <if test="place != null">
- and q.`place` =#{place,jdbcType=VARCHAR}
- </if>
- <if test="difficult != null">
- and q.`difficult` =#{difficult,jdbcType=VARCHAR}
- </if>
- order by ${order} ${direction}
- </select>
- </mapper>
|