xiangpei
2024-05-16 9654776025968dcc4c9e41ee7b6578d72bbf9b43
src/main/resources/mapper/QuestionSubjectMapper.xml
@@ -70,7 +70,8 @@
            tq.id,
            tq.question_type as questionType,
            tq.difficult,
            ttc.content as contentJson
            ttc.content as contentJson,
            tq.correct
        FROM
             t_question_subject tqs
                 INNER JOIN t_question tq ON tqs.question_id = tq.id AND tq.deleted = 0 AND tqs.subject_id IN <foreach collection="subjectIds" open="(" separator="," close=")" item="subjectId">#{subjectId}</foreach>
@@ -79,4 +80,36 @@
             RAND() LIMIT #{questionNum}
    </select>
    <select id="questionsBySubjectIds" resultType="integer">
        SELECT
               question_id
        FROM
             t_question_subject
        <where>
            subject_id IN <foreach collection="subjectIds" open="(" separator="," close=")" item="subjectId">#{subjectId}</foreach>
        </where>
        ORDER BY
            id DESC
    </select>
    <select id="questionsBySubjectId"  resultType="integer">
        SELECT
            tqs.question_id
        FROM
            t_question_subject tqs
                INNER JOIN t_question tq ON tqs.question_id = tq.id AND tqs.subject_id = #{subjectId}
        ORDER BY
            tqs.id DESC
    </select>
    <select id="questionsBySubjectIdAndQuestionType" resultType="integer">
        SELECT
            tqs.question_id
        FROM
            t_question_subject tqs
                INNER JOIN t_question tq ON tqs.question_id = tq.id AND tqs.subject_id = #{subjectId} AND tq.question_type = #{questionType}
        ORDER BY
            tqs.id DESC
    </select>
</mapper>