<?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.system.mapper.VideoCallMapper">
    
    <resultMap type="VideoCall" id="VideoCallResult">
        <result property="id"    column="id"    />
        <result property="userId"    column="user_id"    />
        <result property="callId"    column="call_id"    />
        <result property="content"    column="content"    />
        <result property="answer"    column="answer"    />
    </resultMap>

    <sql id="selectVideoCallVo">
        select id, user_id,call_id, content,answer from video_call
    </sql>

    <select id="selectVideoCallList" parameterType="VideoCall" resultMap="VideoCallResult">
        <include refid="selectVideoCallVo"/>
        <where>  
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="callId != null "> and call_id = #{callId}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="answer != null  and answer != ''"> and answer = #{answer}</if>
        </where>
    </select>
    
    <select id="selectVideoCallById" parameterType="Long" resultMap="VideoCallResult">
        <include refid="selectVideoCallVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertVideoCall" parameterType="VideoCall" useGeneratedKeys="true" keyProperty="id">
        insert into video_call
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="userId != null">user_id,</if>
            <if test="callId != null">call_id,</if>
            <if test="content != null">content,</if>
            <if test="answer != null">answer,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="userId != null">#{userId},</if>
            <if test="callId != null">#{callId},</if>
            <if test="content != null">#{content},</if>
            <if test="answer != null">#{answer},</if>
         </trim>
    </insert>

    <update id="updateVideoCall" parameterType="VideoCall">
        update video_call
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null">user_id = #{userId},</if>
            <if test="callId != null">call_id = #{callId},</if>
            <if test="content != null">content = #{content},</if>
            <if test="answer != null">answer = #{answer},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteVideoCallById" parameterType="Long">
        delete from video_call where id = #{id}
    </delete>

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