<?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="org.dromara.main.mapper.MainAbilityConfigMapper">

    <resultMap type="org.dromara.main.domain.MainAbilityConfig" id="MainAbilityConfigResult">
        <result property="id" column="id"/>
        <result property="evaluationId" column="evaluation_id"/>
        <result property="abilityName" column="ability_name"/>
        <result property="thirdExamInfoId" column="third_exam_info_id"/>
        <result property="thirdExamName" column="third_exam_name"/>
        <result property="thirdExamTime" column="third_exam_time"/>
        <result property="thirdExamPassMark" column="third_exam_pass_mark"/>
        <result property="thirdExamTotalScore" column="third_exam_total_score"/>
        <result property="thirdExamLink" column="third_exam_link"/>
        <result property="sortOrder" column="sort_order"/>
        <result property="createDept" column="create_dept"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="remark" column="remark"/>
        <result property="delFlag" column="del_flag"/>
    </resultMap>

    <select id="selectByEvaluationId" resultMap="MainAbilityConfigResult">
        SELECT * FROM main_ability_config
        WHERE evaluation_id = #{evaluationId} AND del_flag = '0'
        ORDER BY sort_order ASC, id ASC
    </select>

    <delete id="deleteByEvaluationId">
        UPDATE main_ability_config SET del_flag = '1' WHERE evaluation_id = #{evaluationId}
    </delete>

    <insert id="insertBatch" parameterType="java.util.List">
        INSERT INTO main_ability_config (
        evaluation_id, ability_name, third_exam_info_id, third_exam_name,
        third_exam_time, third_exam_pass_mark, third_exam_total_score, third_exam_link,
        sort_order, create_dept, create_by, create_time, del_flag
        ) VALUES
        <foreach collection="configs" item="item" separator=",">
            (#{item.evaluationId}, #{item.abilityName}, #{item.thirdExamInfoId},
            #{item.thirdExamName}, #{item.thirdExamTime}, #{item.thirdExamPassMark},
            #{item.thirdExamTotalScore}, #{item.thirdExamLink}, #{item.sortOrder}, #{item.createDept},
            #{item.createBy}, NOW(), '0')
        </foreach>
    </insert>

</mapper>
