<?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.srs.routine.mapper.RtFuRoomMapper">

    <resultMap type="RtFuRoom" id="RtFuRoomResult">
        <result property="id"    column="id"    />
        <result property="roNo"    column="ro_no"    />
        <result property="roomName"    column="room_name"    />
        <result property="roomMatter"    column="room_matter"    />
        <result property="roomRule"    column="room_rule"    />
        <result property="roomInfo"    column="room_info"    />
        <result property="roomPurp"    column="room_purp"    />
        <result property="status"    column="status"    />
        <result property="roomCapacity"    column="room_capacity"    />
        <result property="roomCreatetime"    column="room_createTime"    />
        <result property="roomUptime"    column="room_upTime"    />
        <result property="roomUpuser"    column="room_upuser"    />
        <result property="roomUser"    column="room_user"    />
        <result property="roomDepar"    column="room_depar"    />
    </resultMap>
    <resultMap type="RtFuRoomVo" id="RtFuRoomResultVo">
        <result property="id"    column="id"    />
        <result property="roNo"    column="ro_no"    />
        <result property="roomName"    column="room_name"    />
        <result property="roomMatter"    column="room_matter"    />
<!--        <result property="roomRule"    column="room_rule"    />-->
        <result property="roomInfo"    column="room_info"    />
        <result property="roomPurp"    column="room_purp"    />
        <result property="status"    column="status"    />
        <result property="roomCapacity"    column="room_capacity"    />
    </resultMap>

    <sql id="selectRtFuRoomVo">
        select id, ro_no, room_name, room_matter, room_rule, room_info, room_purp, status, room_capacity, room_createTime, room_upTime, room_upuser, room_user, room_depar from rt_fu_room
    </sql>

    <select id="selectRtFuRoomLists" resultType="com.srs.routine.domain.vo.RtFuRoomVo">
        SELECT id,ro_no,room_name,room_matter,room_rule,room_info,room_purp,status,room_capacity,room_createTime,room_depar FROM rt_fu_room
        <where>
            <if test="roNo != null  and roNo != ''"> and ro_no = #{roNo}</if>
            <if test="roomName != null  and roomName != ''"> and room_name like concat('%', #{roomName}, '%')</if>
            <if test="roomMatter != null  and roomMatter != ''"> and room_matter = #{roomMatter}</if>
            <if test="roomInfo != null  and roomInfo != ''"> and room_info = #{roomInfo}</if>
            <if test="roomPurp != null  and roomPurp != ''"> and room_purp = #{roomPurp}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="roomCapacity != null  and roomCapacity != ''"> and room_capacity = #{roomCapacity}</if>
        </where>
        ORDER BY room_createTime Desc,
        room_depar Asc
    </select>

    <select id="selectRtFuRoomList" parameterType="RtFuRoom" resultMap="RtFuRoomResult">
        SELECT id,ro_no,room_rule,room_name,room_info,room_capacity,room_matter,status,room_purp,room_createTime,room_user,room_upTime,room_upuser,room_depar FROM rt_fu_room
        <where>
            <if test="roNo != null  and roNo != ''"> and ro_no = #{roNo}</if>
            <if test="roomName != null  and roomName != ''"> and room_name like concat('%', #{roomName}, '%')</if>
            <if test="roomMatter != null  and roomMatter != ''"> and room_matter = #{roomMatter}</if>
            <if test="roomRule != null  and roomRule != ''"> and room_rule = #{roomRule}</if>
            <if test="roomInfo != null  and roomInfo != ''"> and room_info = #{roomInfo}</if>
            <if test="roomPurp != null  and roomPurp != ''"> and room_purp = #{roomPurp}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="roomCapacity != null  and roomCapacity != ''"> and room_capacity = #{roomCapacity}</if>
            <if test="roWeek != null  and roWeek != ''"> and ro_week = #{roWeek}</if>
            <if test="roWeekTime != null  and roWeekTime != ''"> and ro_weekTime = #{roWeekTime}</if>
            <if test="roomCreatetime != null "> and room_createTime = #{roomCreatetime}</if>
            <if test="roomUser != null  and roomUser != ''"> and room_user = #{roomUser}</if>
            <if test="roomDepar != null  and roomDepar != ''"> and room_depar = #{roomDepar}</if>
        </where>
        ORDER BY room_createTime Desc,
        room_depar Asc
    </select>

    <select id="selectRtFuRoomByRoNo" parameterType="string" resultType="com.srs.routine.domain.vo.RtFuResSoltVo">
        SELECT id,ro_no,room_name,room_capacity,room_rule,room_matter,status,room_info,room_createTime,room_user,room_upTime,room_upuser
        FROM rt_fu_room
        where ro_no =#{ro_no}
    </select>

    <select id="getFuRoomByRoNo" parameterType="string" resultMap="RtFuRoomResult">
        SELECT id,ro_no,room_name,room_capacity,room_rule,room_matter,status,room_info,room_createTime,room_user,room_upTime,room_upuser
        FROM rt_fu_room
        where ro_no =#{ro_no}
    </select>

    <select id="selectRtFuRoomById" parameterType="Long" resultMap="RtFuRoomResult">
        SELECT id,ro_no,room_name,room_rule,room_capacity,room_matter,status,room_info,room_createTime,room_user,room_upTime,room_upuser
        FROM rt_fu_room
        where id = #{id}
    </select>
    <select id="selectRtFuRoomByIds" parameterType="Long" resultType="com.srs.routine.domain.vo.RtFuRoomVo">
        SELECT id,ro_no,room_name,room_rule,room_capacity,room_purp,room_matter,status,room_info,room_createTime,room_user,room_upTime,room_upuser
        FROM rt_fu_room
        where id = #{id}
    </select>
<!--    搜索框通过房间名字-->
    <select id="selectRtFuRoomByroom" parameterType="string" resultType="com.srs.routine.domain.vo.RtFuRoomVo">
        SELECT id,ro_no,ro_no,room_name,room_rule,room_capacity,room_purp,room_matter,status,room_info,room_createTime,room_user,room_upTime,room_upuser
        FROM rt_fu_room
        where room_name like concat('%', #{room_name}, '%')
    </select>

<!--    新增功能房-->
    <insert id="insertRtFuRoom" parameterType="RtFuRoom" useGeneratedKeys="true" keyProperty="id">
        insert into rt_fu_room
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="roNo != null">ro_no,</if>
            <if test="roomName != null">room_name,</if>
            <if test="roomMatter != null">room_matter,</if>
            <if test="roomRule != null">room_rule,</if>
            <if test="roomInfo != null">room_info,</if>
            <if test="roomPurp != null">room_purp,</if>
            <if test="status != null">status,</if>
            <if test="roomCapacity != null">room_capacity,</if>
            <if test="roomCreatetime != null">room_createTime,</if>
            <if test="roomUptime != null">room_upTime,</if>
            <if test="roomUpuser != null">room_upuser,</if>
            <if test="roomUser != null">room_user,</if>
            <if test="roomDepar != null">room_depar,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="roNo != null">#{roNo},</if>
            <if test="roomName != null">#{roomName},</if>
            <if test="roomMatter != null">#{roomMatter},</if>
            <if test="roomRule != null">#{roomRule},</if>
            <if test="roomInfo != null">#{roomInfo},</if>
            <if test="roomPurp != null">#{roomPurp},</if>
            <if test="status != null">#{status},</if>
            <if test="roomCapacity != null">#{roomCapacity},</if>
            <if test="roomCreatetime != null">#{roomCreatetime},</if>
            <if test="roomUptime != null">#{roomUptime},</if>
            <if test="roomUpuser != null">#{roomUpuser},</if>
            <if test="roomUser != null">#{roomUser},</if>
            <if test="roomDepar != null">#{roomDepar},</if>
        </trim>
    </insert>


    <update id="updateRtFuRoom" parameterType="RtFuRoom">
        update rt_fu_room
        <trim prefix="SET" suffixOverrides=",">
            <if test="roNo != null">ro_no = #{roNo},</if>
            <if test="roomName != null">room_name = #{roomName},</if>
            <if test="roomMatter != null">room_matter = #{roomMatter},</if>
            <if test="roomRule != null">room_rule = #{roomRule},</if>
            <if test="roomInfo != null">room_info = #{roomInfo},</if>
            <if test="roomPurp != null">room_purp = #{roomPurp},</if>
            <if test="status != null">status = #{status},</if>
            <if test="roomCapacity != null">room_capacity = #{roomCapacity},</if>
            <if test="roomCreatetime != null">room_createTime = #{roomCreatetime},</if>
            <if test="roomUptime != null">room_upTime = #{roomUptime},</if>
            <if test="roomUpuser != null">room_upuser = #{roomUpuser},</if>
            <if test="roomUser != null">room_user = #{roomUser},</if>
            <if test="roomDepar != null">room_depar = #{roomDepar},</if>
        </trim>
        where id = #{id}
    </update>

    <update id="updateRtfuSta" parameterType="rtFuRoom">
            update rt_fu_room
        <trim prefix="SET" suffixOverrides=",">
            <if test="roNo != null">ro_no = #{roNo},</if>
            <if test="roomName != null">room_name = #{roomName},</if>
            <if test="roomMatter != null">room_matter = #{roomMatter},</if>
            <if test="roomRule != null">room_rule = #{roomRule},</if>
            <if test="roomInfo != null">room_info = #{roomInfo},</if>
            <if test="roomPurp != null">room_purp = #{roomPurp},</if>
            <if test="status != null">status = #{status},</if>
            <if test="roomCapacity != null">room_capacity = #{roomCapacity},</if>
            <if test="roomCreatetime != null">room_createTime = #{roomCreatetime},</if>
            <if test="roomUptime != null">room_upTime = #{roomUptime},</if>
            <if test="roomUpuser != null">room_upuser = #{roomUpuser},</if>
            <if test="roomUser != null">room_user = #{roomUser},</if>
            <if test="roomDepar != null">room_depar = #{roomDepar},</if>
        </trim>
            where id=#{id}
    </update>

    <delete id="deleteRtFuRoomById" parameterType="Long">
        delete from rt_fu_room where id = #{id}
    </delete>

    <delete id="deleteRtFuRoomByIds" parameterType="String">
        delete from rt_fu_room where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>
