<?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.project.training.mapper.TTrainingbccRegularMapper">

    <resultMap type="TTrainingbccRegular" id="TTrainingbccRegularResult">
        <result property="id"    column="id"    />
        <result property="courseCode"    column="course_code"    />
        <result property="item"    column="item"    />
        <result property="actualpostId"    column="actualpost_id"    />
        <result property="remarks"    column="remarks"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createrCode"    column="creater_code"    />
        <result property="createdate"    column="createdate"    />
        <result property="updaterCode"    column="updater_code"    />
        <result property="updatedate"    column="updatedate"    />
        <result property="deptId"    column="dept_id"    />
        <result property="planTrainingdate"    column="plan_trainingdate"    />
        <result property="actualCompletedate"    column="actual_completedate"    />
        <result property="lecturer"    column="lecturer"    />
        <result property="hour"    column="hour"    />
        <result property="year"    column="year"    />
        <result property="designatedPosition"    column="designated_position"    />
        <result property="designatedStaff"    column="designated_staff"    />
        <result property="involvedMoc"    column="involved_moc"    />
        <result property="notPlan"    column="not_plan"    />
        <result property="notTrainingdate"    column="not_trainingdate"    />
        <result property="designatedOther"    column="designated_other"    />
        <result property="deptName" column="dept_name" />
    </resultMap>

    <sql id="selectTTrainingbccRegularVo">
        select d.id, d.course_code, d.item, d.actualpost_id, d.remarks, d.del_flag, d.creater_code, d.createdate, d.updater_code, d.updatedate, d.dept_id, d.plan_trainingdate, d.actual_completedate, d.lecturer, d.hour, d.year, d.designated_position, d.designated_staff, d.involved_moc, d.not_plan, d.not_trainingdate, d.designated_other  from t_trainingbcc_regular d
    </sql>

    <select id="selectTTrainingbccRegularList" parameterType="TTrainingbccRegular" resultMap="TTrainingbccRegularResult">
        <include refid="selectTTrainingbccRegularVo"/>
        <where>
            <if test="courseCode != null  and courseCode != ''"> and course_code = #{courseCode}</if>
            <if test="item != null  and item != ''"> and item = #{item}</if>
            <if test="actualpostId != null  and actualpostId != ''"> and actualpost_id = #{actualpostId}</if>
            <if test="remarks != null  and remarks != ''"> and remarks = #{remarks}</if>
            <if test="createrCode != null  and createrCode != ''"> and creater_code = #{createrCode}</if>
            <if test="createdate != null "> and createdate = #{createdate}</if>
            <if test="updaterCode != null  and updaterCode != ''"> and updater_code = #{updaterCode}</if>
            <if test="updatedate != null "> and updatedate = #{updatedate}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="planTrainingdate != null "> and plan_trainingdate = #{planTrainingdate}</if>
            <if test="actualCompletedate != null "> and actual_completedate = #{actualCompletedate}</if>
            <if test="lecturer != null  and lecturer != ''"> and lecturer = #{lecturer}</if>
            <if test="hour != null  and hour != ''"> and hour = #{hour}</if>
            <if test="year != null  and year != ''"> and year = #{year}</if>
            <if test="designatedPosition != null  and designatedPosition != ''"> and designated_position = #{designatedPosition}</if>
            <if test="designatedStaff != null  and designatedStaff != ''"> and designated_staff = #{designatedStaff}</if>
            <if test="involvedMoc != null  and involvedMoc != ''"> and involved_moc = #{involvedMoc}</if>
            <if test="notPlan != null  and notPlan != ''"> and not_plan = #{notPlan}</if>
            <if test="notTrainingdate != null  and notTrainingdate != ''"> and not_trainingdate = #{notTrainingdate}</if>
            <if test="designatedOther != null  and designatedOther != ''"> and designated_other = #{designatedOther}</if>
            and d.del_flag = 0
        </where>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
    </select>

    <select id="selectTTrainingbccRegularById" parameterType="Long" resultMap="TTrainingbccRegularResult">
        <include refid="selectTTrainingbccRegularVo"/>
        where id = #{id}
    </select>

    <insert id="insertTTrainingbccRegular" parameterType="TTrainingbccRegular">
        <selectKey keyProperty="id" resultType="long" order="BEFORE">
            SELECT seq_t_trainingbcc_regular.NEXTVAL as id FROM DUAL
        </selectKey>
        insert into t_trainingbcc_regular
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="courseCode != null">course_code,</if>
            <if test="item != null">item,</if>
            <if test="actualpostId != null">actualpost_id,</if>
            <if test="remarks != null">remarks,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createrCode != null">creater_code,</if>
            <if test="createdate != null">createdate,</if>
            <if test="updaterCode != null">updater_code,</if>
            <if test="updatedate != null">updatedate,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="planTrainingdate != null">plan_trainingdate,</if>
            <if test="actualCompletedate != null">actual_completedate,</if>
            <if test="lecturer != null">lecturer,</if>
            <if test="hour != null">hour,</if>
            <if test="year != null">year,</if>
            <if test="designatedPosition != null">designated_position,</if>
            <if test="designatedStaff != null">designated_staff,</if>
            <if test="involvedMoc != null">involved_moc,</if>
            <if test="notPlan != null">not_plan,</if>
            <if test="notTrainingdate != null">not_trainingdate,</if>
            <if test="designatedOther != null">designated_other,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="courseCode != null">#{courseCode},</if>
            <if test="item != null">#{item},</if>
            <if test="actualpostId != null">#{actualpostId},</if>
            <if test="remarks != null">#{remarks},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createrCode != null">#{createrCode},</if>
            <if test="createdate != null">#{createdate},</if>
            <if test="updaterCode != null">#{updaterCode},</if>
            <if test="updatedate != null">#{updatedate},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="planTrainingdate != null">#{planTrainingdate},</if>
            <if test="actualCompletedate != null">#{actualCompletedate},</if>
            <if test="lecturer != null">#{lecturer},</if>
            <if test="hour != null">#{hour},</if>
            <if test="year != null">#{year},</if>
            <if test="designatedPosition != null">#{designatedPosition},</if>
            <if test="designatedStaff != null">#{designatedStaff},</if>
            <if test="involvedMoc != null">#{involvedMoc},</if>
            <if test="notPlan != null">#{notPlan},</if>
            <if test="notTrainingdate != null">#{notTrainingdate},</if>
            <if test="designatedOther != null">#{designatedOther},</if>
         </trim>
    </insert>

    <update id="updateTTrainingbccRegular" parameterType="TTrainingbccRegular">
        update t_trainingbcc_regular
        <trim prefix="SET" suffixOverrides=",">
            <if test="courseCode != null">course_code = #{courseCode},</if>
            <if test="item != null">item = #{item},</if>
            <if test="actualpostId != null">actualpost_id = #{actualpostId},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createrCode != null">creater_code = #{createrCode},</if>
            <if test="createdate != null">createdate = #{createdate},</if>
            <if test="updaterCode != null">updater_code = #{updaterCode},</if>
            <if test="updatedate != null">updatedate = #{updatedate},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="planTrainingdate != null">plan_trainingdate = #{planTrainingdate},</if>
            <if test="actualCompletedate != null">actual_completedate = #{actualCompletedate},</if>
            <if test="lecturer != null">lecturer = #{lecturer},</if>
            <if test="hour != null">hour = #{hour},</if>
            <if test="year != null">year = #{year},</if>
            <if test="designatedPosition != null">designated_position = #{designatedPosition},</if>
            <if test="designatedStaff != null">designated_staff = #{designatedStaff},</if>
            <if test="involvedMoc != null">involved_moc = #{involvedMoc},</if>
            <if test="notPlan != null">not_plan = #{notPlan},</if>
            <if test="notTrainingdate != null">not_trainingdate = #{notTrainingdate},</if>
            <if test="designatedOther != null">designated_other = #{designatedOther},</if>
        </trim>
        where id = #{id}
    </update>

    <update id="deleteTTrainingbccRegularById" parameterType="Long">
        update t_trainingbcc_regular set del_flag = 2 where id = #{id}
    </update>

    <update id="deleteTTrainingbccRegularByIds" parameterType="String">
        update t_trainingbcc_regular set del_flag = 2 where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>

</mapper>
