<?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.QuestionInfoKtNewMapper">

    <resultMap type="QuestionInfoKtNew" id="QuestionInfoKtNewResult">
        <result property="id"    column="id"    />
        <result property="idYdt"    column="id_ydt"    />
        <result property="number"    column="number"    />
        <result property="answer"    column="answer"    />
        <result property="answerkeyword"    column="answerkeyword"    />
        <result property="explainGif"    column="explain_gif"    />
        <result property="explainJq"    column="explain_jq"    />
        <result property="explainJs"    column="explain_js"    />
        <result property="explainMp3"    column="explain_mp3"    />
        <result property="image"    column="image"    />
        <result property="imageYdt"    column="image_ydt"    />
        <result property="issue"    column="issue"    />
        <result property="opts"    column="opts"    />
        <result property="skillkeyword"    column="skillkeyword"    />
        <result property="titlekeyword"    column="titlekeyword"    />
        <result property="issuemp3"    column="issuemp3"    />
        <result property="answermp3"    column="answermp3"    />
        <result property="explainjsmp3"    column="explainjsmp3"    />
        <result property="model"    column="model"    />
        <result property="columnAll"    column="column_all"    />
        <result property="questionType"    column="question_type"    />
        <result property="subject"    column="subject"    />
        <result property="chapterId"    column="chapter_id"    />
        <result property="isNew"    column="is_new"    />
        <result property="diffDegree"    column="diff_degree"    />
        <result property="errorRate"    column="error_rate"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectQuestionInfoKtNewVo">
        select * from question_info_kt_new
    </sql>

    <select id="selectQuestionInfoKtNewList" parameterType="QuestionInfoKtNew" resultMap="QuestionInfoKtNewResult">
        <include refid="selectQuestionInfoKtNewVo"/>
        <where>
            <if test="idYdt != null "> and id_ydt = #{idYdt}</if>
            <if test="number != null "> and number = #{number}</if>
            <if test="answer != null  and answer != ''"> and answer = #{answer}</if>
            <if test="answerkeyword != null  and answerkeyword != ''"> and answerkeyword = #{answerkeyword}</if>
            <if test="explainGif != null  and explainGif != ''"> and explain_gif = #{explainGif}</if>
            <if test="explainJq != null  and explainJq != ''"> and explain_jq = #{explainJq}</if>
            <if test="explainJs != null  and explainJs != ''"> and explain_js = #{explainJs}</if>
            <if test="explainMp3 != null  and explainMp3 != ''"> and explain_mp3 = #{explainMp3}</if>
            <if test="image != null  and image != ''"> and image = #{image}</if>
            <if test="imageYdt != null  and imageYdt != ''"> and image_ydt = #{imageYdt}</if>
            <if test="issue != null  and issue != ''"> and issue = #{issue}</if>
            <if test="opts != null  and opts != ''"> and opts = #{opts}</if>
            <if test="skillkeyword != null  and skillkeyword != ''"> and skillkeyword = #{skillkeyword}</if>
            <if test="titlekeyword != null  and titlekeyword != ''"> and titlekeyword = #{titlekeyword}</if>
            <if test="issuemp3 != null  and issuemp3 != ''"> and issuemp3 = #{issuemp3}</if>
            <if test="answermp3 != null  and answermp3 != ''"> and answermp3 = #{answermp3}</if>
            <if test="explainjsmp3 != null  and explainjsmp3 != ''"> and explainjsmp3 = #{explainjsmp3}</if>
            <if test="model != null and model != ''"> AND model like concat('%', #{model}, '%') </if>
            <if test="columnAll != null  and columnAll != ''"> and column_all like concat('%', #{columnAll}, '%')</if>
            <if test="questionType != null "> and question_type = #{questionType}</if>
            <if test="subject != null  and subject != ''"> and subject = #{subject}</if>
            <if test="chapterId != null "> and chapter_id = #{chapterId}</if>
            <if test="isNew != null "> and is_new = #{isNew}</if>
            <if test="diffDegree != null "> and diff_degree = #{diffDegree}</if>
            <if test="errorRate != null "> and error_rate = #{errorRate}</if>
        </where>
    </select>


    <select id="selectQuestionInfoKtNewCount" parameterType="QuestionInfoKtNew" resultType="int">
        select count(1) from question_info_kt_new
        <where>
            <if test="id != null "> and id = #{id}</if>
            <if test="idYdt != null "> and id_ydt = #{idYdt}</if>
            <if test="number != null "> and number = #{number}</if>
            <if test="answer != null  and answer != ''"> and answer = #{answer}</if>
            <if test="answerkeyword != null  and answerkeyword != ''"> and answerkeyword = #{answerkeyword}</if>
            <if test="explainGif != null  and explainGif != ''"> and explain_gif = #{explainGif}</if>
            <if test="explainJq != null  and explainJq != ''"> and explain_jq = #{explainJq}</if>
            <if test="explainJs != null  and explainJs != ''"> and explain_js = #{explainJs}</if>
            <if test="explainMp3 != null  and explainMp3 != ''"> and explain_mp3 = #{explainMp3}</if>
            <if test="image != null  and image != ''"> and image = #{image}</if>
            <if test="imageYdt != null  and imageYdt != ''"> and image_ydt = #{imageYdt}</if>
            <if test="issue != null  and issue != ''"> and issue = #{issue}</if>
            <if test="opts != null  and opts != ''"> and opts = #{opts}</if>
            <if test="skillkeyword != null  and skillkeyword != ''"> and skillkeyword = #{skillkeyword}</if>
            <if test="titlekeyword != null  and titlekeyword != ''"> and titlekeyword = #{titlekeyword}</if>
            <if test="issuemp3 != null  and issuemp3 != ''"> and issuemp3 = #{issuemp3}</if>
            <if test="answermp3 != null  and answermp3 != ''"> and answermp3 = #{answermp3}</if>
            <if test="explainjsmp3 != null  and explainjsmp3 != ''"> and explainjsmp3 = #{explainjsmp3}</if>
            <if test="model != null  and model != ''"> and model = #{model}</if>
            <if test="columnAll != null  and columnAll != ''"> and column_all = #{columnAll}</if>
            <if test="questionType != null "> and question_type = #{questionType}</if>
            <if test="subject != null  and subject != ''"> and subject = #{subject}</if>
            <if test="chapterId != null "> and chapter_id = #{chapterId}</if>
            <if test="isNew != null "> and is_new = #{isNew}</if>
            <if test="diffDegree != null "> and diff_degree = #{diffDegree}</if>
            <if test="errorRate != null "> and error_rate = #{errorRate}</if>
        </where>
    </select>

    <select id="selectTestK14QuestionInfoList" resultType="com.miaxis.question.domain.QuestionInfoKtNew">
        ${sql}
    </select>


    <select id="selectFreeQuestionInfoList" resultMap="QuestionInfoKtNewResult"
            resultType="com.miaxis.question.domain.QuestionInfoKtNew">
        select q1.* from question_info_kt_new q1 join question_free q2 on q1.id = q2.id
        <where>
            <if test="subject != null"> and q2.subject = #{subject}</if>
        </where>
        order by q1.number
    </select>


    <select id="selectQuestionInfoList" parameterType="com.miaxis.question.dto.QuestionInfoNewDTO" resultMap="QuestionInfoKtNewResult">
        <include refid="selectQuestionInfoKtNewVo"/>
        <where>
            <if test="id != null "> and id = #{id}</if>
            <if test="number != null "> and number = #{number}</if>
            <if test="answer != null  and answer != ''"> and answer = #{answer}</if>
            <if test="issue != null  and issue != ''"> and issue = #{issue}</if>
            <if test="opts != null  and opts != ''"> and opts = #{opts}</if>
            <if test="questionType != null "> and question_type = #{questionType}</if>
            <if test="model != null and model != ''"> AND FIND_IN_SET(#{model}, model) </if>
            <if test="columnAll != null  and columnAll != ''"> AND FIND_IN_SET(#{columnAll}, column_all) </if>
            <if test="subject != null  and subject != ''"> and subject = #{subject}</if>
            <if test="chapterId != null "> and chapter_id = #{chapterId}</if>
            <if test="diffDegree != null "> and diff_degree = #{diffDegree}</if>
            <if test="isNew != null "> and is_new = #{isNew}</if>
        </where>
        order by number
    </select>


    <select id="selectNormalQuestionInfoList" parameterType="com.miaxis.question.dto.QuestionInfoDTO" resultMap="QuestionInfoKtNewResult">
        <include refid="selectQuestionInfoKtNewVo"/>
        <where>
            <if test="id != null "> and id = #{id}</if>
            <if test="number != null "> and number = #{number}</if>
            <if test="answer != null  and answer != ''"> and answer = #{answer}</if>
            <if test="issue != null  and issue != ''"> and issue = #{issue}</if>
            <if test="opts != null  and opts != ''"> and opts = #{opts}</if>
            <if test="questionType != null "> and question_type = #{questionType}</if>
            <if test="model != null and model != ''"> AND model like concat('%', #{model}, '%') </if>
            <if test="columnAll != null  and columnAll != ''"> and column_all like concat('%', #{columnAll}, '%')</if>
            <if test="subject != null  and subject != ''"> and subject = #{subject}</if>
            <if test="chapterId != null "> and chapter_id = #{chapterId}</if>
            <if test="errorRate != null "> and error_rate = #{errorRate}</if>
            <if test="diffDegree != null "> and diff_degree = #{diffDegree}</if>
            <if test="isNew != null "> and is_new = #{isNew}</if>
        </where>
        limit 0,50
        order by number
    </select>


    <select id="selectQuestionInfoListByIds" parameterType="Long" resultMap="QuestionInfoKtNewResult">
        <include refid="selectQuestionInfoKtNewVo"/>
        <where>
            and id in
            <foreach collection="array" item="id" index="index" open="(" close=")" separator=",">
                #{id}
            </foreach>
        </where>
        order by number
    </select>


</mapper>
