<?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.zehong.system.mapper.TTrainCourseBankMapper">
    
    <resultMap type="TTrainCourseBank" id="TTrainCourseBankResult">
        <result property="bankId"    column="bank_id"    />
        <result property="deptId"    column="dept_id"    />
        <result property="bankName"    column="bank_name"    />
        <result property="isDel"    column="is_del"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectTTrainCourseBankVo">
        select bank_id, dept_id, bank_name, is_del, create_by, create_time, update_by, update_time from t_train_course_bank
    </sql>

    <select id="selectTTrainCourseBankList" parameterType="TTrainCourseBank" resultMap="TTrainCourseBankResult">
        <include refid="selectTTrainCourseBankVo"/>
        <where>  
            <if test="bankName != null  and bankName != ''"> and bank_name like concat('%', #{bankName}, '%')</if>
        </where>
    </select>
    
    <select id="selectTTrainCourseBankById" parameterType="Long" resultMap="TTrainCourseBankResult">
        <include refid="selectTTrainCourseBankVo"/>
        where bank_id = #{bankId}
    </select>
        
    <insert id="insertTTrainCourseBank" parameterType="TTrainCourseBank" useGeneratedKeys="true" keyProperty="bankId">
        insert into t_train_course_bank
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="deptId != null">dept_id,</if>
            <if test="bankName != null">bank_name,</if>
            <if test="isDel != null">is_del,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="deptId != null">#{deptId},</if>
            <if test="bankName != null">#{bankName},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateTTrainCourseBank" parameterType="TTrainCourseBank">
        update t_train_course_bank
        <trim prefix="SET" suffixOverrides=",">
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="bankName != null">bank_name = #{bankName},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where bank_id = #{bankId}
    </update>

    <delete id="deleteTTrainCourseBankById" parameterType="Long">
        delete from t_train_course_bank where bank_id = #{bankId}
    </delete>

    <delete id="deleteTTrainCourseBankByIds" parameterType="String">
        delete from t_train_course_bank where bank_id in 
        <foreach item="bankId" collection="array" open="(" separator="," close=")">
            #{bankId}
        </foreach>
    </delete>
</mapper>