<?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.shiftmgr.mapper.TShiftDevelopmentMapper">
    
    <resultMap type="TShiftDevelopment" id="TShiftDevelopmentResult">
        <result property="id"    column="id"    />
        <result property="team"    column="team"    />
        <result property="title"    column="title"    />
        <result property="location"    column="location"    />
        <result property="organizeDate"    column="organize_date"    />
        <result property="organizer"    column="organizer"    />
        <result property="participants"    column="participants"    />
        <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="deptName" column="dept_name" />
    </resultMap>

    <sql id="selectTShiftDevelopmentVo">
        select d.id, d.team, d.title, d.location, d.organize_date, d.organizer, d.participants, d.del_flag, d.creater_code, d.createdate, d.updater_code, d.updatedate, d.dept_id ,s.dept_name from t_shift_development d
      left join sys_dept s on s.dept_id = d.dept_id
    </sql>

    <select id="selectTShiftDevelopmentList" parameterType="TShiftDevelopment" resultMap="TShiftDevelopmentResult">
        <include refid="selectTShiftDevelopmentVo"/>
        <where>  
            <if test="team != null  and team != ''"> and team = #{team}</if>
            <if test="title != null  and title != ''"> and title = #{title}</if>
            <if test="location != null  and location != ''"> and location = #{location}</if>
            <if test="organizeDate != null "> and organize_date = #{organizeDate}</if>
            <if test="organizer != null  and organizer != ''"> and organizer = #{organizer}</if>
            <if test="participants != null  and participants != ''"> and participants = #{participants}</if>
            <if test="createrCode != null "> and creater_code = #{createrCode}</if>
            <if test="createdate != null "> and createdate = #{createdate}</if>
            <if test="updaterCode != null "> and updater_code = #{updaterCode}</if>
            <if test="updatedate != null "> and updatedate = #{updatedate}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            and d.del_flag = 0
        </where>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
    </select>
    
    <select id="selectTShiftDevelopmentById" parameterType="Long" resultMap="TShiftDevelopmentResult">
        <include refid="selectTShiftDevelopmentVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTShiftDevelopment" parameterType="TShiftDevelopment">
        <selectKey keyProperty="id" resultType="long" order="BEFORE">
            SELECT SEQ_T_SHIFT_DEVELOPMENT.NEXTVAL as id FROM DUAL
        </selectKey>
        insert into t_shift_development
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="team != null">team,</if>
            <if test="title != null">title,</if>
            <if test="location != null">location,</if>
            <if test="organizeDate != null">organize_date,</if>
            <if test="organizer != null">organizer,</if>
            <if test="participants != null">participants,</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>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="team != null">#{team},</if>
            <if test="title != null">#{title},</if>
            <if test="location != null">#{location},</if>
            <if test="organizeDate != null">#{organizeDate},</if>
            <if test="organizer != null">#{organizer},</if>
            <if test="participants != null">#{participants},</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>
         </trim>
    </insert>

    <update id="updateTShiftDevelopment" parameterType="TShiftDevelopment">
        update t_shift_development
        <trim prefix="SET" suffixOverrides=",">
            <if test="team != null">team = #{team},</if>
            <if test="title != null">title = #{title},</if>
            <if test="location != null">location = #{location},</if>
            <if test="organizeDate != null">organize_date = #{organizeDate},</if>
            <if test="organizer != null">organizer = #{organizer},</if>
            <if test="participants != null">participants = #{participants},</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>
        </trim>
        where id = #{id}
    </update>

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

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