<?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.zhongzheng.modules.exam.mapper.ExamConfigMapper">

    <resultMap type="com.zhongzheng.modules.exam.domain.ExamConfig" id="ExamConfigResult">
        <result property="id" column="id"/>
        <result property="passingScore" column="passing_score"/>
        <result property="examTime" column="exam_time"/>
        <result property="singleChoiceNum" column="single_choice_num"/>
        <result property="singleChoiceScore" column="single_choice_score"/>
        <result property="multipleChoiceNum" column="multiple_choice_num"/>
        <result property="multipleChoiceScore" column="multiple_choice_score"/>
        <result property="judgmentNum" column="judgment_num"/>
        <result property="judgmentScore" column="judgment_score"/>
        <result property="caseNum" column="case_num"/>
        <result property="caseScore" column="case_score"/>
        <result property="totalScore" column="total_score"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
        <result property="status" column="status"/>
        <result property="categoryId" column="category_id"/>
        <result property="categoryName" column="category_name"/>
    </resultMap>

    <select id="selectExamConfigList" parameterType="com.zhongzheng.modules.exam.bo.ExamConfigQueryBo"  resultMap="ExamConfigResult">
        SELECT
        ex.*,
        mc.category_name
        FROM
        exam_config ex
        LEFT JOIN major_category mc ON ex.category_id = mc.category_id
        WHERE 1=1
        <if test="status != null and status.size()!=0 ">
            AND ex.status in
            <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
        <if test="categoryId != null and categoryId != ''">
            AND ex.category_id = #{categoryId}
        </if>
    </select>

    <select id="selectBankExamConfig" parameterType="map"  resultMap="ExamConfigResult">
        SELECT
        ex.*
        FROM
        question_bank qb
        RIGHT JOIN exam_config ex ON qb.category_id = ex.category_id
        WHERE
        qb.bank_id = #{bankId}

    </select>

</mapper>
