<?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.plant.mapper.TConfInfoMapper">

    <resultMap type="TConfInfo" id="TConfInfoResult">
        <result property="id"    column="id"    />
        <result property="roomId"    column="room_id"    />
        <result property="subject"    column="subject"    />
        <result property="convenerId"    column="convener_id"    />
        <result property="convenerName"    column="convener_name"    />
        <result property="roomName"    column="room_name"    />
        <result property="participantsList"    column="participants_list"    />
        <result property="beginDatetime"    column="begin_datetime"    />
        <result property="endDatetime"    column="end_datetime"    />
        <result property="color"    column="color"    />
        <result property="isAllday"    column="is_allday"    />
        <result property="genFrequency"    column="gen_frequency"    />
        <result property="genMonth"    column="gen_month"    />
        <result property="genDay"    column="gen_day"    />
        <result property="genDate"    column="gen_date"    />
        <result property="genDatetime"    column="gen_datetime"    />
        <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="remarks"    column="remarks"    />
        <result property="deptName" column="dept_name" />
    </resultMap>

    <sql id="selectTConfInfoVo">
        select d.id, d.room_id, d.subject, d.convener_id, d.convener_name, d.room_name, d.participants_list, d.begin_datetime, d.end_datetime, d.color, d.is_allday, d.gen_frequency, d.gen_month, d.gen_day, d.gen_date, d.gen_datetime, d.del_flag, d.creater_code, d.createdate, d.updater_code, d.updatedate, d.dept_id, d.remarks ,s.dept_name from t_conf_info d
      left join sys_dept s on s.dept_id = d.dept_id
    </sql>

    <select id="selectTConfInfoList" parameterType="TConfInfo" resultMap="TConfInfoResult">
        <include refid="selectTConfInfoVo"/>
        <where>
            <if test="roomId != null "> and room_id = #{roomId}</if>
            <if test="subject != null  and subject != ''"> and subject = #{subject}</if>
            <if test="convenerId != null  and convenerId != ''"> and convener_id = #{convenerId}</if>
            <if test="convenerName != null  and convenerName != ''"> and convener_name like concat(concat('%', #{convenerName}), '%')</if>
            <if test="roomName != null  and roomName != ''"> and room_name like concat(concat('%', #{roomName}), '%')</if>
            <if test="beginDatetime != null "> and begin_datetime = #{beginDatetime}</if>
            <if test="endDatetime != null "> and end_datetime = #{endDatetime}</if>
            and d.del_flag = 0
        </where>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
    </select>

    <select id="selectTConfInfoByTime" parameterType="TConfInfo" resultMap="TConfInfoResult">
        select d.id, d.room_id, d.subject, d.convener_id, d.convener_name, d.room_name, d.participants_list, d.begin_datetime, d.end_datetime, d.color, d.is_allday, d.gen_frequency, d.gen_month, d.gen_day, d.gen_date, d.gen_datetime, d.del_flag, d.creater_code, d.createdate, d.updater_code, d.updatedate, d.dept_id, d.remarks from t_conf_info d
        <where>
            d.room_id = #{roomId}
            <if test="beginDatetime != null "> and  end_datetime > #{beginDatetime}</if>
            <if test="endDatetime != null "> and #{endDatetime} > begin_datetime </if>
            and d.del_flag = 0
        </where>
    </select>



    <select id="selectTConfInfoById" parameterType="Long" resultMap="TConfInfoResult">
        <include refid="selectTConfInfoVo"/>
        where id = #{id}
    </select>

    <insert id="insertTConfInfo" parameterType="TConfInfo">
        <selectKey keyProperty="id" resultType="long" order="BEFORE">
            SELECT seq_t_conf_info.NEXTVAL as id FROM DUAL
        </selectKey>
        insert into t_conf_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="roomId != null">room_id,</if>
            <if test="subject != null">subject,</if>
            <if test="convenerId != null">convener_id,</if>
            <if test="convenerName != null">convener_name,</if>
            <if test="roomName != null">room_name,</if>
            <if test="participantsList != null">participants_list,</if>
            <if test="beginDatetime != null">begin_datetime,</if>
            <if test="endDatetime != null">end_datetime,</if>
            <if test="color != null">color,</if>
            <if test="isAllday != null">is_allday,</if>
            <if test="genFrequency != null">gen_frequency,</if>
            <if test="genMonth != null">gen_month,</if>
            <if test="genDay != null">gen_day,</if>
            <if test="genDate != null">gen_date,</if>
            <if test="genDatetime != null">gen_datetime,</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="remarks != null">remarks,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="roomId != null">#{roomId},</if>
            <if test="subject != null">#{subject},</if>
            <if test="convenerId != null">#{convenerId},</if>
            <if test="convenerName != null">#{convenerName},</if>
            <if test="roomName != null">#{roomName},</if>
            <if test="participantsList != null">#{participantsList},</if>
            <if test="beginDatetime != null">#{beginDatetime},</if>
            <if test="endDatetime != null">#{endDatetime},</if>
            <if test="color != null">#{color},</if>
            <if test="isAllday != null">#{isAllday},</if>
            <if test="genFrequency != null">#{genFrequency},</if>
            <if test="genMonth != null">#{genMonth},</if>
            <if test="genDay != null">#{genDay},</if>
            <if test="genDate != null">#{genDate},</if>
            <if test="genDatetime != null">#{genDatetime},</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="remarks != null">#{remarks},</if>
         </trim>
    </insert>

    <update id="updateTConfInfo" parameterType="TConfInfo">
        update t_conf_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="roomId != null">room_id = #{roomId},</if>
            <if test="subject != null">subject = #{subject},</if>
            <if test="convenerId != null">convener_id = #{convenerId},</if>
            <if test="convenerName != null">convener_name = #{convenerName},</if>
            <if test="roomName != null">room_name = #{roomName},</if>
            <if test="participantsList != null">participants_list = #{participantsList},</if>
            <if test="beginDatetime != null">begin_datetime = #{beginDatetime},</if>
            <if test="endDatetime != null">end_datetime = #{endDatetime},</if>
            <if test="color != null">color = #{color},</if>
            <if test="isAllday != null">is_allday = #{isAllday},</if>
            <if test="genFrequency != null">gen_frequency = #{genFrequency},</if>
            <if test="genMonth != null">gen_month = #{genMonth},</if>
            <if test="genDay != null">gen_day = #{genDay},</if>
            <if test="genDate != null">gen_date = #{genDate},</if>
            <if test="genDatetime != null">gen_datetime = #{genDatetime},</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="remarks != null">remarks = #{remarks},</if>
        </trim>
        where id = #{id}
    </update>

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

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

</mapper>
