<?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.ruoyi.abuwx.mapper.exam.ExmExamMapper">
    
    <resultMap type="ExmExam" id="ExmExamResult">
        <result property="id"    column="ID"    />
        <result property="name"    column="NAME"    />
        <result property="paperName"    column="PAPER_NAME"    />
        <result property="genType"    column="GEN_TYPE"    />
        <result property="markType"    column="MARK_TYPE"    />
        <result property="showType"    column="SHOW_TYPE"    />
        <result property="startTime"    column="START_TIME"    />
        <result property="endTime"    column="END_TIME"    />
        <result property="limitMinute"    column="LIMIT_MINUTE"    />
        <result property="markStartTime"    column="MARK_START_TIME"    />
        <result property="markEndTime"    column="MARK_END_TIME"    />
        <result property="markState"    column="MARK_STATE"    />
        <result property="scoreState"    column="SCORE_STATE"    />
        <result property="rankState"    column="RANK_STATE"    />
        <result property="anonState"    column="ANON_STATE"    />
        <result property="passScore"    column="PASS_SCORE"    />
        <result property="totalScore"    column="TOTAL_SCORE"    />
        <result property="sxes"    column="SXES"    />
        <result property="state"    column="STATE"    />
        <result property="createUserId"    column="CREATE_USER_ID"    />
        <result property="updateUserId"    column="UPDATE_USER_ID"    />
        <result property="updateTime"    column="UPDATE_TIME"    />
    </resultMap>

    <sql id="selectExmExamVo">
        select ID, NAME, PAPER_NAME, GEN_TYPE, MARK_TYPE, SHOW_TYPE, START_TIME, END_TIME, LIMIT_MINUTE, MARK_START_TIME, MARK_END_TIME, MARK_STATE, SCORE_STATE, RANK_STATE, ANON_STATE, PASS_SCORE, TOTAL_SCORE, SXES, STATE, CREATE_USER_ID, UPDATE_USER_ID, UPDATE_TIME from exm_exam
    </sql>

    <select id="selectExmExamList" parameterType="ExmExam" resultMap="ExmExamResult">
        <include refid="selectExmExamVo"/>
        <where>  
            <if test="name != null  and name != ''"> and NAME like concat('%', #{name}, '%')</if>
            <if test="paperName != null  and paperName != ''"> and PAPER_NAME like concat('%', #{paperName}, '%')</if>
            <if test="genType != null "> and GEN_TYPE = #{genType}</if>
            <if test="markType != null "> and MARK_TYPE = #{markType}</if>
            <if test="showType != null "> and SHOW_TYPE = #{showType}</if>
            <if test="startTime != null "> and START_TIME = #{startTime}</if>
            <if test="endTime != null "> and END_TIME = #{endTime}</if>
            <if test="limitMinute != null "> and LIMIT_MINUTE = #{limitMinute}</if>
            <if test="markStartTime != null "> and MARK_START_TIME = #{markStartTime}</if>
            <if test="markEndTime != null "> and MARK_END_TIME = #{markEndTime}</if>
            <if test="markState != null "> and MARK_STATE = #{markState}</if>
            <if test="scoreState != null "> and SCORE_STATE = #{scoreState}</if>
            <if test="rankState != null "> and RANK_STATE = #{rankState}</if>
            <if test="anonState != null "> and ANON_STATE = #{anonState}</if>
            <if test="passScore != null "> and PASS_SCORE = #{passScore}</if>
            <if test="totalScore != null "> and TOTAL_SCORE = #{totalScore}</if>
            <if test="sxes != null  and sxes != ''"> and SXES = #{sxes}</if>
            <if test="state != null "> and STATE = #{state}</if>
            <if test="createUserId != null "> and CREATE_USER_ID = #{createUserId}</if>
            <if test="updateUserId != null "> and UPDATE_USER_ID = #{updateUserId}</if>
            <if test="updateTime != null "> and UPDATE_TIME = #{updateTime}</if>
        </where>
    </select>
    
    <select id="selectExmExamById" parameterType="Long" resultMap="ExmExamResult">
        <include refid="selectExmExamVo"/>
        where ID = #{id}
    </select>
        
    <insert id="insertExmExam" parameterType="ExmExam" useGeneratedKeys="true" keyProperty="id">
        insert into exm_exam
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null">NAME,</if>
            <if test="paperName != null">PAPER_NAME,</if>
            <if test="genType != null">GEN_TYPE,</if>
            <if test="markType != null">MARK_TYPE,</if>
            <if test="showType != null">SHOW_TYPE,</if>
            <if test="startTime != null">START_TIME,</if>
            <if test="endTime != null">END_TIME,</if>
            <if test="limitMinute != null">LIMIT_MINUTE,</if>
            <if test="markStartTime != null">MARK_START_TIME,</if>
            <if test="markEndTime != null">MARK_END_TIME,</if>
            <if test="markState != null">MARK_STATE,</if>
            <if test="scoreState != null">SCORE_STATE,</if>
            <if test="rankState != null">RANK_STATE,</if>
            <if test="anonState != null">ANON_STATE,</if>
            <if test="passScore != null">PASS_SCORE,</if>
            <if test="totalScore != null">TOTAL_SCORE,</if>
            <if test="sxes != null">SXES,</if>
            <if test="state != null">STATE,</if>
            <if test="createUserId != null">CREATE_USER_ID,</if>
            <if test="updateUserId != null">UPDATE_USER_ID,</if>
            <if test="updateTime != null">UPDATE_TIME,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null">#{name},</if>
            <if test="paperName != null">#{paperName},</if>
            <if test="genType != null">#{genType},</if>
            <if test="markType != null">#{markType},</if>
            <if test="showType != null">#{showType},</if>
            <if test="startTime != null">#{startTime},</if>
            <if test="endTime != null">#{endTime},</if>
            <if test="limitMinute != null">#{limitMinute},</if>
            <if test="markStartTime != null">#{markStartTime},</if>
            <if test="markEndTime != null">#{markEndTime},</if>
            <if test="markState != null">#{markState},</if>
            <if test="scoreState != null">#{scoreState},</if>
            <if test="rankState != null">#{rankState},</if>
            <if test="anonState != null">#{anonState},</if>
            <if test="passScore != null">#{passScore},</if>
            <if test="totalScore != null">#{totalScore},</if>
            <if test="sxes != null">#{sxes},</if>
            <if test="state != null">#{state},</if>
            <if test="createUserId != null">#{createUserId},</if>
            <if test="updateUserId != null">#{updateUserId},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateExmExam" parameterType="ExmExam">
        update exm_exam
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">NAME = #{name},</if>
            <if test="paperName != null">PAPER_NAME = #{paperName},</if>
            <if test="genType != null">GEN_TYPE = #{genType},</if>
            <if test="markType != null">MARK_TYPE = #{markType},</if>
            <if test="showType != null">SHOW_TYPE = #{showType},</if>
            <if test="startTime != null">START_TIME = #{startTime},</if>
            <if test="endTime != null">END_TIME = #{endTime},</if>
            <if test="limitMinute != null">LIMIT_MINUTE = #{limitMinute},</if>
            <if test="markStartTime != null">MARK_START_TIME = #{markStartTime},</if>
            <if test="markEndTime != null">MARK_END_TIME = #{markEndTime},</if>
            <if test="markState != null">MARK_STATE = #{markState},</if>
            <if test="scoreState != null">SCORE_STATE = #{scoreState},</if>
            <if test="rankState != null">RANK_STATE = #{rankState},</if>
            <if test="anonState != null">ANON_STATE = #{anonState},</if>
            <if test="passScore != null">PASS_SCORE = #{passScore},</if>
            <if test="totalScore != null">TOTAL_SCORE = #{totalScore},</if>
            <if test="sxes != null">SXES = #{sxes},</if>
            <if test="state != null">STATE = #{state},</if>
            <if test="createUserId != null">CREATE_USER_ID = #{createUserId},</if>
            <if test="updateUserId != null">UPDATE_USER_ID = #{updateUserId},</if>
            <if test="updateTime != null">UPDATE_TIME = #{updateTime},</if>
        </trim>
        where ID = #{id}
    </update>

    <delete id="deleteExmExamById" parameterType="Long">
        delete from exm_exam where ID = #{id}
    </delete>

    <delete id="deleteExmExamByIds" parameterType="String">
        delete from exm_exam where ID in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>