<?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.RoomServeMapper">
    
    <resultMap type="com.ics.admin.domain.meeting.RoomServe" id="RoomServeResult">
        <result property="id"    column="id"    />
        <result property="serveName"    column="serve_name"    />
        <result property="serveType"    column="serve_type"    />
        <result property="serveTime"    column="serve_time"    />
        <result property="remake"    column="remake"    />
        <result property="pic"    column="pic"    />
        <result property="money"    column="money"    />
        <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"    />
    </resultMap>

    <sql id="selectRoomServeVo">
        SELECT id, serve_name, serve_type, serve_time, remake,money, create_by, create_time, update_by, update_time, version, delete_flag,pic,content FROM tb_room_serve
    </sql>

    <select id="selectRoomServeList" parameterType="RoomServe" resultMap="RoomServeResult">
        <include refid="selectRoomServeVo"/>
        <where>  
            <if test="serveName != null  and serveName != ''"> AND serve_name LIKE CONCAT('%', #{serveName}, '%')</if>
        </where>
    </select>
    
    <select id="selectRoomServeById" parameterType="Long" resultMap="RoomServeResult">
        <include refid="selectRoomServeVo"/>
        WHERE id = #{id}
    </select>
        
    <insert id="insertRoomServe" parameterType="RoomServe" useGeneratedKeys="true" keyProperty="id">
        INSERT INTO tb_room_serve
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="serveName != null  and serveName != ''">serve_name,</if>
            <if test="serveType != null ">serve_type,</if>
            <if test="serveTime != null  and serveTime != ''">serve_time,</if>
            <if test="remake != null  and remake != ''">remake,</if>
            <if test="createBy != null  and createBy != ''">create_by,</if>
            <if test="money != null  and money != ''">money,</if>
            <if test="content != null  and content != ''">content,</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="pic != null ">pic,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="serveName != null  and serveName != ''">#{serveName},</if>
            <if test="serveType != null ">#{serveType},</if>
            <if test="serveTime != null  and serveTime != ''">#{serveTime},</if>
            <if test="remake != null  and remake != ''">#{remake},</if>
            <if test="content != null  and content != ''">#{content},</if>
            <if test="money != null  and money != ''">#{money},</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="pic != null ">#{pic},</if>
         </trim>
    </insert>

    <update id="updateRoomServe" parameterType="RoomServe">
        UPDATE tb_room_serve
        <trim prefix="SET" suffixOverrides=",">
            <if test="serveName != null  and serveName != ''">serve_name = #{serveName},</if>
            <if test="serveType != null ">serve_type = #{serveType},</if>
            <if test="serveTime != null  and serveTime != ''">serve_time = #{serveTime},</if>
            <if test="remake != null  and remake != ''">remake = #{remake},</if>
            <if test="createBy != null  and createBy != ''">create_by = #{createBy},</if>
            <if test="money != null  and money != ''">money = #{money},</if>
            <if test="content != null  and content != ''">content = #{content},</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="pic != null ">pic = #{pic},</if>
        </trim>
        WHERE id = #{id}
    </update>

    <delete id="deleteRoomServeById" parameterType="Long">
        DELETE FROM tb_room_serve WHERE id = #{id}
    </delete>

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