<?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.mwt.oes.dao.BankSingleChoiceQueMapper" >
  <resultMap id="BaseResultMap" type="com.mwt.oes.domain.BankSingleChoiceQue" >
    <id column="single_id" property="singleId" jdbcType="INTEGER" />
    <result column="single_content" property="singleContent" jdbcType="VARCHAR" />
    <result column="choice_A" property="choiceA" jdbcType="VARCHAR" />
    <result column="choice_B" property="choiceB" jdbcType="VARCHAR" />
    <result column="choice_C" property="choiceC" jdbcType="VARCHAR" />
    <result column="choice_D" property="choiceD" jdbcType="VARCHAR" />
    <result column="choice_E" property="choiceE" jdbcType="VARCHAR" />
    <result column="choice_F" property="choiceF" jdbcType="VARCHAR" />
    <result column="choice_G" property="choiceG" jdbcType="VARCHAR" />
    <result column="single_answer" property="singleAnswer" jdbcType="VARCHAR" />
    <result column="compose_flag" property="composeFlag" jdbcType="VARCHAR" />
    <result column="answer_explain" property="answerExplain" jdbcType="VARCHAR" />
    <result column="lang_id" property="langId" jdbcType="INTEGER" />

    <association property="paperQue" javaType="com.mwt.oes.domain.PaperQue">
      <id column="que_id" property="queId" jdbcType="INTEGER" />
      <result column="que_type" property="queType" jdbcType="INTEGER"/>
    </association>
  </resultMap>
  <sql id="Example_Where_Clause" >
    <where >
      <foreach collection="oredCriteria" item="criteria" separator="or" >
        <if test="criteria.valid" >
          <trim prefix="(" suffix=")" prefixOverrides="and" >
            <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 collection="criterion.value" item="listItem" open="(" close=")" separator="," >
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause" >
    <where >
      <foreach collection="example.oredCriteria" item="criteria" separator="or" >
        <if test="criteria.valid" >
          <trim prefix="(" suffix=")" prefixOverrides="and" >
            <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 collection="criterion.value" item="listItem" open="(" close=")" separator="," >
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List" >
    single_id, single_content, choice_A, choice_B, choice_C, choice_D, choice_E, choice_F, 
    choice_G, single_answer, compose_flag, answer_explain, lang_id
  </sql>
  <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.mwt.oes.domain.BankSingleChoiceQueExample" >
    select
    <if test="distinct" >
      distinct
    </if>
    <include refid="Base_Column_List" />
    from bank_single_choice_que
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null" >
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from bank_single_choice_que
    where single_id = #{singleId,jdbcType=INTEGER}
  </select>

  <select id="getSingleQueListByPaperId" resultMap="BaseResultMap" parameterType="java.lang.Integer">
    SELECT q.que_id,q.que_type,s.single_id,s.single_content,s.choice_A,s.choice_B,s.choice_C,s.choice_D,s.choice_E,s.choice_F,s.choice_G,s.single_answer,s.compose_flag,s.answer_explain,s.lang_id
    FROM paper_que q,bank_single_choice_que s
    WHERE paper_id=#{paperId,jdbcType=INTEGER} AND q.single_id=s.single_id
  </select>

  <select id="getRandomSingleByCountAndLangId" resultMap="BaseResultMap" parameterType="java.lang.Integer">
    SELECT * FROM bank_single_choice_que WHERE lang_id=#{langId,jdbcType=INTEGER} ORDER BY RAND() LIMIT #{singleNum,jdbcType=INTEGER}
  </select>

  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from bank_single_choice_que
    where single_id = #{singleId,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="com.mwt.oes.domain.BankSingleChoiceQueExample" >
    delete from bank_single_choice_que
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.mwt.oes.domain.BankSingleChoiceQue" >
    insert into bank_single_choice_que (single_id, single_content, choice_A, 
      choice_B, choice_C, choice_D, 
      choice_E, choice_F, choice_G, 
      single_answer, compose_flag, answer_explain, 
      lang_id)
    values (#{singleId,jdbcType=INTEGER}, #{singleContent,jdbcType=VARCHAR}, #{choiceA,jdbcType=VARCHAR}, 
      #{choiceB,jdbcType=VARCHAR}, #{choiceC,jdbcType=VARCHAR}, #{choiceD,jdbcType=VARCHAR}, 
      #{choiceE,jdbcType=VARCHAR}, #{choiceF,jdbcType=VARCHAR}, #{choiceG,jdbcType=VARCHAR}, 
      #{singleAnswer,jdbcType=VARCHAR}, #{composeFlag,jdbcType=VARCHAR}, #{answerExplain,jdbcType=VARCHAR}, 
      #{langId,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" parameterType="com.mwt.oes.domain.BankSingleChoiceQue" >
    insert into bank_single_choice_que
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="singleId != null" >
        single_id,
      </if>
      <if test="singleContent != null" >
        single_content,
      </if>
      <if test="choiceA != null" >
        choice_A,
      </if>
      <if test="choiceB != null" >
        choice_B,
      </if>
      <if test="choiceC != null" >
        choice_C,
      </if>
      <if test="choiceD != null" >
        choice_D,
      </if>
      <if test="choiceE != null" >
        choice_E,
      </if>
      <if test="choiceF != null" >
        choice_F,
      </if>
      <if test="choiceG != null" >
        choice_G,
      </if>
      <if test="singleAnswer != null" >
        single_answer,
      </if>
      <if test="composeFlag != null" >
        compose_flag,
      </if>
      <if test="answerExplain != null" >
        answer_explain,
      </if>
      <if test="langId != null" >
        lang_id,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="singleId != null" >
        #{singleId,jdbcType=INTEGER},
      </if>
      <if test="singleContent != null" >
        #{singleContent,jdbcType=VARCHAR},
      </if>
      <if test="choiceA != null" >
        #{choiceA,jdbcType=VARCHAR},
      </if>
      <if test="choiceB != null" >
        #{choiceB,jdbcType=VARCHAR},
      </if>
      <if test="choiceC != null" >
        #{choiceC,jdbcType=VARCHAR},
      </if>
      <if test="choiceD != null" >
        #{choiceD,jdbcType=VARCHAR},
      </if>
      <if test="choiceE != null" >
        #{choiceE,jdbcType=VARCHAR},
      </if>
      <if test="choiceF != null" >
        #{choiceF,jdbcType=VARCHAR},
      </if>
      <if test="choiceG != null" >
        #{choiceG,jdbcType=VARCHAR},
      </if>
      <if test="singleAnswer != null" >
        #{singleAnswer,jdbcType=VARCHAR},
      </if>
      <if test="composeFlag != null" >
        #{composeFlag,jdbcType=VARCHAR},
      </if>
      <if test="answerExplain != null" >
        #{answerExplain,jdbcType=VARCHAR},
      </if>
      <if test="langId != null" >
        #{langId,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.mwt.oes.domain.BankSingleChoiceQueExample" resultType="java.lang.Integer" >
    select count(*) from bank_single_choice_que
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map" >
    update bank_single_choice_que
    <set >
      <if test="record.singleId != null" >
        single_id = #{record.singleId,jdbcType=INTEGER},
      </if>
      <if test="record.singleContent != null" >
        single_content = #{record.singleContent,jdbcType=VARCHAR},
      </if>
      <if test="record.choiceA != null" >
        choice_A = #{record.choiceA,jdbcType=VARCHAR},
      </if>
      <if test="record.choiceB != null" >
        choice_B = #{record.choiceB,jdbcType=VARCHAR},
      </if>
      <if test="record.choiceC != null" >
        choice_C = #{record.choiceC,jdbcType=VARCHAR},
      </if>
      <if test="record.choiceD != null" >
        choice_D = #{record.choiceD,jdbcType=VARCHAR},
      </if>
      <if test="record.choiceE != null" >
        choice_E = #{record.choiceE,jdbcType=VARCHAR},
      </if>
      <if test="record.choiceF != null" >
        choice_F = #{record.choiceF,jdbcType=VARCHAR},
      </if>
      <if test="record.choiceG != null" >
        choice_G = #{record.choiceG,jdbcType=VARCHAR},
      </if>
      <if test="record.singleAnswer != null" >
        single_answer = #{record.singleAnswer,jdbcType=VARCHAR},
      </if>
      <if test="record.composeFlag != null" >
        compose_flag = #{record.composeFlag,jdbcType=VARCHAR},
      </if>
      <if test="record.answerExplain != null" >
        answer_explain = #{record.answerExplain,jdbcType=VARCHAR},
      </if>
      <if test="record.langId != null" >
        lang_id = #{record.langId,jdbcType=INTEGER},
      </if>
    </set>
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map" >
    update bank_single_choice_que
    set single_id = #{record.singleId,jdbcType=INTEGER},
      single_content = #{record.singleContent,jdbcType=VARCHAR},
      choice_A = #{record.choiceA,jdbcType=VARCHAR},
      choice_B = #{record.choiceB,jdbcType=VARCHAR},
      choice_C = #{record.choiceC,jdbcType=VARCHAR},
      choice_D = #{record.choiceD,jdbcType=VARCHAR},
      choice_E = #{record.choiceE,jdbcType=VARCHAR},
      choice_F = #{record.choiceF,jdbcType=VARCHAR},
      choice_G = #{record.choiceG,jdbcType=VARCHAR},
      single_answer = #{record.singleAnswer,jdbcType=VARCHAR},
      compose_flag = #{record.composeFlag,jdbcType=VARCHAR},
      answer_explain = #{record.answerExplain,jdbcType=VARCHAR},
      lang_id = #{record.langId,jdbcType=INTEGER}
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.mwt.oes.domain.BankSingleChoiceQue" >
    update bank_single_choice_que
    <set >
      <if test="singleContent != null" >
        single_content = #{singleContent,jdbcType=VARCHAR},
      </if>
      <if test="choiceA != null" >
        choice_A = #{choiceA,jdbcType=VARCHAR},
      </if>
      <if test="choiceB != null" >
        choice_B = #{choiceB,jdbcType=VARCHAR},
      </if>
      <if test="choiceC != null" >
        choice_C = #{choiceC,jdbcType=VARCHAR},
      </if>
      <if test="choiceD != null" >
        choice_D = #{choiceD,jdbcType=VARCHAR},
      </if>
      <if test="choiceE != null" >
        choice_E = #{choiceE,jdbcType=VARCHAR},
      </if>
      <if test="choiceF != null" >
        choice_F = #{choiceF,jdbcType=VARCHAR},
      </if>
      <if test="choiceG != null" >
        choice_G = #{choiceG,jdbcType=VARCHAR},
      </if>
      <if test="singleAnswer != null" >
        single_answer = #{singleAnswer,jdbcType=VARCHAR},
      </if>
      <if test="composeFlag != null" >
        compose_flag = #{composeFlag,jdbcType=VARCHAR},
      </if>
      <if test="answerExplain != null" >
        answer_explain = #{answerExplain,jdbcType=VARCHAR},
      </if>
      <if test="langId != null" >
        lang_id = #{langId,jdbcType=INTEGER},
      </if>
    </set>
    where single_id = #{singleId,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.mwt.oes.domain.BankSingleChoiceQue" >
    update bank_single_choice_que
    set single_content = #{singleContent,jdbcType=VARCHAR},
      choice_A = #{choiceA,jdbcType=VARCHAR},
      choice_B = #{choiceB,jdbcType=VARCHAR},
      choice_C = #{choiceC,jdbcType=VARCHAR},
      choice_D = #{choiceD,jdbcType=VARCHAR},
      choice_E = #{choiceE,jdbcType=VARCHAR},
      choice_F = #{choiceF,jdbcType=VARCHAR},
      choice_G = #{choiceG,jdbcType=VARCHAR},
      single_answer = #{singleAnswer,jdbcType=VARCHAR},
      compose_flag = #{composeFlag,jdbcType=VARCHAR},
      answer_explain = #{answerExplain,jdbcType=VARCHAR},
      lang_id = #{langId,jdbcType=INTEGER}
    where single_id = #{singleId,jdbcType=INTEGER}
  </update>
</mapper>