<?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.ics.admin.mapper.meeting.RoomEquipmentMapper">
    
    <resultMap type="com.ics.admin.domain.meeting.RoomEquipment" id="RoomEquipmentResult">
        <result property="id"    column="id"    />
        <result property="equipmentId"    column="equipment_id"    />
        <result property="roomId"    column="room_id"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectRoomEquipmentVo">
        SELECT id, equipment_id, room_id, create_time FROM tb_room_equipment
    </sql>

    <select id="selectRoomEquipmentList" parameterType="RoomEquipment" resultMap="RoomEquipmentResult">
        <include refid="selectRoomEquipmentVo"/>
        <where>
            <if test="roomId != null  and roomId != ''"> AND room_id =#{roomId}</if>
        </where>
    </select>
    
    <select id="selectRoomEquipmentById" parameterType="Long" resultMap="RoomEquipmentResult">
        <include refid="selectRoomEquipmentVo"/>
        WHERE id = #{id}
    </select>
        
    <insert id="insertRoomEquipment" parameterType="RoomEquipment">
        INSERT INTO tb_room_equipment
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null ">id,</if>
            <if test="equipmentId != null ">equipment_id,</if>
            <if test="roomId != null ">room_id,</if>
            <if test="createTime != null ">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null ">#{id},</if>
            <if test="equipmentId != null ">#{equipmentId},</if>
            <if test="roomId != null ">#{roomId},</if>
            <if test="createTime != null ">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateRoomEquipment" parameterType="RoomEquipment">
        UPDATE tb_room_equipment
        <trim prefix="SET" suffixOverrides=",">
            <if test="equipmentId != null ">equipment_id = #{equipmentId},</if>
            <if test="roomId != null ">room_id = #{roomId},</if>
            <if test="createTime != null ">create_time = #{createTime},</if>
        </trim>
        WHERE id = #{id}
    </update>

    <delete id="deleteRoomEquipmentById" parameterType="Long">
        DELETE FROM tb_room_equipment WHERE id = #{id}
    </delete>

    <delete id="deleteRoomEquipmentByIds" parameterType="String">
        DELETE FROM tb_room_equipment where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    
</mapper>