<?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.RoomRecordMapper">
    
    <resultMap type="com.ics.admin.domain.meeting.RoomRecord" id="RoomRecordResult">
        <result property="id"    column="id"    />
        <result property="roomId"    column="room_id"    />
        <result property="deviceId"    column="device_id"    />
        <result property="userId"    column="user_id"    />
        <result property="createTime"    column="create_time"    />
        <result property="type"    column="type"    />
        <result property="createBy"    column="create_by"    />
        <result property="deleteFlag"    column="delete_flag"    />
    </resultMap>

    <sql id="selectRoomRecordVo">
        SELECT id, room_id, device_id, user_id, create_time,`type`, create_by, delete_flag FROM tb_room_record
    </sql>

    <select id="selectRoomRecordList" parameterType="RoomRecord" resultMap="RoomRecordResult">
        <include refid="selectRoomRecordVo"/>
        <where>  
        </where>
    </select>
    
    <select id="selectRoomRecordById" parameterType="Long" resultMap="RoomRecordResult">
        <include refid="selectRoomRecordVo"/>
        WHERE id = #{id}
    </select>
        
    <insert id="insertRoomRecord" parameterType="RoomRecord">
        INSERT INTO tb_room_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null ">id,</if>
            <if test="roomId != null ">room_id,</if>
            <if test="deviceId != null ">device_id,</if>
            <if test="userId != null ">user_id,</if>
            <if test="type != null ">type,</if>
            <if test="createTime != null ">create_time,</if>
            <if test="createBy != null  and createBy != ''">create_by,</if>
            <if test="deleteFlag != null ">delete_flag,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null ">#{id},</if>
            <if test="roomId != null ">#{roomId},</if>
            <if test="deviceId != null ">#{deviceId},</if>
            <if test="userId != null ">#{userId},</if>
            <if test="type != null ">#{type},</if>
            <if test="createTime != null ">#{createTime},</if>
            <if test="createBy != null  and createBy != ''">#{createBy},</if>
            <if test="deleteFlag != null ">#{deleteFlag},</if>
         </trim>
    </insert>

    <update id="updateRoomRecord" parameterType="RoomRecord">
        UPDATE tb_room_record
        <trim prefix="SET" suffixOverrides=",">
            <if test="roomId != null ">room_id = #{roomId},</if>
            <if test="deviceId != null ">device_id = #{deviceId},</if>
            <if test="userId != null ">user_id = #{userId},</if>
            <if test="type != null ">`type` = #{type},</if>
            <if test="createTime != null ">create_time = #{createTime},</if>
            <if test="createBy != null  and createBy != ''">create_by = #{createBy},</if>
            <if test="deleteFlag != null ">delete_flag = #{deleteFlag},</if>
        </trim>
        WHERE id = #{id}
    </update>

    <delete id="deleteRoomRecordById" parameterType="Long">
        DELETE FROM tb_room_record WHERE id = #{id}
    </delete>

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