<?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.stureg.mapper.SrsStuDormMapper">
    
    <resultMap type="SrsStuDorm" id="SrsStuDormResult">
        <result property="id"    column="id"    />
        <result property="stuNo"    column="stu_no"    />
        <result property="roomNo"    column="room_no"    />
    </resultMap>

    <sql id="selectSrsStuDormVo">
        select id, stu_no, room_no from srs_stu_dorm
    </sql>

    <select id="selectSrsStuDormList" parameterType="SrsStuDorm" resultMap="SrsStuDormResult">
        <include refid="selectSrsStuDormVo"/>
        <where>  
            <if test="stuNo != null  and stuNo != ''"> and stu_no = #{stuNo}</if>
            <if test="roomNo != null "> and room_no = #{roomNo}</if>
        </where>
    </select>
    
    <select id="selectSrsStuDormById" parameterType="Long" resultMap="SrsStuDormResult">
        <include refid="selectSrsStuDormVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertSrsStuDorm" parameterType="SrsStuDorm">
        insert into srs_stu_dorm
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="stuNo != null">stu_no,</if>
            <if test="roomNo != null">room_no,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="stuNo != null">#{stuNo},</if>
            <if test="roomNo != null">#{roomNo},</if>
         </trim>
    </insert>

    <update id="updateSrsStuDorm" parameterType="SrsStuDorm">
        update srs_stu_dorm
        <trim prefix="SET" suffixOverrides=",">
            <if test="stuNo != null">stu_no = #{stuNo},</if>
            <if test="roomNo != null">room_no = #{roomNo},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSrsStuDormById" parameterType="Long">
        delete from srs_stu_dorm where id = #{id}
    </delete>

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