<?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.ShowroomMapper">
    
    <resultMap type="com.ics.admin.domain.meeting.Showroom" id="ShowroomResult">
        <result property="id"    column="id"    />
        <result property="showroomCode"    column="showroom_code"    />
        <result property="meetingName"    column="meeting_name"    />
        <result property="capacityNum"    column="capacity_num"    />
        <result property="expandNum"    column="expand_num"    />
        <result property="indoorPicUrl"    column="indoor_pic_url"    />
        <result property="address"    column="address"    />
        <result property="startTime"    column="start_time"    />
        <result property="endDate"    column="end_date"    />
        <result property="isShow"    column="is_show"    />
        <result property="headName"    column="head_name"    />
        <result property="headPhone"    column="head_phone"    />
        <result property="content"    column="content"    />
        <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="version"    column="version"    />
        <result property="deleteFlag"    column="delete_flag"    />
        <result property="roomId"    column="room_id"    />
        <result property="area"    column="area"    />
        <result property="parkId"    column="park_id"    />
        <result property="buildingId"    column="building_id"    />
        <result property="tenantId"    column="tenant_id"    />
        <result property="buildId"    column="build_id"    />

    </resultMap>

    <sql id="selectShowroomVo">
        SELECT id, showroom_code, meeting_name, capacity_num, expand_num, indoor_pic_url, address,park_id,building_id,tenant_id,build_id, start_time, end_date, is_show, head_name, head_phone, content, create_by, create_time, update_by, update_time, version, delete_flag, room_id, area FROM tb_showroom
    </sql>

    <select id="selectShowroomList" parameterType="Showroom" resultMap="ShowroomResult">
        <include refid="selectShowroomVo"/>
        <where>  
            <if test="meetingName != null  and meetingName != ''"> AND meeting_name LIKE CONCAT('%', #{meetingName}, '%')</if>
            <if test="headName != null  and headName != ''"> AND head_name LIKE CONCAT('%', #{headName}, '%')</if>
        </where>
    </select>
    
    <select id="selectShowroomById" parameterType="Long" resultMap="ShowroomResult">
        <include refid="selectShowroomVo"/>
        WHERE id = #{id}
    </select>
        
    <insert id="insertShowroom" parameterType="Showroom" useGeneratedKeys="true" keyProperty="id">
        INSERT INTO tb_showroom
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="showroomCode != null  and showroomCode != ''">showroom_code,</if>
            <if test="meetingName != null  and meetingName != ''">meeting_name,</if>
            <if test="capacityNum != null ">capacity_num,</if>
            <if test="expandNum != null ">expand_num,</if>
            <if test="indoorPicUrl != null  and indoorPicUrl != ''">indoor_pic_url,</if>
            <if test="address != null  and address != ''">address,</if>
            <if test="startTime != null ">start_time,</if>
            <if test="endDate != null ">end_date,</if>
            <if test="isShow != null ">is_show,</if>
            <if test="headName != null  and headName != ''">head_name,</if>
            <if test="headPhone != null  and headPhone != ''">head_phone,</if>
            <if test="content != null  and content != ''">content,</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>
            <if test="version != null ">version,</if>
            <if test="deleteFlag != null ">delete_flag,</if>
            <if test="roomId != null ">room_id,</if>
            <if test="area != null  and area != ''">area,</if>
            <if test="parkId != null and parkId != '' ">park_id,</if>
            <if test="buildingId != null and buildingId != '' ">building_id,</if>
            <if test="tenantId != null and tenantId != '' ">tenant_id,</if>
            <if test="buildId != null and buildId != '' ">build_id,</if>

         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="showroomCode != null  and showroomCode != ''">#{showroomCode},</if>
            <if test="meetingName != null  and meetingName != ''">#{meetingName},</if>
            <if test="capacityNum != null ">#{capacityNum},</if>
            <if test="expandNum != null ">#{expandNum},</if>
            <if test="indoorPicUrl != null  and indoorPicUrl != ''">#{indoorPicUrl},</if>
            <if test="address != null  and address != ''">#{address},</if>
            <if test="startTime != null ">#{startTime},</if>
            <if test="endDate != null ">#{endDate},</if>
            <if test="isShow != null ">#{isShow},</if>
            <if test="headName != null  and headName != ''">#{headName},</if>
            <if test="headPhone != null  and headPhone != ''">#{headPhone},</if>
            <if test="content != null  and content != ''">#{content},</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>
            <if test="version != null ">#{version},</if>
            <if test="deleteFlag != null ">#{deleteFlag},</if>
            <if test="roomId != null ">#{roomId},</if>
            <if test="area != null  and area != ''">#{area},</if>
            <if test="parkId != null and parkId != '' ">parkId,</if>
            <if test="buildingId != null and buildingId != '' ">buildingId,</if>
            <if test="tenantId != null and tenantId != '' ">tenantId,</if>
            <if test="buildId != null and buildId != '' ">buildId,</if>
         </trim>
    </insert>

    <update id="updateShowroom" parameterType="Showroom">
        UPDATE tb_showroom
        <trim prefix="SET" suffixOverrides=",">
            <if test="showroomCode != null  and showroomCode != ''">showroom_code = #{showroomCode},</if>
            <if test="meetingName != null  and meetingName != ''">meeting_name = #{meetingName},</if>
            <if test="capacityNum != null ">capacity_num = #{capacityNum},</if>
            <if test="expandNum != null ">expand_num = #{expandNum},</if>
            <if test="indoorPicUrl != null  and indoorPicUrl != ''">indoor_pic_url = #{indoorPicUrl},</if>
            <if test="address != null  and address != ''">address = #{address},</if>
            <if test="startTime != null ">start_time = #{startTime},</if>
            <if test="endDate != null ">end_date = #{endDate},</if>
            <if test="isShow != null ">is_show = #{isShow},</if>
            <if test="headName != null  and headName != ''">head_name = #{headName},</if>
            <if test="headPhone != null  and headPhone != ''">head_phone = #{headPhone},</if>
            <if test="content != null  and content != ''">content = #{content},</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>
            <if test="version != null ">version = #{version},</if>
            <if test="deleteFlag != null ">delete_flag = #{deleteFlag},</if>
            <if test="roomId != null ">room_id = #{roomId},</if>
            <if test="area != null  and area != ''">area = #{area},</if>
            <if test="parkId != null  and parkId != ''">park_id = #{parkId},</if>
            <if test="buildingId != null  and buildingId != ''">building_id = #{buildingId},</if>
            <if test="tenantId != null  and tenantId != ''">tenant_id = #{tenantId},</if>
            <if test="buildId != null  and buildId != ''">build_id = #{buildId},</if>
        </trim>
        WHERE id = #{id}
    </update>

    <delete id="deleteShowroomById" parameterType="Long">
        DELETE FROM tb_showroom WHERE id = #{id}
    </delete>

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