<?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.ruoyi.call.mapper.ArdCallSessionUserMapper"> 
 | 
  
 | 
    <resultMap type="ArdCallSessionUser" id="ArdCallSessionUserResult"> 
 | 
        <result property="id" column="id"/> 
 | 
        <result property="sessionId" column="session_id"/> 
 | 
        <result property="type" column="type"/> 
 | 
        <result property="userId" column="user_id"/> 
 | 
        <result property="targetId" column="target_id"/> 
 | 
    </resultMap> 
 | 
  
 | 
    <sql id="selectArdCallSessionUserVo"> 
 | 
        select id, session_id, type, user_id,target_id 
 | 
        from ard_call_session_user 
 | 
    </sql> 
 | 
  
 | 
    <select id="selectArdCallSessionUserList" parameterType="ArdCallSessionUser" resultMap="ArdCallSessionUserResult"> 
 | 
        <include refid="selectArdCallSessionUserVo"/> 
 | 
        <where> 
 | 
            <if test="sessionId != null  and sessionId != ''">and session_id = #{sessionId}</if> 
 | 
            <if test="type != null  and type != ''">and type = #{type}</if> 
 | 
            <if test="userId != null  and userId != ''">and user_id = #{userId}</if> 
 | 
            <if test="targetId != null  and targetId != ''">and target_id = #{targetId}</if> 
 | 
        </where> 
 | 
    </select> 
 | 
  
 | 
    <select id="selectArdCallSessionUserBySesionId" parameterType="String" resultMap="ArdCallSessionUserResult"> 
 | 
        <include refid="selectArdCallSessionUserVo"/> 
 | 
        where session_id = #{sessionId} and user_id = #{userId} 
 | 
    </select> 
 | 
    <select id="selectArdCallSessionUserById" parameterType="String" resultMap="ArdCallSessionUserResult"> 
 | 
        <include refid="selectArdCallSessionUserVo"/> 
 | 
        where id = #{id} 
 | 
    </select> 
 | 
    <insert id="insertArdCallSessionUser" parameterType="ArdCallSessionUser"> 
 | 
        insert into ard_call_session_user 
 | 
        <trim prefix="(" suffix=")" suffixOverrides=","> 
 | 
            <if test="id != null">id,</if> 
 | 
            <if test="sessionId != null">session_id,</if> 
 | 
            <if test="type != null">type,</if> 
 | 
            <if test="userId != null">user_id,</if> 
 | 
            <if test="targetId != null">target_id,</if> 
 | 
        </trim> 
 | 
        <trim prefix="values (" suffix=")" suffixOverrides=","> 
 | 
            <if test="id != null">#{id},</if> 
 | 
            <if test="sessionId != null">#{sessionId},</if> 
 | 
            <if test="type != null">#{type},</if> 
 | 
            <if test="userId != null">#{userId},</if> 
 | 
            <if test="targetId != null">#{targetId},</if> 
 | 
        </trim> 
 | 
    </insert> 
 | 
  
 | 
    <update id="updateArdCallSessionUser" parameterType="ArdCallSessionUser"> 
 | 
        update ard_call_session_user 
 | 
        <trim prefix="SET" suffixOverrides=","> 
 | 
            <if test="sessionId != null">session_id = #{sessionId},</if> 
 | 
            <if test="type != null">type = #{type},</if> 
 | 
            <if test="userId != null">user_id = #{userId},</if> 
 | 
            <if test="targetId != null">target_id = #{targetId},</if> 
 | 
        </trim> 
 | 
        where id = #{id} 
 | 
    </update> 
 | 
  
 | 
    <delete id="deleteArdCallSessionUserById" parameterType="String"> 
 | 
        delete 
 | 
        from ard_call_session_user 
 | 
        where id = #{id} 
 | 
    </delete> 
 | 
  
 | 
    <delete id="deleteArdCallSessionUserByIds" parameterType="String"> 
 | 
        delete from ard_call_session_user where id in 
 | 
        <foreach item="id" collection="array" open="(" separator="," close=")"> 
 | 
            #{id} 
 | 
        </foreach> 
 | 
    </delete> 
 | 
    <select id="getSessionId" parameterType="String" resultType="String"> 
 | 
        select session_id 
 | 
        from ard_call_session_user 
 | 
        where user_id = #{userId} 
 | 
          and target_id = #{targetId} 
 | 
          and type = #{type} 
 | 
    </select> 
 | 
    <select id="getGroupSessionId" parameterType="String" resultType="String"> 
 | 
        select session_id 
 | 
        from ard_call_session_user 
 | 
        where target_id = #{targetId} 
 | 
        limit 1 
 | 
    </select> 
 | 
    <delete id="deleteArdCallSessionUserBySessionId" parameterType="String"> 
 | 
        delete 
 | 
        from ard_call_session_user 
 | 
        where session_id = #{sessionId} 
 | 
    </delete> 
 | 
</mapper> 
 |