<?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.fs.qw.mapper.QwIpadServerUserMapper">

    <resultMap type="QwIpadServerUser" id="QwIpadServerUserResult">
        <result property="id"    column="id"    />
        <result property="serverId"    column="server_id"    />
        <result property="qwUserId"    column="qw_user_id"    />
        <result property="companyId"    column="company_id"    />
        <result property="companyUserId"    column="company_user_id"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectQwIpadServerUserVo">
        select id, server_id, qw_user_id, company_id, company_user_id, create_time from qw_ipad_server_user
    </sql>

    <select id="selectQwIpadServerUserList" parameterType="QwIpadServerUser" resultMap="QwIpadServerUserResult">
        <include refid="selectQwIpadServerUserVo"/>
        <where>
            <if test="serverId != null "> and server_id = #{serverId}</if>
            <if test="qwUserId != null "> and qw_user_id = #{qwUserId}</if>
            <if test="companyId != null "> and company_id = #{companyId}</if>
            <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
        </where>
    </select>

    <select id="selectQwIpadServerUserById" parameterType="Long" resultMap="QwIpadServerUserResult">
        <include refid="selectQwIpadServerUserVo"/>
        where id = #{id}
    </select>

    <insert id="insertQwIpadServerUser" parameterType="QwIpadServerUser" useGeneratedKeys="true" keyProperty="id">
        insert into qw_ipad_server_user
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="serverId != null">server_id,</if>
            <if test="qwUserId != null">qw_user_id,</if>
            <if test="companyId != null">company_id,</if>
            <if test="companyUserId != null">company_user_id,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="serverId != null">#{serverId},</if>
            <if test="qwUserId != null">#{qwUserId},</if>
            <if test="companyId != null">#{companyId},</if>
            <if test="companyUserId != null">#{companyUserId},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateQwIpadServerUser" parameterType="QwIpadServerUser">
        update qw_ipad_server_user
        <trim prefix="SET" suffixOverrides=",">
            <if test="serverId != null">server_id = #{serverId},</if>
            <if test="qwUserId != null">qw_user_id = #{qwUserId},</if>
            <if test="companyId != null">company_id = #{companyId},</if>
            <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteQwIpadServerUserById" parameterType="Long">
        delete from qw_ipad_server_user where id = #{id}
    </delete>

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