123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- <?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.qxgmat.data.relation.UserAskQuestionRelationMapper">
- <resultMap id="IdMap" type="com.qxgmat.data.dao.entity.UserAskQuestion">
- <!--
- WARNING - @mbg.generated
- -->
- <id column="id" jdbcType="INTEGER" property="id" />
- </resultMap>
- <sql id="Id_Column_List">
- <!--
- WARNING - @mbg.generated
- -->
- DISTINCT(uaq.`id`)
- </sql>
- <!--修改问答排序-->
- <update id="adjust">
- UPDATE `user_ask_question`
- <trim prefix="set" suffixOverrides=",">
- `order`#{flag}1
- </trim>
- WHERE `question_id` = #{questionId,jdbcType=VARCHAR} and `order` #{direction} #{order,jdbcType=INTEGER}
- </update>
- <select id="listExercise" resultMap="IdMap">
- <if test="keyword != null">
- <bind name="keywordLike" value="'%' + keyword + '%'" />
- </if>
- select
- <include refid="Id_Column_List" />,
- uaq.`ask_time`,
- uaq.`create_time`
- from `user_ask_question` uaq
- left join `question` q on q.`id` = uaq.`question_id`
- and (q.`question_module` = 'base' or q.`question_module` = 'sentence')
- <if test="questionTypes != null">
- and
- <foreach collection="questionTypes" item="item" index="index" open="(" close=")" separator=" or ">
- q.`question_type` = #{item}
- </foreach>
- </if>
- left join `question_no` qn on qn.`id` = uaq.`question_no_id` and qn.`module` = 'exercise' and qn.`delete_time` is null
- and (q.`question_module` = 'base')
- <if test="structIds != null">
- and
- <foreach collection="structIds" item="item" index="index" open="(" close=")" separator=" or ">
- find_in_set(#{item}, qn.`module_struct`)
- </foreach>
- </if>
- left join `sentence_question` sq on sq.`question_id` = q.`id`
- and (q.`question_module` = 'sentence')
- where
- q.`id` > 0 and uaq.`user_id` = #{userId,jdbcType=VARCHAR}
- <if test="keyword != null">
- and (q.`stem` like #{keywordLike,jdbcType=VARCHAR}
- or qn.`title` like #{keywordLike,jdbcType=VARCHAR}
- or sq.`title` like #{keywordLike,jdbcType=VARCHAR})
- </if>
- <if test="structIds != null">
- and qn.`id` > 0
- </if>
- <if test="structIds == null">
- and (qn.`id` > 0 or sq.`id` > 0)
- </if>
- <if test="answerStatus != null">
- and uaq.`answer_status` = #{answerStatus,jdbcType=INTEGER}
- </if>
- <if test="startTime != null">
- and uaq.`create_time` > #{startTime,jdbcType=TIMESTAMP}
- </if>
- <if test="endTime != null">
- and uaq.`create_time` < #{endTime,jdbcType=TIMESTAMP}
- </if>
- <if test="order != null">
- order by ${order}
- </if>
- </select>
- <select id="listExamination" resultMap="IdMap">
- <if test="keyword != null">
- <bind name="keywordLike" value="'%' + keyword + '%'" />
- </if>
- select
- <include refid="Id_Column_List" />,
- uaq.`ask_time`,
- uaq.`create_time`
- from `user_ask_question` uaq
- left join `question` q on q.`id` = uaq.`question_id`
- and (q.`question_module` = 'base' or q.`question_module` = 'textbook')
- <if test="questionTypes != null">
- and
- <foreach collection="questionTypes" item="item" index="index" open="(" close=")" separator=" or ">
- q.`question_type` = #{item}
- </foreach>
- </if>
- left join `question_no` qn on qn.`id` = uaq.`question_no_id` and qn.`module` = 'examination' and qn.`delete_time` is null
- and (q.`question_module` = 'base')
- <if test="structIds != null">
- and
- <foreach collection="structIds" item="item" index="index" open="(" close=")" separator=" or ">
- find_in_set(#{item}, qn.`module_struct`)
- </foreach>
- </if>
- left join `textbook_question` tq on tq.`question_id` = q.`id`
- and (q.`question_module` = 'textbook')
- <if test="libraryId != null and libraryId > 0">
- and tq.`library_id` = #{libraryId,jdbcType=VARCHAR}
- </if>
- <if test="year != null">
- and tq.`year` = #{year,jdbcType=VARCHAR}
- </if>
- where
- q.`id` > 0 and uaq.`user_id` = #{userId,jdbcType=VARCHAR}
- <if test="keyword != null">
- and (q.`stem` like #{keywordLike,jdbcType=VARCHAR}
- or qn.`title` like #{keywordLike,jdbcType=VARCHAR}
- or tq.`title` like #{keywordLike,jdbcType=VARCHAR})
- </if>
- <if test="structIds != null">
- and qn.`id` > 0
- </if>
- <if test="structIds == null">
- and (qn.`id` > 0 or tq.`id` > 0)
- </if>
- <if test="libraryId != null">
- and (tq.`id` > 0)
- </if>
- <if test="year != null">
- and (tq.`id` > 0)
- </if>
- <if test="answerStatus != null">
- and uaq.`answer_status` = #{answerStatus,jdbcType=INTEGER}
- </if>
- <if test="startTime != null">
- and uaq.`create_time` > #{startTime,jdbcType=TIMESTAMP}
- </if>
- <if test="endTime != null">
- and uaq.`create_time` < #{endTime,jdbcType=TIMESTAMP}
- </if>
- <if test="order != null">
- order by ${order}
- </if>
- </select>
- <!--后台提问列表-->
- <select id="listAdmin" resultMap="IdMap">
- select
- <include refid="Id_Column_List" />
- from `user_ask_question` uaq
- left join `user` u on u.`id` = uaq.`user_id`
- <if test="userId != null">
- and uaq.`user_id` = #{userId,jdbcType=VARCHAR}
- </if>
- <if test="max != null">
- and u.`total_money` < ${max}
- </if>
- <if test="min != null">
- and u.`total_money` > ${min}
- </if>
- left join `question` q on q.`id` = uaq.`question_id`
- where
- u.`id` > 0
- <if test="questionNoId != null">
- and uaq.`question_no_id` = #{questionNoId,jdbcType=VARCHAR}
- </if>
- <if test="target != null">
- and uaq.`target` = #{target,jdbcType=VARCHAR}
- </if>
- <if test="answerStatus != null">
- and uaq.`answer_status` = #{answerStatus,jdbcType=INTEGER}
- </if>
- <if test="showStatus != null">
- and uaq.`show_status` = #{showStatus,jdbcType=INTEGER}
- </if>
- <if test="askModule != null">
- and uaq.`ask_module` =#{askModule,jdbcType=VARCHAR}
- </if>
- <if test="questionModule != null">
- and uaq.`question_module` =#{questionModule,jdbcType=VARCHAR}
- </if>
- <if test="questionType != null">
- and q.`question_type` =#{questionType,jdbcType=VARCHAR}
- </if>
- <if test="startTime != null">
- and uaq.`create_time` > #{startTime,jdbcType=TIMESTAMP}
- </if>
- <if test="endTime != null">
- and uaq.`create_time` < #{endTime,jdbcType=TIMESTAMP}
- </if>
- <if test="hasRecord != null">
- <if test="hasRecord">
- and uaq.`record_id` > 0
- </if>
- <if test="!hasRecord">
- and uaq.`record_id` = 0
- </if>
- </if>
- order by ${order} ${direction}
- </select>
- </mapper>
|