<?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.projectV2.ZsyzFjMapper">
    
    <resultMap type="ZsyzFj" id="ZsyzFjResult">
        <result property="id"    column="id"    />
        <result property="xmId"    column="xm_id"    />
        <result property="xmbh"    column="xmbh"    />
        <result property="sourceId"    column="source_id"    />
        <result property="fjName"    column="fj_name"    />
        <result property="path"    column="path"    />
        <result property="type"    column="type"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectZsyzFjVo">
        select id, xm_id, xmbh, source_id, fj_name, path, type, remark from zsyz_fj
    </sql>

    <select id="selectZsyzFjList" parameterType="ZsyzFj" resultMap="ZsyzFjResult">
        <include refid="selectZsyzFjVo"/>
        <where>
            <if test="xmId != null "> and xm_id = #{xmId}</if>
            <if test="xmbh != null  and xmbh != ''"> and xmbh = #{xmbh}</if>
            <if test="sourceId != null "> and source_id = #{sourceId}</if>
            <if test="fjName != null  and fjName != ''"> and fj_name like concat('%', #{fjName}, '%')</if>
            <if test="path != null  and path != ''"> and path = #{path}</if>
            <if test="type != null  and type != ''"> and type = #{type}</if>
        </where>
    </select>
    
    <select id="selectZsyzFjById" parameterType="Long" resultMap="ZsyzFjResult">
        <include refid="selectZsyzFjVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertZsyzFj" parameterType="ZsyzFj" useGeneratedKeys="true" keyProperty="id">
        insert into zsyz_fj
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="xmId != null">xm_id,</if>
            <if test="xmbh != null">xmbh,</if>
            <if test="sourceId != null">source_id,</if>
            <if test="fjName != null and fjName != ''">fj_name,</if>
            <if test="path != null">path,</if>
            <if test="type != null">type,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="xmId != null">#{xmId},</if>
            <if test="xmbh != null">#{xmbh},</if>
            <if test="sourceId != null">#{sourceId},</if>
            <if test="fjName != null and fjName != ''">#{fjName},</if>
            <if test="path != null">#{path},</if>
            <if test="type != null">#{type},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateZsyzFj" parameterType="ZsyzFj">
        update zsyz_fj
        <trim prefix="SET" suffixOverrides=",">
            <if test="xmId != null">xm_id = #{xmId},</if>
            <if test="xmbh != null">xmbh = #{xmbh},</if>
            <if test="sourceId != null">source_id = #{sourceId},</if>
            <if test="fjName != null and fjName != ''">fj_name = #{fjName},</if>
            <if test="path != null">path = #{path},</if>
            <if test="type != null">type = #{type},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteZsyzFjById" parameterType="Long">
        delete from zsyz_fj where id = #{id}
    </delete>

    <delete id="deleteZsyzFjByIds" parameterType="String">
        delete from zsyz_fj where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <delete id="deleteZsyzFjBySourceId" parameterType="ZsyzFj">
        delete from zsyz_fj where source_id = #{sourceId} and type = #{type}
    </delete>
</mapper>