<?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.system.mapper.ConferenceRoomMapper">
    
    <resultMap type="ConferenceRoom" id="ConferenceRoomResult">
        <result property="conferenceRoomId"    column="conference_room_id"    />
        <result property="conferenceRoomName"    column="conference_room_name"    />
        <result property="conferenceRoomAddress"    column="conference_room_address"    />
        <result property="createDept"    column="create_dept"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectConferenceRoomVo">
        select conference_room_id, conference_room_name, conference_room_address, create_dept, create_by, create_time, update_by, update_time, remark from conference_room
    </sql>

    <select id="selectConferenceRoomList" parameterType="ConferenceRoom" resultMap="ConferenceRoomResult">
        <include refid="selectConferenceRoomVo"/>
        <where>  
            <if test="conferenceRoomName != null  and conferenceRoomName != ''"> and conference_room_name like concat('%', #{conferenceRoomName}, '%')</if>
            <if test="conferenceRoomAddress != null  and conferenceRoomAddress != ''"> and conference_room_address = #{conferenceRoomAddress}</if>
            <if test="createDept != null "> and create_dept = #{createDept}</if>
        </where>
    </select>
    
    <select id="selectConferenceRoomByConferenceRoomId" parameterType="Long" resultMap="ConferenceRoomResult">
        <include refid="selectConferenceRoomVo"/>
        where conference_room_id = #{conferenceRoomId}
    </select>
        
    <insert id="insertConferenceRoom" parameterType="ConferenceRoom" useGeneratedKeys="true" keyProperty="conferenceRoomId">
        insert into conference_room
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="conferenceRoomName != null">conference_room_name,</if>
            <if test="conferenceRoomAddress != null">conference_room_address,</if>
            <if test="createDept != null">create_dept,</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>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="conferenceRoomName != null">#{conferenceRoomName},</if>
            <if test="conferenceRoomAddress != null">#{conferenceRoomAddress},</if>
            <if test="createDept != null">#{createDept},</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>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateConferenceRoom" parameterType="ConferenceRoom">
        update conference_room
        <trim prefix="SET" suffixOverrides=",">
            <if test="conferenceRoomName != null">conference_room_name = #{conferenceRoomName},</if>
            <if test="conferenceRoomAddress != null">conference_room_address = #{conferenceRoomAddress},</if>
            <if test="createDept != null">create_dept = #{createDept},</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>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where conference_room_id = #{conferenceRoomId}
    </update>

    <delete id="deleteConferenceRoomByConferenceRoomId" parameterType="Long">
        delete from conference_room where conference_room_id = #{conferenceRoomId}
    </delete>

    <delete id="deleteConferenceRoomByConferenceRoomIds" parameterType="String">
        delete from conference_room where conference_room_id in 
        <foreach item="conferenceRoomId" collection="array" open="(" separator="," close=")">
            #{conferenceRoomId}
        </foreach>
    </delete>
</mapper>