无人机小程序
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/TdQuestionMapper.xml

243 lines
9.1 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.TdQuestionMapper">
<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.CIDS,
tq.CATEGORY,
tq.IMAGE_URL,
tq.BEST_ANSWER,
tq.SKILL_INFO,
tq.CHAPTER,
tq.SUBJECT,
tq.OPTIONS,
tq.TYPE,
tq.SHOW_ORDER,
tq.CAR_TYPE_ID,
tq.IS_ACTIVE,
tq.TITLE_WORDS,
tq.SKILL_WORDS,
tq.A_WORDS,
tq.B_WORDS,
tq.C_WORDS,
tq.D_WORDS
from td_question tq
left join td_chapter cha on tq.CHAPTER = cha.CHAPTER_ID
left join td_car_chapter tcc on tcc.CHAPTER_ID = cha.CHAPTER_ID
left join td_point_question tpq on tq.QUESTION_ID = tpq.QUESTION_ID and tq.CAR_TYPE_ID = tpq.CAR_TYPE_ID and
tpq.IS_ACTIVE = '0'
<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 queryDto.chapter !=''">
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.subject !=null and queryDto.subject !=''">
and tcc.SUBJECT = #{queryDto.subject}
</if>
<if test="queryDto.carTypeId !=null">
and tcc.CAR_TYPE_ID = #{queryDto.carTypeId}
</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>
<if test="queryDto.cid !=null and queryDto.cid !=''">
and find_in_set(#{queryDto.cid},tq.CIDS)
</if>
<if test="queryDto.category !=null and queryDto.category !=''">
and find_in_set(#{queryDto.category},tq.CATEGORY)
</if>
<if test="queryDto.point !=null and queryDto.point !=''">
and tpq.POINT = #{queryDto.point}
</if>
<if test="queryDto.isWatermark !=null and queryDto.isWatermark">
and tq.IMAGE_URL like concat('https://wos.58cdn.com.cn' , '%')
</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.CIDS,
tq.CATEGORY,
tq.IMAGE_URL,
tq.BEST_ANSWER,
tq.SKILL_INFO,
tq.CHAPTER,
tq.SUBJECT,
tq.OPTIONS,
tq.TYPE,
tq.SHOW_ORDER,
tq.CAR_TYPE_ID,
tq.IS_ACTIVE
from td_question tq
left join td_car_chapter tcc on tcc.CHAPTER_ID = tq.CHAPTER
<where>
tq.IS_ACTIVE = '0'
<if test="queryDto.subject !=null and queryDto.subject !=''">
and tcc.SUBJECT = #{queryDto.subject}
</if>
<if test="queryDto.carTypeId !=null">
and tcc.CAR_TYPE_ID = #{queryDto.carTypeId}
</if>
<if test="queryDto.type !=null">
and tq.TYPE = #{queryDto.type}
</if>
<if test="queryDto.chapter !=null and queryDto.chapter !=''">
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 td_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(IS_NEW = '1', IS_NEW, NULL)) as newQuestionNum,
count(IF(IS_ERROR = '1', IS_ERROR, NULL)) as errorQuestionNum,
count(IF(TYPE = '1', TYPE, NULL)) as judgeQuestionNum,
count(IF(TYPE = '2', TYPE, NULL)) as radioQuestionNum,
count(IF(TYPE = '3', TYPE, NULL)) as multipleChoiceQuestionNum,
count(IFNULL(IMAGE_URL, NULL)) as imageQuestionNum
from td_question
where CAR_TYPE_ID = #{queryDto.carTypeId}
and SUBJECT = #{queryDto.subject}
and IS_ACTIVE = '0'
</select>
<select id="queryQuestionId" resultType="java.lang.Long">
select
tq.QUESTION_ID
from td_question tq
left join td_car_chapter tcc on tcc.CHAPTER_ID = tq.CHAPTER
left join td_point_question tpq on tq.QUESTION_ID = tpq.QUESTION_ID and tq.CAR_TYPE_ID = tpq.CAR_TYPE_ID and
tpq.IS_ACTIVE = '0'
<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 queryDto.chapter !=''">
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.subject !=null and queryDto.subject !=''">
and tcc.SUBJECT = #{queryDto.subject}
</if>
<if test="queryDto.carTypeId !=null">
and tcc.CAR_TYPE_ID = #{queryDto.carTypeId}
</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>
<if test="queryDto.examKey !=null and queryDto.examKey != ''">
and find_in_set(#{queryDto.examKey},tq.EXAM_KEYS)
</if>
<if test="queryDto.cid !=null and queryDto.cid !=''">
and find_in_set(#{queryDto.cid},tq.CIDS)
</if>
<if test="queryDto.category !=null and queryDto.category !=''">
and find_in_set(#{queryDto.category},tq.CATEGORY)
</if>
<if test="queryDto.point !=null and queryDto.point !=''">
and tpq.POINT = #{queryDto.point}
</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 td_question tq
left join td_car_chapter tcc on tcc.CHAPTER_ID = tq.CHAPTER
<where>
tq.IS_ACTIVE = '0'
<if test="queryDto.subject !=null and queryDto.subject !=''">
and tcc.SUBJECT = #{queryDto.subject}
</if>
<if test="queryDto.carTypeId !=null">
and tcc.CAR_TYPE_ID = #{queryDto.carTypeId}
</if>
<if test="queryDto.type !=null">
and tq.TYPE = #{queryDto.type}
</if>
<if test="queryDto.chapter !=null and queryDto.chapter !=''">
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 td_question tq
where tq.CAR_TYPE_ID = #{carTypeId}
</select>
</mapper>