<?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.miaxis.question.mapper.QuestionInfoMapper">

    <resultMap type="QuestionInfo" id="QuestionInfoResult">
        <result property="id"    column="id"    />
        <result property="type"    column="type"    />
        <result property="intNumber"    column="int_number"    />
        <result property="strTppe"    column="str_tppe"    />
        <result property="strTypeL"    column="str_type_l"    />
        <result property="licenseType"    column="license_type"    />
        <result property="question"    column="question"    />
        <result property="an1"    column="an1"    />
        <result property="an2"    column="an2"    />
        <result property="an3"    column="an3"    />
        <result property="an4"    column="an4"    />
        <result property="an5"    column="an5"    />
        <result property="an6"    column="an6"    />
        <result property="an7"    column="an7"    />
        <result property="answerTrue"    column="answer_true"    />
        <result property="explain1"    column="explain1"    />
        <result property="bestAnswerId"    column="best_answer_id"    />
        <result property="kemu"    column="kemu"    />
        <result property="jieshiFrom"    column="jieshi_from"    />
        <result property="moretypes"    column="moretypes"    />
        <result property="chapterid"    column="chapterid"    />
        <result property="sinaimg"    column="sinaimg"    />
        <result property="videoUrl"    column="video_url"    />
        <result property="diffDegree"    column="diff_degree"    />
        <result property="cityid"    column="cityid"    />
        <result property="gs"    column="gs"    />
        <result property="keyword"    column="keyword"    />
        <result property="errorRate"    column="error_rate"    />
        <result property="mediaUrl"    column="media_url"    />
        <result property="showOptionType"    column="show_option_type"    />
    </resultMap>

    <sql id="selectQuestionInfoVo">
        select id, type, int_number, str_tppe, str_type_l, license_type, question, an1, an2, an3, an4, an5, an6, an7, answer_true, explain1, best_answer_id, kemu, jieshi_from, moretypes, chapterid, sinaimg, video_url, diff_degree, cityid, gs, keyword, error_rate, media_url, show_option_type from question_info
    </sql>

    <select id="selectQuestionInfoList" parameterType="QuestionInfo" resultMap="QuestionInfoResult">
        <include refid="selectQuestionInfoVo"/>
        <where>
            <if test="id != null "> and id = #{id}</if>
            <if test="type != null "> and type = #{type}</if>
            <if test="intNumber != null  and intNumber != ''"> and int_number = #{intNumber}</if>
            <if test="strTppe != null  and strTppe != ''"> and str_tppe = #{strTppe}</if>
            <if test="strTypeL != null  and strTypeL != ''"> and str_type_l = #{strTypeL}</if>
            <if test="licenseType != null  and licenseType != ''"> and license_type = #{licenseType}</if>
            <if test="question != null  and question != ''"> and question = #{question}</if>
            <if test="an1 != null  and an1 != ''"> and an1 = #{an1}</if>
            <if test="an2 != null  and an2 != ''"> and an2 = #{an2}</if>
            <if test="an3 != null  and an3 != ''"> and an3 = #{an3}</if>
            <if test="an4 != null  and an4 != ''"> and an4 = #{an4}</if>
            <if test="an5 != null  and an5 != ''"> and an5 = #{an5}</if>
            <if test="an6 != null  and an6 != ''"> and an6 = #{an6}</if>
            <if test="an7 != null  and an7 != ''"> and an7 = #{an7}</if>
            <if test="answerTrue != null  and answerTrue != ''"> and answer_true = #{answerTrue}</if>
            <if test="explain1 != null  and explain1 != ''"> and explain1 = #{explain1}</if>
            <if test="bestAnswerId != null  and bestAnswerId != ''"> and best_answer_id = #{bestAnswerId}</if>
            <if test="kemu != null "> and kemu = #{kemu}</if>
            <if test="jieshiFrom != null  and jieshiFrom != ''"> and jieshi_from = #{jieshiFrom}</if>
            <if test="moretypes != null  and moretypes != ''"> and moretypes = #{moretypes}</if>
            <if test="chapterid != null "> and chapterid = #{chapterid}</if>
            <if test="sinaimg != null  and sinaimg != ''"> and sinaimg = #{sinaimg}</if>
            <if test="videoUrl != null  and videoUrl != ''"> and video_url = #{videoUrl}</if>
            <if test="diffDegree != null "> and diff_degree = #{diffDegree}</if>
            <if test="cityid != null "> and cityid = #{cityid}</if>
            <if test="gs != null  and gs != ''"> and gs = #{gs}</if>
            <if test="keyword != null  and keyword != ''"> and keyword = #{keyword}</if>
            <if test="errorRate != null "> and error_rate = #{errorRate}</if>
            <if test="mediaUrl != null  and mediaUrl != ''"> and media_url = #{mediaUrl}</if>
            <if test="showOptionType != null "> and show_option_type = #{showOptionType}</if>
        </where>
    </select>


    <select id="getQuestionInfoList" parameterType="com.miaxis.question.dto.QuestionInfoDto" resultType="com.miaxis.question.vo.QuestionInfoVo">
        select id, type, question, an1, an2, an3, an4, an5, an6, an7, answer_true, explain1, best_answer_id, kemu, sinaimg, video_url, cityid, media_url, show_option_type from question_info
        <where>
            <if test="id != null "> and id = #{id}</if>
            <if test="type != null "> and type = #{type}</if>
            <if test="licenseType != null  and licenseType != ''"> and license_type like #{licenseType}</if>
            <if test="kemu != null "> and kemu = #{kemu}</if>
            <if test="showOptionType != null "> and show_option_type = #{showOptionType}</if>
        </where>
    </select>


    <select id="getRandQuestionInfoList" parameterType="com.miaxis.question.dto.QuestionInfoRandDto" resultType="com.miaxis.question.vo.QuestionInfoVo">
        select id, type, question, an1, an2, an3, an4, an5, an6, an7, answer_true, explain1, best_answer_id, kemu, sinaimg, video_url, cityid, media_url, show_option_type from question_info
        <where>
            <if test="type != null "> and type = #{type}</if>
            <if test="licenseType != null  and licenseType != ''"> and license_type like #{licenseType}</if>
            <if test="kemu != null "> and kemu = #{kemu}</if>
        </where>
         order by rand() limit #{num}
    </select>


</mapper>
