无人机小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
wrj-applet-api/target/classes/mapper/WrjQuestionMapper.xml

200 lines
6.9 KiB

<?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.wrj.driver.server.mapper.WrjQuestionMapper">
<select id="queryQuestion" resultType="com.wrj.driver.server.vo.QuestionVo">
select
tq.question_id,
tq.question,
tq.choose_a,
tq.choose_b,
tq.choose_c,
tq.choose_d,
tq.choose_e,
tq.choose_f,
tq.choose_g,
tq.true_answer,
tq.image_url,
tq.best_answer,
tq.skill_info,
tq.error_info,
tq.chapter,
tq.options,
tq.type,
tq.show_order,
tq.origin_id,
tq.is_active,
tq.title_words,
tq.skill_words,
tq.a_words,
tq.b_words,
tq.c_words,
tq.d_words
from wrj_question tq
left join wrj_chapter cha on tq.chapter = cha.chapter_id
left join wrj_type_chapter tcc on tcc.chapter_id = cha.chapter_id
<where>
tq.is_active = '0'
<if test="queryDto.questionId !=null">
and tq.question_id = #{queryDto.questionId}
</if>
<if test="queryDto.questionIdList !=null and queryDto.questionIdList.size() > 0">
and tq.question_id in
<foreach collection="queryDto.questionIdList" open="(" item="item" separator="," close=")">
#{item}
</foreach>
</if>
<if test="queryDto.chapter !=null">
and tq.chapter = #{queryDto.chapter}
</if>
<if test="queryDto.question !=null and queryDto.question !=''">
and tq.question like concat('%' , #{queryDto.question} , '%')
</if>
<if test="queryDto.driverTypeId !=null">
and tcc.type_id = #{queryDto.driverTypeId}
</if>
<if test="queryDto.type !=null and queryDto.type != ''">
and tq.type = #{queryDto.type}
</if>
<if test="queryDto.isImage !=null">
and tq.image_url is not null
</if>
</where>
group by tq.question_id
order by tq.show_order asc, question_id asc
</select>
<select id="queryQuestionByRandom" resultType="com.wrj.driver.server.vo.QuestionVo">
select
tq.question_id,
tq.question,
tq.choose_a,
tq.choose_b,
tq.choose_c,
tq.choose_d,
tq.choose_e,
tq.choose_f,
tq.choose_g,
tq.true_answer,
tq.image_url,
tq.best_answer,
tq.skill_info,
tq.error_info,
tq.chapter,
tq.options,
tq.type,
tq.show_order,
tq.origin_id,
tq.is_active,
tq.title_words,
tq.skill_words,
tq.a_words,
tq.b_words,
tq.c_words,
tq.d_words
from wrj_question tq
left join wrj_type_chapter tcc on tcc.chapter_id = tq.chapter
<where>
tq.is_active = '0'
<if test="queryDto.driverTypeId !=null">
and tcc.type_id = #{queryDto.driverTypeId}
</if>
<if test="queryDto.type !=null and queryDto.type != ''">
and tq.TYPE = #{queryDto.type}
</if>
<if test="queryDto.chapter !=null">
and tq.chapter = #{queryDto.chapter}
</if>
</where>
order by rand() limit ${queryDto.num};
</select>
<update id="updateQuestion" parameterType="com.wrj.driver.server.vo.QuestionVo">
update wrj_question
<trim prefix="SET" suffixOverrides=",">
<if test="questionVo.skillInfo !=null and questionVo.skillInfo !=''">
skill_info = #{questionVo.skillInfo},
</if>
<if test="questionVo.imageUrl !=null">
image_url = #{questionVo.imageUrl},
</if>
</trim>
where question_id = #{questionVo.questionId}
</update>
<select id="querySpecialNum" resultType="java.util.Map">
select
count(IF(TYPE = '1', tq.type, NULL)) as judgeQuestionNum,
count(IF(TYPE = '2', tq.type, NULL)) as radioQuestionNum,
count(IF(TYPE = '3', tq.type, NULL)) as multipleChoiceQuestionNum,
count(IFNULL(tq.image_url, NULL)) as imageQuestionNum
from wrj_question tq
left join wrj_type_chapter tcc on tcc.chapter_id = tq.chapter
where tcc.type_id = #{queryDto.driverTypeId}
and tq.is_active = '0'
</select>
<select id="queryQuestionId" resultType="java.lang.Long">
select
tq.question_id
from wrj_question tq
left join wrj_type_chapter tcc on tcc.chapter_id = tq.chapter
<where>
tq.is_active = '0'
<if test="queryDto.questionId !=null">
and tq.question_id = #{queryDto.questionId}
</if>
<if test="queryDto.questionIdList !=null and queryDto.questionIdList.size() > 0">
and tq.question_id in
<foreach collection="queryDto.questionIdList" open="(" item="item" separator="," close=")">
#{item}
</foreach>
</if>
<if test="queryDto.chapter !=null">
and tq.chapter = #{queryDto.chapter}
</if>
<if test="queryDto.question !=null and queryDto.question !=''">
and tq.question like concat('%' , #{queryDto.question} , '%')
</if>
<if test="queryDto.driverTypeId !=null">
and tcc.type_id = #{queryDto.driverTypeId}
</if>
<if test="queryDto.type !=null and queryDto.type != ''">
and tq.type = #{queryDto.type}
</if>
<if test="queryDto.isImage !=null">
and tq.image_url is not null
</if>
</where>
group by tq.question_id
order by tq.show_order asc
</select>
<select id="queryQuestionIdByRandom" resultType="java.lang.Long">
select
tq.question_id
from wrj_question tq
left join wrj_type_chapter tcc on tcc.chapter_id = tq.chapter
<where>
tq.is_active = '0'
<if test="queryDto.driverTypeId !=null">
and tcc.type_id = #{queryDto.driverTypeId}
</if>
<if test="queryDto.type !=null and queryDto.type != ''">
and tq.type = #{queryDto.type}
</if>
<if test="queryDto.chapter !=null">
and tq.chapter = #{queryDto.chapter}
</if>
</where>
order by rand() limit ${queryDto.num};
</select>
<select id="queryMaxSort" resultType="java.lang.Integer">
select
MAX(tq.show_order)
from wrj_question tq
</select>
</mapper>