<?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.fuxi.ws.data.dao.WQuestiondtlMapper">
  <resultMap id="BaseResultMap" type="com.fuxi.ws.data.entity.WQuestiondtl">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Thu Oct 19 11:35:02 CST 2017.
    -->
    <id column="QtID" jdbcType="INTEGER" property="qtid" />
    <id column="QtDtlID" jdbcType="TINYINT" property="qtdtlid" />
    <result column="HasFraction" jdbcType="TINYINT" property="hasfraction" />
    <result column="TestType" jdbcType="TINYINT" property="testtype" />
    <result column="TestContext" jdbcType="VARCHAR" property="testcontext" />
    <result column="AnswerType" jdbcType="TINYINT" property="answertype" />
    <result column="ListIdx" jdbcType="TINYINT" property="listidx" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Thu Oct 19 11:35:02 CST 2017.
    -->
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <foreach collection="criteria.criteria" item="criterion">
              <choose>
                <when test="criterion.noValue">
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue">
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue">
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue">
                  and ${criterion.condition}
                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Thu Oct 19 11:35:02 CST 2017.
    -->
    QtID, QtDtlID, HasFraction, TestType, TestContext, AnswerType, ListIdx
  </sql>
  <select id="selectByExample" parameterType="com.fuxi.ws.data.entity.WQuestiondtlExample" resultMap="BaseResultMap">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Thu Oct 19 11:35:02 CST 2017.
    -->
    select
    <if test="distinct">
      distinct
    </if>
    'false' as QUERYID,
    <include refid="Base_Column_List" />
    from W_QuestionDtl
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="com.fuxi.ws.data.entity.WQuestiondtlKey" resultMap="BaseResultMap">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Thu Oct 19 11:35:02 CST 2017.
    -->
    select 
    <include refid="Base_Column_List" />
    from W_QuestionDtl
    where QtID = #{qtid,jdbcType=INTEGER}
      and QtDtlID = #{qtdtlid,jdbcType=TINYINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="com.fuxi.ws.data.entity.WQuestiondtlKey">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Thu Oct 19 11:35:02 CST 2017.
    -->
    delete from W_QuestionDtl
    where QtID = #{qtid,jdbcType=INTEGER}
      and QtDtlID = #{qtdtlid,jdbcType=TINYINT}
  </delete>
  <insert id="insert" parameterType="com.fuxi.ws.data.entity.WQuestiondtl">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Thu Oct 19 11:35:02 CST 2017.
    -->
    insert into W_QuestionDtl (QtID, QtDtlID, HasFraction, 
      TestType, TestContext, AnswerType, 
      ListIdx)
    values (#{qtid,jdbcType=INTEGER}, #{qtdtlid,jdbcType=TINYINT}, #{hasfraction,jdbcType=TINYINT}, 
      #{testtype,jdbcType=TINYINT}, #{testcontext,jdbcType=VARCHAR}, #{answertype,jdbcType=TINYINT}, 
      #{listidx,jdbcType=TINYINT})
  </insert>
  <insert id="insertSelective" parameterType="com.fuxi.ws.data.entity.WQuestiondtl">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Thu Oct 19 11:35:02 CST 2017.
    -->
    insert into W_QuestionDtl
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="qtid != null">
        QtID,
      </if>
      <if test="qtdtlid != null">
        QtDtlID,
      </if>
      <if test="hasfraction != null">
        HasFraction,
      </if>
      <if test="testtype != null">
        TestType,
      </if>
      <if test="testcontext != null">
        TestContext,
      </if>
      <if test="answertype != null">
        AnswerType,
      </if>
      <if test="listidx != null">
        ListIdx,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="qtid != null">
        #{qtid,jdbcType=INTEGER},
      </if>
      <if test="qtdtlid != null">
        #{qtdtlid,jdbcType=TINYINT},
      </if>
      <if test="hasfraction != null">
        #{hasfraction,jdbcType=TINYINT},
      </if>
      <if test="testtype != null">
        #{testtype,jdbcType=TINYINT},
      </if>
      <if test="testcontext != null">
        #{testcontext,jdbcType=VARCHAR},
      </if>
      <if test="answertype != null">
        #{answertype,jdbcType=TINYINT},
      </if>
      <if test="listidx != null">
        #{listidx,jdbcType=TINYINT},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.fuxi.ws.data.entity.WQuestiondtlExample" resultType="java.lang.Integer">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Thu Oct 19 11:35:02 CST 2017.
    -->
    select count(*) from W_QuestionDtl
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByPrimaryKeySelective" parameterType="com.fuxi.ws.data.entity.WQuestiondtl">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Thu Oct 19 11:35:02 CST 2017.
    -->
    update W_QuestionDtl
    <set>
      <if test="hasfraction != null">
        HasFraction = #{hasfraction,jdbcType=TINYINT},
      </if>
      <if test="testtype != null">
        TestType = #{testtype,jdbcType=TINYINT},
      </if>
      <if test="testcontext != null">
        TestContext = #{testcontext,jdbcType=VARCHAR},
      </if>
      <if test="answertype != null">
        AnswerType = #{answertype,jdbcType=TINYINT},
      </if>
      <if test="listidx != null">
        ListIdx = #{listidx,jdbcType=TINYINT},
      </if>
    </set>
    where QtID = #{qtid,jdbcType=INTEGER}
      and QtDtlID = #{qtdtlid,jdbcType=TINYINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.fuxi.ws.data.entity.WQuestiondtl">
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Thu Oct 19 11:35:02 CST 2017.
    -->
    update W_QuestionDtl
    set HasFraction = #{hasfraction,jdbcType=TINYINT},
      TestType = #{testtype,jdbcType=TINYINT},
      TestContext = #{testcontext,jdbcType=VARCHAR},
      AnswerType = #{answertype,jdbcType=TINYINT},
      ListIdx = #{listidx,jdbcType=TINYINT}
    where QtID = #{qtid,jdbcType=INTEGER}
      and QtDtlID = #{qtdtlid,jdbcType=TINYINT}
  </update>

	<select id="questionList" resultType="java.util.LinkedHashMap">
		select
		a.*,b.OptionID,b.OptionContext,b.OptionImg,b.LabelID,b.Fraction from
		W_QuestionDtl a
		join W_QuestionOption b on a.QtID=b.QtID and
		a.QtDtlID=b.QtDtlID
		where a.QtID=#{ qtid }
		order by a.QtDtlID,a.ListIdx,b.OptionID
	</select>
</mapper>