<?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.ktg.iscs.mapper.IsUserWorkstationMapper">
    
    <resultMap type="IsUserWorkstation" id="IsUserWorkstationResult">
        <result property="userId"    column="user_id"    />
        <result property="workstationId"    column="workstation_id"    />
    </resultMap>

    <sql id="selectIsUserWorkstationVo">
        select user_id, workstation_id from is_user_workstation
    </sql>

    <select id="selectIsUserWorkstationList" parameterType="IsUserWorkstation" resultMap="IsUserWorkstationResult">
        <include refid="selectIsUserWorkstationVo"/>
        <where>  
        </where>
    </select>
    
    <select id="selectIsUserWorkstationByUserId" parameterType="Long" resultMap="IsUserWorkstationResult">
        <include refid="selectIsUserWorkstationVo"/>
        where user_id = #{userId}
    </select>
        
    <insert id="insertIsUserWorkstation" parameterType="IsUserWorkstation">
        insert into is_user_workstation
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="userId != null">user_id,</if>
            <if test="workstationId != null">workstation_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="userId != null">#{userId},</if>
            <if test="workstationId != null">#{workstationId},</if>
         </trim>
    </insert>

    <update id="updateIsUserWorkstation" parameterType="IsUserWorkstation">
        update is_user_workstation
        <trim prefix="SET" suffixOverrides=",">
            <if test="workstationId != null">workstation_id = #{workstationId},</if>
        </trim>
        where user_id = #{userId}
    </update>

    <delete id="deleteIsUserWorkstationByUserId" parameterType="Long">
        delete from is_user_workstation where user_id = #{userId}
    </delete>

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