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

  <select id="listAdmin" resultMap="IdMap">
    select
    <include refid="Id_Column_List" />
    from `exercise_paper_question` epq
    left join `question` q on q.`id` = epq.`question_id`
    left join `question_no` qn on qn.`id` = epq.`question_no_id`
    <if test="structId != null">
    left join `exercise_paper` ep on ep.`id` = epg.`paper_id`
        and ep.`id` = #{paperId,jdbcType=VARCHAR}
    </if>
    where qn.`module` = "exercise"
    <if test="paperId != null">
      and epq.`paper_id` != null
    </if>
    <if test="structId != null">
      and find_in_set(#{structId,jdbcType=VARCHAR}, qn.`module_struct`)
    </if>
    <if test="questionNoId != null">
      and qn.`id` =#{questionNoId,jdbcType=VARCHAR}
    </if>
    <if test="type != null">
      and q.`type` =#{type,jdbcType=VARCHAR}
    </if>
    <if test="place != null">
      and q.`place` =#{place,jdbcType=VARCHAR}
    </if>
    <if test="difficult != null">
      and q.`difficult` =#{difficult,jdbcType=VARCHAR}
    </if>
    <if test="startTime != null">
      and hp.`update_time` &gt; #{startTime,jdbcType=VARCHAR}
    </if>
    <if test="endTime != null">
      and hp.`update_time` &lt; #{endTime,jdbcType=VARCHAR}
    </if>
    order by ${order} ${direction}
  </select>
</mapper>