<?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.RecordLeaveFjMapper">
    
    <resultMap type="RecordLeaveFj" id="RecordLeaveFjResult">
        <result property="id"    column="id"    />
        <result property="recordId"    column="record_id"    />
        <result property="name"    column="name"    />
        <result property="url"    column="url"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectRecordLeaveFjVo">
        select id, record_id, name, url, remark from record_leave_fj
    </sql>

    <select id="selectRecordLeaveFjList" parameterType="RecordLeaveFj" resultMap="RecordLeaveFjResult">
        <include refid="selectRecordLeaveFjVo"/>
        <where>  
            <if test="recordId != null  and recordId != ''"> and record_id = #{recordId}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="url != null  and url != ''"> and url = #{url}</if>
        </where>
    </select>
    
    <select id="selectRecordLeaveFjById" parameterType="Long" resultMap="RecordLeaveFjResult">
        <include refid="selectRecordLeaveFjVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertRecordLeaveFj" parameterType="RecordLeaveFj" useGeneratedKeys="true" keyProperty="id">
        insert into record_leave_fj
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="recordId != null">record_id,</if>
            <if test="name != null and name != ''">name,</if>
            <if test="url != null">url,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="recordId != null">#{recordId},</if>
            <if test="name != null and name != ''">#{name},</if>
            <if test="url != null">#{url},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateRecordLeaveFj" parameterType="RecordLeaveFj">
        update record_leave_fj
        <trim prefix="SET" suffixOverrides=",">
            <if test="recordId != null">record_id = #{recordId},</if>
            <if test="name != null and name != ''">name = #{name},</if>
            <if test="url != null">url = #{url},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteRecordLeaveFjById" parameterType="Long">
        delete from record_leave_fj where id = #{id}
    </delete>

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