<?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.SysUserConferenceMapper">
    
    <resultMap type="SysUserConference" id="SysUserConferenceResult">
        <result property="conferenceId"    column="conference_id"    />
        <result property="userId"    column="user_id"    />
        <result property="idCard"    column="id_card"    />
        <result property="realName"    column="real_name"    />
        <result property="loanApplicationId"    column="loan_application_id"    />
        <result property="loanApplicationNumber"    column="loan_application_number"    />
        <result property="isConference"    column="is_conference"    />
        <result property="reason"    column="reason"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectSysUserConferenceVo">
        select conference_id, user_id, id_card, real_name, loan_application_id, loan_application_number, is_conference, reason, create_by, create_time, update_by, update_time, remark from sys_user_conference
    </sql>

    <select id="selectSysUserConferenceList" parameterType="SysUserConference" resultMap="SysUserConferenceResult">
        <include refid="selectSysUserConferenceVo"/>
        <where>  
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="idCard != null  and idCard != ''"> and id_card = #{idCard}</if>
            <if test="realName != null  and realName != ''"> and real_name like concat('%', #{realName}, '%')</if>
            <if test="loanApplicationId != null "> and loan_application_id = #{loanApplicationId}</if>
            <if test="loanApplicationNumber != null  and loanApplicationNumber != ''"> and loan_application_number = #{loanApplicationNumber}</if>
            <if test="isConference != null  and isConference != ''"> and is_conference = #{isConference}</if>
            <if test="reason != null  and reason != ''"> and reason = #{reason}</if>
        </where>
        order by create_time
    </select>
    
    <select id="selectSysUserConferenceByConferenceId" parameterType="Long" resultMap="SysUserConferenceResult">
        <include refid="selectSysUserConferenceVo"/>
        where conference_id = #{conferenceId}
    </select>
        
    <insert id="insertSysUserConference" parameterType="SysUserConference" useGeneratedKeys="true" keyProperty="conferenceId">
        insert into sys_user_conference
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="userId != null">user_id,</if>
            <if test="idCard != null">id_card,</if>
            <if test="realName != null and realName != ''">real_name,</if>
            <if test="loanApplicationId != null">loan_application_id,</if>
            <if test="loanApplicationNumber != null">loan_application_number,</if>
            <if test="isConference != null">is_conference,</if>
            <if test="reason != null">reason,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="userId != null">#{userId},</if>
            <if test="idCard != null">#{idCard},</if>
            <if test="realName != null and realName != ''">#{realName},</if>
            <if test="loanApplicationId != null">#{loanApplicationId},</if>
            <if test="loanApplicationNumber != null">#{loanApplicationNumber},</if>
            <if test="isConference != null">#{isConference},</if>
            <if test="reason != null">#{reason},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>
    <insert id="batchSysUserConference">
        insert into sys_user_conference(user_id, id_card, real_name, loan_application_id, loan_application_number, is_conference, reason, create_by, create_time, update_by, update_time, remark) values
        <foreach item="item" index="index" collection="list" separator=",">
            (#{item.userId},#{item.idCard},#{item.realName},#{item.loanApplicationId},#{item.loanApplicationNumber},#{item.isConference},#{item.reason},#{item.createBy},sysdate(),#{item.updateBy},#{item.updateTime},#{item.remark})
        </foreach>
    </insert>

    <update id="updateSysUserConference" parameterType="SysUserConference">
        update sys_user_conference
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null">user_id = #{userId},</if>
            <if test="idCard != null">id_card = #{idCard},</if>
            <if test="realName != null and realName != ''">real_name = #{realName},</if>
            <if test="loanApplicationId != null">loan_application_id = #{loanApplicationId},</if>
            <if test="loanApplicationNumber != null">loan_application_number = #{loanApplicationNumber},</if>
            <if test="isConference != null">is_conference = #{isConference},</if>
            <if test="reason != null">reason = #{reason},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where conference_id = #{conferenceId}
    </update>

    <delete id="deleteSysUserConferenceByConferenceId" parameterType="Long">
        delete from sys_user_conference where conference_id = #{conferenceId}
    </delete>

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