<?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.UserCollectQuestionRelationMapper">
  <resultMap id="IdMap" type="com.qxgmat.data.dao.entity.UserCollectQuestion">
    <!--
      WARNING - @mbg.generated
    -->
    <id column="id" jdbcType="INTEGER" property="id" />
  </resultMap>
  <sql id="Id_Column_List">
    <!--
      WARNING - @mbg.generated
    -->
    ucq.`id`
  </sql>

  <!--
    用户收藏题目列表
  -->
  <select id="list" resultMap="IdMap">
    select
    <include refid="Id_Column_List" />
    from `user_collect_question` ucq
    left join `question_no` qn on qn.`id` = ucq.`question_no_id`
      <if test="module != null">
        and qn.`module` = #{module,jdbcType=VARCHAR}
      </if>
    left join `question` q on q.`id` = ucq.`question_id`
      <if test="questionType != null">
        and q.`question_type` = #{questionType,jdbcType=VARCHAR}
      </if>
    where
    qn.`id` != null
    and q.`id` != null
    <if test="userId != null">
      and ucq.`user_id` = #{userId,jdbcType=VARCHAR}
    </if>
    <if test="startTime != null">
      and ucq.`createTime` &gt; #{startTime,jdbcType=VARCHAR}
    </if>
    <if test="endTime != null">
      and ucq.`createTime` &lt; #{endTime,jdbcType=VARCHAR}
    </if>

    order by ${order} ${direction}
  </select>

</mapper>