driver-server/src/main/resources/mapper/TdQuestionMapper.xml

281 lines
10 KiB
XML
Raw Normal View History

2023-08-11 11:51:09 +08:00
<?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.jwl.driver.server.mapper.TdQuestionMapper">
2023-08-19 23:36:50 +08:00
<select id="queryQuestion" resultType="com.jwl.driver.server.vo.QuestionVo">
2023-08-14 01:31:26 +08:00
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.SOHU_IMG,
tq.BEST_ANSWER,
tq.CHAPTER,
tq.SUBJECT,
tq.OPTIONS,
tq.TYPE,
tq.SHOW_ORDER,
tq.CAR_TYPE_ID,
2023-08-19 00:39:11 +08:00
tq.IS_ACTIVE,
tq.IS_VIP,
tq.IS_ERROR,
tq.IS_NEW,
2023-08-19 13:49:56 +08:00
tq.EXAM_KEYS,
tq.IS_EXAM1,
tq.IS_EXAM2,
tq.IS_VIP2
2023-08-14 01:31:26 +08:00
from td_question tq
2023-08-15 01:37:50 +08:00
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'
2023-08-14 01:31:26 +08:00
<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>
2023-08-19 00:39:11 +08:00
<if test="queryDto.question !=null and queryDto.question !=''">
and tq.QUESTION like concat('%' , #{queryDto.question} , '%')
</if>
2023-08-14 01:31:26 +08:00
<if test="queryDto.subject !=null and queryDto.subject !=''">
and tq.SUBJECT = #{queryDto.subject}
</if>
<if test="queryDto.carTypeId !=null">
and tq.CAR_TYPE_ID = #{queryDto.carTypeId}
</if>
2023-08-15 01:37:50 +08:00
<if test="queryDto.type !=null and queryDto.type != ''">
2023-08-14 01:31:26 +08:00
and tq.TYPE = #{queryDto.type}
</if>
2023-08-23 23:58:25 +08:00
<if test="queryDto.isError !=null">
and tq.IS_ERROR = #{queryDto.isError}
</if>
<if test="queryDto.isNew !=null">
and tq.IS_NEW = #{queryDto.isNew}
</if>
2023-08-27 16:38:22 +08:00
<if test="queryDto.isImage !=null">
and tq.IMAGE_URL is not null
</if>
2023-08-23 23:58:25 +08:00
<if test="queryDto.examKey !=null and queryDto.examKey != ''">
and find_in_set(#{queryDto.examKey},tq.EXAM_KEYS)
</if>
<if test="queryDto.isVip !=null">
and tq.IS_VIP = #{queryDto.isVip}
</if>
<if test="queryDto.isVip2 !=null">
and tq.IS_VIP2 = #{queryDto.isVip2}
</if>
<if test="queryDto.isExam1 !=null">
and tq.IS_EXAM1 = #{queryDto.isExam1}
</if>
<if test="queryDto.isExam2 !=null">
and tq.IS_EXAM2 = #{queryDto.isExam2}
</if>
2023-08-14 01:31:26 +08:00
<if test="queryDto.cid !=null and queryDto.cid !=''">
and find_in_set(#{queryDto.cid},tq.CIDS)
</if>
2023-08-16 23:46:01 +08:00
<if test="queryDto.category !=null and queryDto.category !=''">
and find_in_set(#{queryDto.category},tq.CATEGORY)
</if>
2023-08-14 01:31:26 +08:00
<if test="queryDto.point !=null and queryDto.point !=''">
2023-08-15 01:37:50 +08:00
and tpq.POINT = #{queryDto.point}
2023-08-14 01:31:26 +08:00
</if>
</where>
group by tq.QUESTION_ID
order by tq.SHOW_ORDER asc
</select>
2023-08-19 23:36:50 +08:00
<select id="queryQuestionByRandom" resultType="com.jwl.driver.server.vo.QuestionVo">
2023-08-14 01:31:26 +08:00
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.SOHU_IMG,
tq.BEST_ANSWER,
tq.CHAPTER,
tq.SUBJECT,
tq.OPTIONS,
tq.TYPE,
tq.SHOW_ORDER,
tq.CAR_TYPE_ID,
2023-08-19 00:39:11 +08:00
tq.IS_ACTIVE,
tq.IS_VIP,
tq.IS_ERROR,
tq.IS_NEW,
2023-08-19 13:49:56 +08:00
tq.EXAM_KEYS,
tq.IS_EXAM1,
tq.IS_EXAM2,
tq.IS_VIP2
2023-08-14 01:31:26 +08:00
from td_question tq
<where>
tq.IS_ACTIVE = '0'
<if test="queryDto.subject !=null and queryDto.subject !=''">
and tq.SUBJECT = #{queryDto.subject}
</if>
<if test="queryDto.carTypeId !=null">
and tq.CAR_TYPE_ID = #{queryDto.carTypeId}
</if>
<if test="queryDto.type !=null">
and tq.TYPE = #{queryDto.type}
</if>
</where>
order by rand() limit ${queryDto.num};
</select>
2023-08-19 00:39:11 +08:00
2023-08-19 23:36:50 +08:00
<update id="updateQuestion" parameterType="com.jwl.driver.server.vo.QuestionVo">
2023-08-23 23:58:25 +08:00
update td_question
2023-08-19 00:39:11 +08:00
<trim prefix="SET" suffixOverrides=",">
2023-08-23 23:58:25 +08:00
<if test="questionVo.isVip !=null">
IS_VIP = #{questionVo.isVip},
</if>
2023-08-19 23:36:50 +08:00
<if test="questionVo.isError !=null">
IS_ERROR = #{questionVo.isError},
2023-08-19 00:39:11 +08:00
</if>
2023-08-19 23:36:50 +08:00
<if test="questionVo.isNew !=null">
IS_NEW = #{questionVo.isNew},
2023-08-19 00:39:11 +08:00
</if>
2023-08-19 23:36:50 +08:00
<if test="questionVo.examKeys !=null">
EXAM_KEYS = #{questionVo.examKeys},
2023-08-19 00:39:11 +08:00
</if>
2023-08-19 23:36:50 +08:00
<if test="questionVo.isVip2 !=null">
IS_VIP2 = #{questionVo.isVip2},
2023-08-19 13:49:56 +08:00
</if>
2023-08-19 23:36:50 +08:00
<if test="questionVo.isExam1 !=null">
IS_EXAM1 = #{questionVo.isExam1},
2023-08-19 13:49:56 +08:00
</if>
2023-08-19 23:36:50 +08:00
<if test="questionVo.isExam2 !=null">
IS_EXAM2 = #{questionVo.isExam2},
2023-08-19 13:49:56 +08:00
</if>
2023-08-19 00:39:11 +08:00
</trim>
2023-08-19 23:36:50 +08:00
where QUESTION_ID = #{questionVo.questionId}
2023-08-19 00:39:11 +08:00
</update>
2023-08-27 16:38:22 +08:00
<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>
2023-09-03 22:38:58 +08:00
<select id="queryQuestionId" resultType="java.lang.Long">
select
tq.QUESTION_ID
from td_question tq
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 tq.SUBJECT = #{queryDto.subject}
</if>
<if test="queryDto.carTypeId !=null">
and tq.CAR_TYPE_ID = #{queryDto.carTypeId}
</if>
<if test="queryDto.type !=null and queryDto.type != ''">
and tq.TYPE = #{queryDto.type}
</if>
<if test="queryDto.isError !=null">
and tq.IS_ERROR = #{queryDto.isError}
</if>
<if test="queryDto.isNew !=null">
and tq.IS_NEW = #{queryDto.isNew}
</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.isVip !=null">
and tq.IS_VIP = #{queryDto.isVip}
</if>
<if test="queryDto.isVip2 !=null">
and tq.IS_VIP2 = #{queryDto.isVip2}
</if>
<if test="queryDto.isExam1 !=null">
and tq.IS_EXAM1 = #{queryDto.isExam1}
</if>
<if test="queryDto.isExam2 !=null">
and tq.IS_EXAM2 = #{queryDto.isExam2}
</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
<where>
tq.IS_ACTIVE = '0'
<if test="queryDto.subject !=null and queryDto.subject !=''">
and tq.SUBJECT = #{queryDto.subject}
</if>
<if test="queryDto.carTypeId !=null">
and tq.CAR_TYPE_ID = #{queryDto.carTypeId}
</if>
<if test="queryDto.type !=null">
and tq.TYPE = #{queryDto.type}
</if>
</where>
order by rand() limit ${queryDto.num};
</select>
2023-08-19 00:39:11 +08:00
2023-08-11 11:51:09 +08:00
</mapper>