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

    <resultMap type="QuestionError" id="QuestionErrorResult">
        <result property="id"    column="id"    />
        <result property="userId"    column="user_id"    />
        <result property="questionId"    column="question_id"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectQuestionErrorVo">
        select id, user_id, question_id, create_time, update_time from question_error
    </sql>

    <select id="selectQuestionErrorList" parameterType="QuestionError" resultMap="QuestionErrorResult">
        <include refid="selectQuestionErrorVo"/>
        <where>
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="questionId != null "> and question_id = #{questionId}</if>
        </where>
    </select>


    <select id="getQuestionErrorList" parameterType="com.miaxis.question.dto.QuestionErrorDto" resultType="com.miaxis.question.vo.QuestionInfoVo">
        select qi.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 qi
        JOIN question_error qe
        ON qi.id = qe.question_id
        <where>
            <if test="userId != null"> and qe.user_id = #{userId} </if>
            <if test="questionId != null "> and question_id = #{questionId}</if>
            <if test="kemu != null "> and kemu = #{kemu}</if>
        </where>
    </select>


</mapper>
