123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910 |
- <?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.ruoyi.ie.mapper.QuestionsMapper">
- <resultMap type="Questions" id="QuestionsResult">
- <result property="id" column="id" />
- <result property="title" column="title" />
- <result property="title1" column="title1" />
- <result property="title0" column="title0" />
- <result property="options0" column="options0" />
- <result property="answer0" column="answer0" />
- <result property="parse0" column="parse0" />
- <result property="options" column="options" />
- <result property="optionA" column="option_a" />
- <result property="optionB" column="option_b" />
- <result property="optionC" column="option_c" />
- <result property="optionD" column="option_d" />
- <result property="optionE" column="option_e" />
- <result property="optionF" column="option_f" />
- <result property="optionG" column="option_g" />
- <result property="answers" column="answers" />
- <result property="answer1" column="answer1" />
- <result property="answer2" column="answer2" />
- <result property="parse" column="parse" />
- <result property="qtpye" column="qtpye" />
- <result property="diff" column="diff" />
- <result property="md5" column="md5" />
- <result property="subjectId" column="subjectId" />
- <result property="gradeId" column="gradeId" />
- <result property="knowledges" column="knowledges" />
- <result property="area" column="area" />
- <result property="year" column="year" />
- <result property="paperTpye" column="paperTpye" />
- <result property="source" column="source" />
- <result property="fromSite" column="fromSite" />
- <result property="isSub" column="isSub" />
- <result property="isSubType" column="isSubType" />
- <result property="isNormal" column="isNormal" />
- <result property="isKonw" column="isKonw" />
- <result property="tiid" column="tiid" />
- <result property="similarity" column="Similarity" />
- <result property="isunique" column="isunique" />
- <result property="md52" column="md52" />
- <result property="score" column="score" />
- <result property="paperTitle" column="paperTitle" />
- <result property="collect" column="collect" />
- <result property="seq" column="seq" />
- <result property="paperId" column="paper_id" />
- <result property="createTime" column="create_time" />
- </resultMap>
- <sql id="selectQuestionsVo">
- select id, title, title1, option_a, option_b, option_c, option_d, option_e, option_f, option_g, answer1, answer2, parse, qtpye, diff, md5, subjectId, gradeId, knowledges, area, year, paperTpye, source, fromSite, isSub, isNormal, isKonw, tiid, Similarity, isunique, md52 from questions
- </sql>
- <select id="getQuestionsCountByChapterIds" resultType="int">
- select COUNT(*) num from chapter_question_id where 1 = 1
- and chapter_id in
- <foreach item="id" collection="chapterIds" open="(" separator="," close=")">
- #{id}
- </foreach>
- </select>
- <select id="getPaperByKnowledgeLevelId" resultMap="QuestionsResult">
- select ques.* from questions ques where 1=1
- <if test="difficulty == 0">and ques.diff in (1,2)</if>
- <if test="difficulty == 1">and ques.diff = 3 </if>
- <if test="difficulty == 2">and ques.diff in (4,5)</if>
- and ques.id in (
- select question_id from question_knowledge_basic_id
- where knowledge_basic_id in
- <foreach item="id" collection="ids" index="index" open="(" separator="," close=")">
- #{id}
- </foreach>
- )
- and ques.qtpye = #{qtype}
- order by rand() limit 0,#{number}
- </select>
- <select id="getPaperByChapterId" resultMap="QuestionsResult">
- select * from questions where 1=1
- <if test="difficulty == 0">and diff in (1,2)</if>
- <if test="difficulty == 1">and diff = 3 </if>
- <if test="difficulty == 2">and diff in (4,5)</if>
- and id in (
- select question_id from chapter_question_id where chapter_id in
- <foreach item="id" collection="ids" index="index" open="(" separator="," close=")">
- #{id}
- </foreach>
- )
- and qtpye = #{qtype}
- order by rand() limit 0,#{number}
- </select>
- <select id="selectQuestionsByMxjbPaperId" parameterType="map" resultMap="QuestionsResult">
- SELECT p.paper_id, q.knowledges, pq.knowledge_id, pq.seq, q.id, q.qtpye, q.title, q.title1, q.source, p.subjectId, q.isSub, pq.answers, q.diff,
- IF(pq.parse IS NULL, q.parse, pq.parse) parse,
- IF(pq.answer1 IS NULL, q.answer1, pq.answer1) answer1,
- IF(pq.answer2 IS NULL, q.answer2, pq.answer2) answer2,
- q.option_a, q.option_b, q.option_c, q.option_d, q.option_e, q.option_f, q.option_g, pq.score, q.isSubType
- <if test="userId != null">
- , if(qc.user_id is null, 0, 1) collect
- </if>
- FROM mxjb_paper p
- JOIN mxjb_paper_question pq ON pq.paper_id = p.paper_id
- JOIN questions q ON q.id = pq.question_id
- <if test="userId != null">
- LEFT JOIN mxjb_question_collection qc ON qc.question_id = pq.question_id AND qc.user_id = #{userId}
- </if>
- <where>
- <if test="paperId != null"> AND p.paper_id = #{paperId}</if>
- <if test="paperIds != null"> AND p.paper_id in <foreach item="id" collection="paperIds" open="(" separator="," close=")">#{id}</foreach></if>
- </where>
- ORDER BY pq.seq
- </select>
- <select id="selectQuestionsByAiPaperId" parameterType="map" resultMap="QuestionsResult">
- SELECT p.paper_id, q.knowledges, pq.knowledge_id, pq.seq, q.id, q.qtpye, q.title, q.title1, q.source, p.subjectId, q.isSub, pq.answers, q.diff,
- IF(pq.parse IS NULL, q.parse, pq.parse) parse,
- IF(pq.answer1 IS NULL, q.answer1, pq.answer1) answer1,
- IF(pq.answer2 IS NULL, q.answer2, pq.answer2) answer2,
- q.option_a, q.option_b, q.option_c, q.option_d, q.option_e, q.option_f, q.option_g, pq.score, q.isSubType
- <if test="userId != null">
- , if(qc.user_id is null, 0, 1) collect
- </if>
- FROM mxjb_ai_paper p
- JOIN mxjb_ai_paper_question pq ON pq.paper_id = p.paper_id
- JOIN questions q ON q.id = pq.question_id
- <if test="userId != null">
- LEFT JOIN mxjb_question_collection qc ON qc.question_id = pq.question_id AND qc.user_id = #{userId}
- </if>
- <where>
- <if test="paperId != null"> AND p.paper_id = #{paperId}</if>
- <if test="paperIds != null"> AND p.paper_id in <foreach item="id" collection="paperIds" open="(" separator="," close=")">#{id}</foreach></if>
- </where>
- ORDER BY pq.seq
- </select>
- <select id="selectQuestionsByHomeworkPaperId" parameterType="map" resultMap="QuestionsResult">
- SELECT p.paper_id, q.knowledges, pq.knowledge_id, pq.seq, q.id, q.qtpye, q.title, q.title1, q.source, p.subjectId, q.isSub, pq.answers, q.diff,
- IF(pq.parse IS NULL, q.parse, pq.parse) parse,
- IF(pq.answer1 IS NULL, q.answer1, pq.answer1) answer1,
- IF(pq.answer2 IS NULL, q.answer2, pq.answer2) answer2,
- q.option_a, q.option_b, q.option_c, q.option_d, q.option_e, q.option_f, q.option_g, pq.score, q.isSubType
- <if test="userId != null">
- , if(qc.user_id is null, 0, 1) collect
- </if>
- FROM mxjb_customer_paper p
- JOIN mxjb_customer_paper_question pq ON pq.paper_id = p.paper_id
- JOIN questions q ON q.id = pq.question_id
- <if test="userId != null">
- LEFT JOIN mxjb_question_collection qc ON qc.question_id = pq.question_id AND qc.user_id = #{userId}
- </if>
- <where>
- <if test="paperId != null"> AND p.paper_id = #{paperId}</if>
- <if test="paperIds != null"> AND p.paper_id in <foreach item="id" collection="paperIds" open="(" separator="," close=")">#{id}</foreach></if>
- </where>
- ORDER BY pq.seq
- </select>
- <select id="selectQuestionsByZtPaperId" parameterType="map" resultMap="QuestionsResult">
- SELECT q.* FROM `paperques` pq
- LEFT JOIN questions q ON q.id = pq.`question_id`
- <where>
- <if test="type != null"> AND pq.type = #{type}</if>
- <if test="paperId != null"> AND pq.paperId = #{paperId}</if>
- <if test="paperIds != null"> AND pq.paperId in <foreach item="paperId" collection="paperIds" open="(" separator="," close=")">#{paperId}</foreach></if>
- </where>
- ORDER BY pq.`id`
- </select>
- <select id="selectQuestionsByPaperId" parameterType="map" resultMap="QuestionsResult">
- SELECT q.knowledges, 0 seq, q.id, q.qtpye, q.title, q.title1, q.source, NULL, q.`subjectId`, q.isSub, q.parse, q.answer1, q.answer2, q.option_a, q.option_b, q.option_c, q.option_d, q.option_e, if(pq.sorces is null, q.score, pq.sorces) score, q.knowledgeId, qc.question_id > 0 collect, q.isSubType
- FROM papers p
- JOIN paperques pq ON pq.paperId = p.id
- JOIN questions q ON q.id = pq.question_id
- LEFT JOIN mxjb_question_collection qc on qc.question_id = q.id and qc.user_id = #{userId}
- WHERE p.id = #{paperId} AND (q.isSub is null or q.isSub = 0 or q.id = q.isSubType)
- ORDER BY pq.seq, IF(pq.`type` = 'paper', q.id, pq.id)
- </select>
- <select id="listQuestionsByPaperId" resultMap="QuestionsResult">
- SELECT q.*
- FROM papers p
- left JOIN paperques pq ON pq.paperId = p.id
- left JOIN questions q ON q.id = pq.question_id
- WHERE p.id = ${paperId}
- and q.id is not null
- ORDER BY q.id
- </select>
- <select id="selectSimilarQuestions" parameterType="map" resultMap="QuestionsResult">
- SELECT n.id
- FROM questions n
- LEFT JOIN mxjb_wrong_book w ON w.question_id = n.id AND w.customer_code = #{customerCode}
- <where> n.id != #{questionId} AND w.question_id IS NULL AND n.qtpye = #{qtpye} AND n.gradeId = #{gradeId} and n.subjectId = #{subjectId}
- <if test="isSub != null"> AND n.isSub = #{isSub}</if>
- <if test="known != null"> AND n.knowledges = #{known}</if>
- </where>
- LIMIT 500
- </select>
- <select id="selectTestQuestionsByMapCount" parameterType="map" resultType="int">
- SELECT COUNT(*)
- FROM `paperques` pq
- JOIN questions q ON q.id = pq.`question_id`
- LEFT JOIN `mxjb_paper_answers` a ON a.`question_id` = q.`id`
- LEFT JOIN `mxjb_paper_examinee` e ON e.`customer_code` = #{userId} AND a.`examinee_id` = e.`examinee_id`
- <where> a.`answer_id` IS NULL AND (q.isSub is null or q.id = q.isSubType)
- <if test="type != null"> AND pq.type = #{type}</if>
- <if test="paperId != null"> AND pq.paperId = #{paperId}</if>
- <if test="incTypes != null"> and qtpye in <foreach item="o" collection="incTypes" open="(" separator="," close=")">#{o}</foreach></if>
- <if test="excTypes != null"> and qtpye not in <foreach item="o" collection="excTypes" open="(" separator="," close=")">#{o}</foreach></if>
- <if test="diff != null "> and diff = #{diff}</if>
- <if test="subjectId != null "> and subjectId = #{subjectId}</if>
- <if test="gradeId != null "> and gradeId = #{gradeId}</if>
- <if test="knowledges != null and knowledges != ''"> and knowledges = #{knowledges}</if>
- <if test="area != null and area != ''"> and area = #{area}</if>
- <if test="year != null "> and year = #{year}</if>
- <if test="similarity != null "> and Similarity = #{similarity}</if>
- </where>
- </select>
- <select id="selectTestQuestionsByMap" parameterType="map" resultMap="QuestionsResult">
- select distinct q.id, title, title1, option_a, option_b, option_c, option_d, option_e, option_f, option_g, answer1, answer2,
- parse, qtpye, diff, md5, subjectId,
- gradeId, knowledges, area, year, paperTpye, source,
- fromSite, isSub, isNormal, isKonw, tiid, Similarity, isunique, md52, isSubType
- FROM `paperques` pq JOIN questions q ON q.id = pq.`question_id`
- LEFT JOIN (SELECT question_id FROM `mxjb_paper_examinee` e JOIN `mxjb_paper_answers` a ON a.`examinee_id` = e.`examinee_id` WHERE e.`customer_code` = #{userId}) T ON T.question_id = q.id
- <where>T.`question_id` IS NULL AND (q.isSub is null or q.id = q.isSubType)
- <if test="type != null"> AND pq.type = #{type}</if>
- <if test="paperId != null"> AND pq.paperId = #{paperId}</if>
- <if test="incTypes != null"> and qtpye in <foreach item="o" collection="incTypes" open="(" separator="," close=")">#{o}</foreach></if>
- <if test="excTypes != null"> and qtpye not in <foreach item="o" collection="excTypes" open="(" separator="," close=")">#{o}</foreach></if>
- <if test="diff != null "> and diff = #{diff}</if>
- <if test="subjectId != null "> and subjectId = #{subjectId}</if>
- <if test="gradeId != null "> and gradeId = #{gradeId}</if>
- <if test="knowledges != null and knowledges != ''"> and knowledges = #{knowledges}</if>
- <if test="area != null and area != ''"> and area = #{area}</if>
- <if test="year != null "> and year = #{year}</if>
- <if test="similarity != null "> and Similarity = #{similarity}</if>
- </where>
- limit #{startPos}, 100
- </select>
- <select id="selectQuestionsByMapCount" parameterType="map" resultType="int">
- select count(*)
- from questions q
- <where>
- <if test="incTypes != null"> and qtpye in <foreach item="o" collection="incTypes" open="(" separator="," close=")">#{o}</foreach></if>
- <if test="excTypes != null"> and qtpye not in <foreach item="o" collection="excTypes" open="(" separator="," close=")">#{o}</foreach></if>
- <if test="diff != null "> and diff = #{diff}</if>
- <if test="subjectId != null "> and subjectId = #{subjectId}</if>
- <if test="gradeId != null "> and gradeId = #{gradeId}</if>
- <if test="knowledges != null and knowledges != ''"> and knowledges = #{knowledges}</if>
- <if test="area != null and area != ''"> and area = #{area}</if>
- <if test="year != null "> and year = #{year}</if>
- <if test="similarity != null "> and Similarity = #{similarity}</if>
- </where>
- </select>
- <select id="selectQuestionsByMap" parameterType="map" resultMap="QuestionsResult">
- select id, title, title1, option_a, option_b, option_c, option_d, option_e, option_f, option_g, answer1, answer2,
- parse, qtpye, diff, md5, subjectId,
- gradeId, knowledges, area, year, paperTpye, source,
- fromSite, isSub, isNormal, isKonw, tiid, Similarity, isunique, md52, q.isSubType
- from questions q
- <where>
- <if test="incTypes != null"> and qtpye in <foreach item="o" collection="incTypes" open="(" separator="," close=")">#{o}</foreach></if>
- <if test="excTypes != null"> and qtpye not in <foreach item="o" collection="excTypes" open="(" separator="," close=")">#{o}</foreach></if>
- <if test="diff != null "> and diff = #{diff}</if>
- <if test="subjectId != null "> and subjectId = #{subjectId}</if>
- <if test="gradeId != null "> and gradeId = #{gradeId}</if>
- <if test="knowledges != null and knowledges != ''"> and knowledges = #{knowledges}</if>
- <if test="area != null and area != ''"> and area = #{area}</if>
- <if test="year != null "> and year = #{year}</if>
- <if test="similarity != null "> and Similarity = #{similarity}</if>
- limit #{startPos}, 100
- </where>
- </select>
- <select id="selectQuestionsForAiSubject" parameterType="map" resultMap="QuestionsResult">
- SELECT pq.`create_time`, p.paper_id, q.knowledges, pq.knowledge_id, e.`examinee_id` seq, q.id, q.qtpye, q.title, q.source, p.subjectId, q.isSub, pq.answers, q.diff,
- IF(pq.parse IS NULL, q.parse, pq.parse) parse,
- IF(pq.answer1 IS NULL, q.answer1, pq.answer1) answer1,
- IF(pq.answer2 IS NULL, q.answer2, pq.answer2) answer2,
- q.option_a, q.option_b, q.option_c, q.option_d, q.option_e, pq.score, q.isSubType
- FROM mxjb_ai_paper p
- JOIN `mxjb_ai_examinee` e ON e.`paper_id` = p.`paper_id`
- JOIN `mxjb_ai_paper_question` pq ON pq.`paper_id` = p.`paper_id`
- JOIN questions q ON q.id = pq.`question_id`
- WHERE p.`creator_id` = #{creatorId} and p.subjectId = #{subjectId}
- ORDER BY pq.`create_time` DESC
- </select>
- <select id="selectQuestionsList" parameterType="Questions" resultMap="QuestionsResult">
- select id, title, title1, option_a, option_b, option_c, option_d, option_e, option_f, option_g, answer1, answer2,
- parse, qtpye, diff, md5, subjectId, (select subjectName from subject s where s.subjectId=q.subjectId) subjectName,
- gradeId, knowledges, area, year, paperTpye, source,
- fromSite, isSub, isNormal, isKonw, tiid, Similarity, isunique, md52, q.isSubType
- from questions q
- where 1=1
- <if test="id != null "> and id = #{id}</if>
- <if test="title != null and title != ''"> and title like concat('%',#{title},'%')</if>
- <if test="optionA != null and optionA != ''"> and option_a = #{optionA}</if>
- <if test="optionB != null and optionB != ''"> and option_b = #{optionB}</if>
- <if test="optionC != null and optionC != ''"> and option_c = #{optionC}</if>
- <if test="optionD != null and optionD != ''"> and option_d = #{optionD}</if>
- <if test="optionE != null and optionE != ''"> and option_e = #{optionE}</if>
- <if test="answer1 != null and answer1 != ''"> and answer1 = #{answer1}</if>
- <if test="answer2 != null and answer2 != ''"> and answer2 = #{answer2}</if>
- <if test="parse != null and parse != ''"> and parse = #{parse}</if>
- <if test="qtpye != null and qtpye != ''"> and qtpye = #{qtpye}</if>
- <if test="diff != null "> and diff = #{diff}</if>
- <if test="md5 != null and md5 != ''"> and md5 = #{md5}</if>
- <if test="subjectId != null "> and subjectId = #{subjectId}</if>
- <if test="gradeId != null "> and gradeId = #{gradeId}</if>
- <if test="knowledges != null and knowledges != ''"> and knowledges = #{knowledges}</if>
- <if test="area != null and area != ''"> and area = #{area}</if>
- <if test="year != null "> and year = #{year}</if>
- <if test="paperTpye != null and paperTpye != ''"> and paperTpye = #{paperTpye}</if>
- <if test="source != null and source != ''"> and source = #{source}</if>
- <if test="fromSite != null and fromSite != ''"> and fromSite = #{fromSite}</if>
- <if test="isSub != null "> and isSub = #{isSub}</if>
- <if test="isSubType != null "> and isSubType = #{isSubType}</if>
- <if test="isNormal != null "> and isNormal = #{isNormal}</if>
- <if test="isKonw != null "> and isKonw = #{isKonw}</if>
- <if test="tiid != null and tiid != ''"> and tiid = #{tiid}</if>
- <if test="similarity != null "> and Similarity = #{similarity}</if>
- <if test="isunique != null "> and isunique = #{isunique}</if>
- <if test="md52 != null and md52 != ''"> and md52 = #{md52}</if>
- <if test="subjectName != null and subjectName != ''">
- and subjectId = (select subjectId from subject where subjectName=#{subjectName})
- </if>
- order by id desc
- </select>
- <!--解决分页慢 https://github.com/pagehelper/Mybatis-PageHelper/blob/master/wikis/zh/Changelog.md 更新时间2017-08-01 -->
- <select id="selectQuestionsList_COUNT" resultType="Long">
- select count(*)
- from questions q
- where 1=1 and q.id >=1 and q.id <=999999999
- <if test="id != null "> and id = #{id}</if>
- <if test="title != null and title != ''"> and title like concat('%',#{title},'%')</if>
- <if test="optionA != null and optionA != ''"> and option_a = #{optionA}</if>
- <if test="optionB != null and optionB != ''"> and option_b = #{optionB}</if>
- <if test="optionC != null and optionC != ''"> and option_c = #{optionC}</if>
- <if test="optionD != null and optionD != ''"> and option_d = #{optionD}</if>
- <if test="optionE != null and optionE != ''"> and option_e = #{optionE}</if>
- <if test="answer1 != null and answer1 != ''"> and answer1 = #{answer1}</if>
- <if test="answer2 != null and answer2 != ''"> and answer2 = #{answer2}</if>
- <if test="parse != null and parse != ''"> and parse = #{parse}</if>
- <if test="qtpye != null and qtpye != ''"> and qtpye = #{qtpye}</if>
- <if test="diff != null "> and diff = #{diff}</if>
- <if test="md5 != null and md5 != ''"> and md5 = #{md5}</if>
- <if test="subjectId != null "> and subjectId = #{subjectId}</if>
- <if test="gradeId != null "> and gradeId = #{gradeId}</if>
- <if test="knowledges != null and knowledges != ''"> and knowledges = #{knowledges}</if>
- <if test="area != null and area != ''"> and area = #{area}</if>
- <if test="year != null "> and year = #{year}</if>
- <if test="paperTpye != null and paperTpye != ''"> and paperTpye = #{paperTpye}</if>
- <if test="source != null and source != ''"> and source = #{source}</if>
- <if test="fromSite != null and fromSite != ''"> and fromSite = #{fromSite}</if>
- <if test="isSub != null "> and isSub = #{isSub}</if>
- <if test="isNormal != null "> and isNormal = #{isNormal}</if>
- <if test="isKonw != null "> and isKonw = #{isKonw}</if>
- <if test="tiid != null and tiid != ''"> and tiid = #{tiid}</if>
- <if test="similarity != null "> and Similarity = #{similarity}</if>
- <if test="isunique != null "> and isunique = #{isunique}</if>
- <if test="md52 != null and md52 != ''"> and md52 = #{md52}</if>
- <if test="subjectName != null and subjectName != ''">
- and subjectId = (select subjectId from subject where subjectName=#{subjectName})
- </if>
- </select>
- <select id="selectQuestionsFilter" parameterType="Questions" resultMap="QuestionsResult">
- select id, title, title1, title0, answer0, parse0, options0,options, option_a, option_b, option_c, option_d, option_e, option_f, option_g, answer1, answer2, parse, qtpye, diff, md5, subjectId, gradeId, knowledges, area, year, paperTpye, source, fromSite, isSub, isNormal, isKonw, tiid, Similarity, isunique, md52, isSubType from questions
- where isUpdate=0
- <if test="id != null "> and id = #{id}</if>
- <if test="params.ids != null "> and id in
- <foreach item="id" collection="params.ids" open="(" separator="," close=")">
- #{id}
- </foreach></if>
- and
- ( title like concat('%', #{title} ,'%')
- or title1 like concat('%', #{title} ,'%')
- or parse like concat('%', #{title} ,'%')
- or options like concat('%', #{title} ,'%')
- or answer1 like concat('%', #{title} ,'%')
- )
- </select>
- <select id="selectQuestionsById" parameterType="Long" resultMap="QuestionsResult">
- <include refid="selectQuestionsVo"/>
- where id = #{id}
- </select>
- <select id="selectQuestionsByPids" parameterType="Integer" resultMap="QuestionsResult">
- select id, title, title0, title1, option_a, option_b, option_c, option_d, option_e, option_f, option_g, answer1, answer2,
- parse, qtpye, diff, md5,
- gradeId, knowledges, area, year, paperTpye, source,
- fromSite, isSub, isNormal, isKonw, tiid, Similarity, isunique, md52, isSubType, score
- from questions q
- where isSubType in <foreach item="id" collection="array" open="(" separator="," close=")">#{id}</foreach>
- order by q.number * 1
- </select>
- <insert id="insertQuestions" parameterType="Questions" useGeneratedKeys="true" keyProperty="id">
- insert into questions
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="title != null">title,</if>
- <if test="title1 != null">title1,</if>
- <if test="optionA != null">option_a,</if>
- <if test="optionB != null">option_b,</if>
- <if test="optionC != null">option_c,</if>
- <if test="optionD != null">option_d,</if>
- <if test="optionE != null">option_e,</if>
- <if test="answer1 != null">answer1,</if>
- <if test="answer2 != null">answer2,</if>
- <if test="parse != null">parse,</if>
- <if test="qtpye != null">qtpye,</if>
- <if test="diff != null">diff,</if>
- <if test="md5 != null">md5,</if>
- <if test="subjectId != null">subjectId,</if>
- <if test="gradeId != null">gradeId,</if>
- <if test="knowledges != null">knowledges,</if>
- <if test="area != null">area,</if>
- <if test="year != null">year,</if>
- <if test="paperTpye != null">paperTpye,</if>
- <if test="source != null">source,</if>
- <if test="fromSite != null">fromSite,</if>
- <if test="isSub != null">isSub,</if>
- <if test="isNormal != null">isNormal,</if>
- <if test="isKonw != null">isKonw,</if>
- <if test="tiid != null">tiid,</if>
- <if test="similarity != null">Similarity,</if>
- <if test="isunique != null">isunique,</if>
- <if test="md52 != null">md52,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="title != null">#{title},</if>
- <if test="title1 != null">#{title1},</if>
- <if test="optionA != null">#{optionA},</if>
- <if test="optionB != null">#{optionB},</if>
- <if test="optionC != null">#{optionC},</if>
- <if test="optionD != null">#{optionD},</if>
- <if test="optionE != null">#{optionE},</if>
- <if test="answer1 != null">#{answer1},</if>
- <if test="answer2 != null">#{answer2},</if>
- <if test="parse != null">#{parse},</if>
- <if test="qtpye != null">#{qtpye},</if>
- <if test="diff != null">#{diff},</if>
- <if test="md5 != null">#{md5},</if>
- <if test="subjectId != null">#{subjectId},</if>
- <if test="gradeId != null">#{gradeId},</if>
- <if test="knowledges != null">#{knowledges},</if>
- <if test="area != null">#{area},</if>
- <if test="year != null">#{year},</if>
- <if test="paperTpye != null">#{paperTpye},</if>
- <if test="source != null">#{source},</if>
- <if test="fromSite != null">#{fromSite},</if>
- <if test="isSub != null">#{isSub},</if>
- <if test="isNormal != null">#{isNormal},</if>
- <if test="isKonw != null">#{isKonw},</if>
- <if test="tiid != null">#{tiid},</if>
- <if test="similarity != null">#{similarity},</if>
- <if test="isunique != null">#{isunique},</if>
- <if test="md52 != null">#{md52},</if>
- </trim>
- </insert>
- <update id="updateQuestions" parameterType="Questions">
- update questions
- <trim prefix="SET" suffixOverrides=",">
- <if test="title != null">title = #{title},</if>
- <if test="title1 != null">title1 = #{title1},</if>
- <if test="options != null">options = #{options},</if>
- <if test="optionA != null">option_a = #{optionA},</if>
- <if test="optionB != null">option_b = #{optionB},</if>
- <if test="optionC != null">option_c = #{optionC},</if>
- <if test="optionD != null">option_d = #{optionD},</if>
- <if test="optionE != null">option_e = #{optionE},</if>
- <if test="optionF != null">option_f = #{optionF},</if>
- <if test="optionG != null">option_g = #{optionG},</if>
- <if test="answer1 != null">answer1 = #{answer1},</if>
- <if test="answer2 != null">answer2 = #{answer2},</if>
- <if test="parse != null">parse = #{parse},</if>
- <if test="qtpye != null">qtpye = #{qtpye},</if>
- <if test="diff != null">diff = #{diff},</if>
- <if test="md5 != null">md5 = #{md5},</if>
- <if test="subjectId != null">subjectId = #{subjectId},</if>
- <if test="gradeId != null">gradeId = #{gradeId},</if>
- <if test="knowledges != null">knowledges = #{knowledges},</if>
- <if test="area != null">area = #{area},</if>
- <if test="year != null">year = #{year},</if>
- <if test="paperTpye != null">paperTpye = #{paperTpye},</if>
- <if test="source != null">source = #{source},</if>
- <if test="fromSite != null">fromSite = #{fromSite},</if>
- <if test="isSub != null">isSub = #{isSub},</if>
- <if test="isNormal != null">isNormal = #{isNormal},</if>
- <if test="isKonw != null">isKonw = #{isKonw},</if>
- <if test="tiid != null">tiid = #{tiid},</if>
- <if test="similarity != null">Similarity = #{similarity},</if>
- <if test="isunique != null">isunique = #{isunique},</if>
- <if test="md52 != null">md52 = #{md52},</if>
- <if test="isUpdate != null">isUpdate = #{isUpdate},</if>
- </trim>
- where id = #{id}
- </update>
- <delete id="deleteQuestionsById" parameterType="Long">
- delete from questions where id = #{id}
- </delete>
- <delete id="deleteQuestionsByIds" parameterType="String">
- delete from questions where id in
- <foreach item="id" collection="array" open="(" separator="," close=")">
- #{id}
- </foreach>
- </delete>
- <select id="getPaperQuestionList" parameterType="Questions" resultMap="QuestionsResult">
- SELECT
- a.id, a.title, a.title1, a.option_a,a.option_b,a.option_c,a.option_d,a.option_e,a.option_f,
- a.option_g, a.answer1,a.answer2, a.parse,a.qtpye,a.diff,
- a.md5,a.subjectId, a.gradeId,a.knowledges,a.area, a.year, a.paperTpye,a.source,
- a.fromSite,a.isSub,a.isNormal, a.isKonw, a.tiid,a.Similarity, a.isunique,a.md52, a.isSubType
- FROM
- questions a,
- question_knowledge_basic_id b,
- chapter c
- WHERE
- c.pharseId = 3 and
- a.id = b.question_id
- AND b.knowledge_basic_id=c.knowledgeId
- <if test="gradeId != null">
- AND c.gradeId = #{gradeId}
- </if>
- <if test="subjectId != null">
- AND c.subjectId = #{subjectId}
- </if>
- <if test="editionid != null">
- AND c.editionId = #{editionid}
- </if>
- <if test="chapterIds != null">
- AND c.id in
- <foreach collection="chapterIds" item="chapterId" open="(" separator="," close=")">
- #{chapterId}
- </foreach>
- </if>
- <if test="chapterOrder != null">
- AND c.chapterOrder = #{chapterOrder}
- </if>
- <if test="sectionOrder != null">
- AND c.sectionOrder = #{sectionOrder}
- </if>
- <if test="unitOrder != null">
- AND c.unitOrder = #{unitOrder}
- </if>
- <if test="qtpye != null and qtpye !=''">
- AND a.qtpye = #{qtpye}
- </if>
- <if test="diff != null and diff == 0">and a.diff in (1,2)</if>
- <if test="diff != null and diff == 1">and a.diff = 3 </if>
- <if test="diff != null and diff == 2">and a.diff in (4,5)</if>
- <if test="knowledgeBasicIds != null">
- and b.knowledge_basic_id in
- <foreach item="id" collection="knowledgeBasicIds" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- <if test="number != null ">
- limit ${number}
- </if>
- </select>
- <select id="getPaperQuestionListByPaperId" parameterType="Long" resultMap="QuestionsResult">
- SELECT
- a.id, a.title, a.title1, a.option_a,a.option_b,a.option_c,a.option_d,
- a.option_e,a.option_f,a.option_g, pq.answer1,pq.answer2, pq.parse,a.qtpye,a.diff,
- a.md5,a.knowledges,a.area, a.year, a.paperTpye,a.source,
- a.fromSite,a.isSub,a.isNormal, a.isKonw, a.tiid,a.Similarity, a.isunique,a.md52,pq.score,p.subjectId, p.grade_id gradeId,
- p.name paperTitle, a.isSubType
- FROM
- questions a
- left join mxjb_paper_question pq on pq.question_id=a.id
- left join mxjb_paper p on p.paper_id=pq.paper_id
- WHERE
- p.paper_id=#{paperId}
- </select>
- <select id="getPaperQuestionListByKnowledge" parameterType="Questions" resultMap="QuestionsResult">
- SELECT
- a.id, a.title, a.title1, a.option_a,a.option_b,a.option_c,a.option_d,
- a.option_e,a.option_f,a.option_g, a.answer1,a.answer2, a.parse,a.qtpye,a.diff,
- a.md5,a.subjectId, a.gradeId,a.knowledges,a.area, a.year, a.paperTpye,a.source,
- a.fromSite,a.isSub,a.isNormal, a.isKonw, a.tiid,a.Similarity, a.isunique,a.md52, a.isSubType
- FROM
- questions a
- left join question_knowledge_basic_id b on b.question_id=a.id
- left join knowledge_level c on c.knowledgeId=b.knowledge_basic_id
- WHERE
- a.gradeId = 500
- <if test="subjectId != null">
- AND c.subjectId = #{subjectId}
- </if>
- <if test="level != null and knowledgeId != null and level == 1">
- AND c.knowledge_level_1 = #{knowledgeId}
- </if>
- <if test="level != null and knowledgeId != null and level == 2">
- AND c.knowledge_level_2 = #{knowledgeId}
- </if>
- <if test="level != null and knowledgeId != null and level == 3">
- AND c.knowledge_level_3 = #{knowledgeId}
- </if>
- <if test="qtpye != null and qtpye !=''">
- AND a.qtpye = #{qtpye}
- </if>
- <if test="diff != null and diff == 0">and a.diff in (1,2)</if>
- <if test="diff != null and diff == 1">and a.diff = 3 </if>
- <if test="diff != null and diff == 2">and a.diff in (4,5)</if>
- <if test="number != null ">
- limit ${number}
- </if>
- </select>
- <select id="getQuestionListByIds" parameterType="String" resultMap="QuestionsResult">
- <include refid="selectQuestionsVo"/>
- where id in
- <foreach item="id" collection="array" open="(" separator="," close=")">
- #{id}
- </foreach>
- </select>
- <select id="selectIdsByIdGreaterThan2" parameterType="Long" resultMap="QuestionsResult">
- SELECT t1.id from questions t1 where 1=1
- and t1.id not in (SELECT question_id from test_question_pic)
- order by t1.id desc
- limit 200
- </select>
- <select id="selectIdsByIdGreaterThan" parameterType="Long" resultMap="QuestionsResult">
- select id from questions
- where id > #{id}
- order by id asc limit 1000
- </select>
- <select id="selectByChapterTreeOldids" parameterType="Questions" resultMap="QuestionsResult">
- SELECT q.* from questions q
- left join question_knowledge_basic_id qkbi on q.id = qkbi.question_id
- left join knowledge_basic kb on kb.id = qkbi.knowledge_basic_id
- left join chapter_tree ct on ct.oldid = kb.md5
- where 1=1
- <if test="parse != null">and q.parse IS NOT NULL</if>
- <if test="chapterIds != null">
- and ct.id in
- <foreach item="id" collection="chapterIds" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- <if test="knowledgeBasicIds != null">
- and kb.id in
- <foreach item="id" collection="knowledgeBasicIds" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- <if test="subjectId != null">
- AND q.subjectId = #{subjectId}
- </if>
- <if test="qtpye != null and qtpye !=''">
- AND q.qtpye = #{qtpye}
- </if>
- <if test="title != null and title != ''"> and q.title like concat('%', #{title} ,'%') </if>
- </select>
- <select id="selectByChapterTreeChineseAndEnglish" parameterType="Questions" resultMap="QuestionsResult">
- SELECT q.* from questions q
- left join chapter_question_id cqi on cqi.question_id = q.id
- left join chapter_tree ct on ct.id = cqi.chapter_id
- where 1=1
- <if test="subjectId != null">and q.subjectId = #{subjectId}</if>
- <if test="parse != null">and q.parse IS NOT NULL</if>
- <if test="chapterIds != null">
- and ct.id in
- <foreach item="id" collection="chapterIds" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- <if test="chapterid != null">
- and ct.id = #{chapterid}
- </if>
- <if test="qtpye != null and qtpye !=''">
- AND q.qtpye = #{qtpye}
- </if>
- <if test="diff != null and diff == 0">and q.diff in (1,2)</if>
- <if test="diff != null and diff == 1">and q.diff = 3 </if>
- <if test="diff != null and diff == 2">and q.diff in (4,5)</if>
- <if test="title != null and title != ''"> and q.title like concat('%', #{title} ,'%') </if>
- </select>
- <select id="selectByKnowledgeTreeOldids" parameterType="Questions" resultMap="QuestionsResult">
- SELECT q.* from questions q
- left join question_knowledge_basic_id qkbi on q.id = qkbi.question_id
- left join knowledge_basic kb on qkbi.knowledge_basic_id = kb.id
- left join knowledge_tree kt on kt.oldId = kb.md5
- where 1=1
- <if test="knowledgeIds != null">
- and kt.id in
- <foreach item="id" collection="knowledgeIds" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- <if test="qtpye != null and qtpye !=''">
- AND q.qtpye = #{qtpye}
- </if>
- <if test="title != null and title != ''"> and q.title like concat('%', #{title} ,'%') </if>
- </select>
- <select id="getPaperQuestionListBySubject" parameterType="Questions" resultMap="QuestionsResult">
- SELECT
- a.id, a.title, a.title1, a.option_a,a.option_b,a.option_c,a.option_d,
- a.option_e, a.answer1,a.answer2, a.parse,a.qtpye,a.diff,
- a.md5,a.subjectId, a.gradeId,a.knowledges,a.area, a.year, a.paperTpye,a.source,
- a.fromSite,a.isSub,a.isNormal, a.isKonw, a.tiid,a.Similarity, a.isunique,a.md52, a.isSubType
- FROM
- questions a
- WHERE
- 1=1
- <if test="subjectId != null">
- AND a.subjectId = #{subjectId}
- </if>
- <if test="qtpye != null and qtpye !=''">
- AND a.qtpye = #{qtpye}
- </if>
- <if test="diff != null and diff == 0">and a.diff in (1,2)</if>
- <if test="diff != null and diff == 1">and a.diff = 3 </if>
- <if test="diff != null and diff == 2">and a.diff in (4,5)</if>
- <if test="number != null ">
- limit ${number}
- </if>
- </select>
- <select id="getQuestionsByChapterForParactice" parameterType="Questions" resultMap="QuestionsResult">
- SELECT q.* from questions q
- left join question_knowledge_basic_id qkbi on q.id = qkbi.question_id
- left join knowledge_basic kb on kb.id = qkbi.knowledge_basic_id
- left join chapter_tree ct on ct.oldid = kb.md5
- where 1=1
- <if test="chapterIds != null">
- and ct.id in
- <foreach item="id" collection="chapterIds" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- and q.qtpye in ('单选题' ,'单项选择题' ,'选择搭配题' ,'选择题')
- and q.option_a !='' and length(q.answer1)=1
- order by (q.parse IS NULL OR q.parse = ''), rand()
- </select>
- <select id="getQuestionsByChapterForParacticeChineseAndEnglish" parameterType="Questions" resultMap="QuestionsResult">
- select q.*
- from chapter_question_id cqi
- left join chapter_tree ct on cqi.chapter_id = ct.id
- left join questions q on cqi.question_id = q.id
- where 1=1
- <if test="chapterIds != null">
- and ct.id in
- <foreach item="id" collection="chapterIds" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- and q.qtpye in ('单选题' ,'单项选择题' ,'选择搭配题' ,'选择题')
- and q.option_a !='' and length(q.answer1)=1
- order by (q.parse IS NULL OR q.parse = ''), rand()
- </select>
- <select id="getQuestionsByKnowledgeForParactice" parameterType="Questions" resultMap="QuestionsResult">
- SELECT q.* from questions q
- left join question_knowledge_basic_id qkbi on q.id = qkbi.question_id
- left join knowledge_basic kb on qkbi.knowledge_basic_id = kb.id
- left join knowledge_tree kt on kt.oldId = kb.md5
- where 1=1
- <if test="knowledgeIds != null">
- and kt.id in
- <foreach item="id" collection="knowledgeIds" open="(" separator="," close=")">
- #{id}
- </foreach>
- </if>
- <if test="knowledgeId != null">
- and kt.id = #{knowledgeId}
- </if>
- and q.qtpye in ('单选题' ,'单项选择题' ,'选择搭配题' ,'选择题')
- and q.option_a !='' and length(q.answer1)=1
- order by (q.parse IS NULL OR q.parse = ''), rand()
- </select>
- <select id="selectCollectedList" parameterType="Questions" resultMap="QuestionsResult">
- select q.* from mxjb_question_collection c
- left join questions q on c.question_id = q.id
- left join subject s on q.subjectId = s.subjectId
- where c.user_id = #{userId}
- and q.subjectId = #{subjectId}
- </select>
- <select id="selectWrongQuestions" parameterType="Questions" resultMap="QuestionsResult">
- select q.* from mxjb_wrong_book b
- left join questions q on q.id = b.question_id
- where b.customer_code = #{customerCode}
- and q.subjectId = #{subjectId}
- and q.qtpye = #{qtpye}
- </select>
- <select id="selectCollectInfo" parameterType="java.util.HashMap" resultMap="QuestionsResult">
- SELECT q.id from mxjb_question_collection c
- left join questions q on c.question_id = q.id
- where user_id = #{userId}
- and c.question_id in
- <foreach item="id" collection="ids" open="(" separator="," close=")">
- #{id}
- </foreach>
- </select>
- <select id="selectByIds" parameterType="java.util.HashMap" resultMap="QuestionsResult">
- SELECT * from questions
- where id in
- <foreach item="id" collection="ids" open="(" separator="," close=")">
- #{id}
- </foreach>
- </select>
- <select id="selectByKnowledgeIds" parameterType="Questions" resultMap="QuestionsResult">
- select * from questions
- where id in (
- select question_id
- from question_knowledge_basic_id
- where knowledge_basic_id in
- <foreach item="id" collection="knowledgeIds" open="(" separator="," close=")">
- #{id}
- </foreach>
- )
- <if test="qtpye != null and qtpye !=''">
- AND qtpye = #{qtpye}
- </if>
- <if test="number != null ">
- limit ${number}
- </if>
- </select>
- <select id="selectTotalBySubjectId" parameterType="integer" resultType="long">
- SELECT COUNT(*)
- FROM `questions` q
- WHERE q.`subjectId` = #{subjectId} AND q.`qtpye` IN ('单选题', '判断题', '单项选择题','选择题')
- </select>
- <select id="selectTotalOfCompleted" resultType="long">
- SELECT count(distinct q2.id)
- FROM `questions` q2
- JOIN `mxjb_paper_answers` a2 ON a2.`question_id` = q2.`id`
- JOIN `mxjb_paper_examinee` e2 ON e2.`customer_code` = #{userId} AND a2.`examinee_id` = e2.`examinee_id`
- JOIN `mxjb_paper_test` p2 ON e2.`paper_id` = p2.`paper_id` AND p2.`name` = '必刷题'
- WHERE q2.`subjectId` = #{subjectId} AND q2.`qtpye` IN ('单选题', '判断题', '单项选择题','选择题')
- </select>
- <select id="selectTotalOfLatestRight" resultType="long">
- SELECT COUNT(*)
- FROM `questions` q2
- JOIN `mxjb_paper_answers` a2 ON a2.`question_id` = q2.`id` AND a2.`state` = 1
- JOIN `mxjb_paper_examinee` e2 ON e2.`customer_code` = #{userId} AND a2.`examinee_id` = e2.`examinee_id`
- JOIN `mxjb_paper_test` p2 ON e2.`paper_id` = p2.`paper_id` AND p2.`name` = '必刷题'
- JOIN (SELECT q.`id`, MAX(e.`begin_time`) begin_time
- FROM `questions` q
- JOIN `mxjb_paper_answers` a ON a.`question_id` = q.`id`
- JOIN `mxjb_paper_examinee` e ON e.`customer_code` = #{userId} AND a.`examinee_id` = e.`examinee_id`
- JOIN `mxjb_paper_test` p ON e.`paper_id` = p.`paper_id` AND p.`name` = '必刷题'
- WHERE q.`subjectId` = #{subjectId} AND q.`qtpye` IN ('单选题', '判断题', '单项选择题','选择题')
- GROUP BY q.`id`
- ) T ON q2.id = T.id AND T.begin_time = e2.begin_time
- WHERE q2.`subjectId` = #{subjectId} AND q2.`qtpye` IN ('单选题', '判断题', '单项选择题','选择题')
- </select>
- <select id="selectLatestRates" resultMap="QuestionsResult">
- SELECT e.`paper_id` id, e.`begin_time` create_time, round(e.`score_rate` * 100) score
- FROM `mxjb_paper_test` p
- JOIN `mxjb_paper_examinee` e ON e.`paper_id` = p.`paper_id` AND e.`customer_code` = #{userId} AND e.`state` = 6
- WHERE p.name = '必刷题' AND p.subjectId = #{subjectId}
- ORDER BY e.`begin_time` DESC LIMIT 10
- </select>
- </mapper>
|