<?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.RoomItemMapper">
    
    <resultMap type="com.ics.admin.domain.meeting.RoomItem" id="RoomItemResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="brand"    column="brand"    />
        <result property="specification"    column="specification"    />
        <result property="picUrl"    column="pic_url"    />
        <result property="fileUrl"    column="file_url"    />
        <result property="remark"    column="remark"    />
        <result property="deleteFlag"    column="delete_flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectRoomItemVo">
        SELECT id, name, brand, specification, pic_url, file_url, remark, delete_flag, create_by, create_time, update_by, update_time FROM tb_room_item
    </sql>

    <select id="selectRoomItemList" parameterType="RoomItem" resultMap="RoomItemResult">
        <include refid="selectRoomItemVo"/>
        <where>  
            <if test="name != null  and name != ''"> AND name LIKE CONCAT('%', #{name}, '%')</if>
        </where>
    </select>
    
    <select id="selectRoomItemById" parameterType="Long" resultMap="RoomItemResult">
        <include refid="selectRoomItemVo"/>
        WHERE id = #{id}
    </select>
        
    <insert id="insertRoomItem" parameterType="RoomItem" useGeneratedKeys="true" keyProperty="id">
        INSERT INTO tb_room_item
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null  and name != ''">name,</if>
            <if test="brand != null  and brand != ''">brand,</if>
            <if test="specification != null  and specification != ''">specification,</if>
            <if test="picUrl != null  and picUrl != ''">pic_url,</if>
            <if test="fileUrl != null  and fileUrl != ''">file_url,</if>
            <if test="remark != null  and remark != ''">remark,</if>
            <if test="createBy != null  and createBy != ''">create_by,</if>
            <if test="createTime != null ">create_time,</if>
            <if test="updateBy != null  and updateBy != ''">update_by,</if>
            <if test="updateTime != null ">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null  and name != ''">#{name},</if>
            <if test="brand != null  and brand != ''">#{brand},</if>
            <if test="specification != null  and specification != ''">#{specification},</if>
            <if test="picUrl != null  and picUrl != ''">#{picUrl},</if>
            <if test="fileUrl != null  and fileUrl != ''">#{fileUrl},</if>
            <if test="remark != null  and remark != ''">#{remark},</if>
            <if test="createBy != null  and createBy != ''">#{createBy},</if>
            <if test="createTime != null ">#{createTime},</if>
            <if test="updateBy != null  and updateBy != ''">#{updateBy},</if>
            <if test="updateTime != null ">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateRoomItem" parameterType="RoomItem">
        UPDATE tb_room_item
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null  and name != ''">name = #{name},</if>
            <if test="brand != null  and brand != ''">brand = #{brand},</if>
            <if test="specification != null  and specification != ''">specification = #{specification},</if>
            <if test="picUrl != null  and picUrl != ''">pic_url = #{picUrl},</if>
            <if test="fileUrl != null  and fileUrl != ''">file_url = #{fileUrl},</if>
            <if test="remark != null  and remark != ''">remark = #{remark},</if>
            <if test="createBy != null  and createBy != ''">create_by = #{createBy},</if>
            <if test="createTime != null ">create_time = #{createTime},</if>
            <if test="updateBy != null  and updateBy != ''">update_by = #{updateBy},</if>
            <if test="updateTime != null ">update_time = #{updateTime},</if>
        </trim>
        WHERE id = #{id}
    </update>

    <delete id="deleteRoomItemById" parameterType="Long">
        DELETE FROM tb_room_item WHERE id = #{id}
    </delete>

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