<?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.model.mapper.TrainingMapper">
    
    <resultMap type="Training" id="TrainingResult">
        <result property="trainingId"    column="training_id"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="profile"    column="profile"    />
        <result property="reamk"    column="reamk"    />
        <result property="trainingAssessType"    column="training_assess_type"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectTrainingVo">
        select training_id, create_by, create_time, del_flag, profile, reamk, training_assess_type, update_by, update_time from training
    </sql>

    <select id="selectTrainingList" parameterType="Training" resultMap="TrainingResult">
        <include refid="selectTrainingVo"/>
        <where>  
            <if test="profile != null  and profile != ''"> and profile = #{profile}</if>
            <if test="reamk != null  and reamk != ''"> and reamk = #{reamk}</if>
            <if test="trainingAssessType != null  and trainingAssessType != ''"> and training_assess_type = #{trainingAssessType}</if>
        </where>
    </select>
    
    <select id="selectTrainingByTrainingId" parameterType="Long" resultMap="TrainingResult">
        <include refid="selectTrainingVo"/>
        where training_id = #{trainingId}
    </select>
    <select id="getTrainingList" resultType="com.ruoyi.model.domain.Training">
        <include refid="selectTrainingVo"/>
    </select>

    <insert id="insertTraining" parameterType="Training">
        insert into training
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="trainingId != null">training_id,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="profile != null">profile,</if>
            <if test="reamk != null">reamk,</if>
            <if test="trainingAssessType != null">training_assess_type,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="trainingId != null">#{trainingId},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="profile != null">#{profile},</if>
            <if test="reamk != null">#{reamk},</if>
            <if test="trainingAssessType != null">#{trainingAssessType},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateTraining" parameterType="Training">
        update training
        <trim prefix="SET" suffixOverrides=",">
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="profile != null">profile = #{profile},</if>
            <if test="reamk != null">reamk = #{reamk},</if>
            <if test="trainingAssessType != null">training_assess_type = #{trainingAssessType},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where training_id = #{trainingId}
    </update>

    <delete id="deleteTrainingByTrainingId" parameterType="Long">
        delete from training where training_id = #{trainingId}
    </delete>

    <delete id="deleteTrainingByTrainingIds" parameterType="String">
        delete from training where training_id in 
        <foreach item="trainingId" collection="array" open="(" separator="," close=")">
            #{trainingId}
        </foreach>
    </delete>
</mapper>