<?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.DoumuProductFjMapper">
    
    <resultMap type="DoumuProductFj" id="DoumuProductFjResult">
        <result property="fiId"    column="fi_id"    />
        <result property="productId"    column="product_id"    />
        <result property="fjName"    column="fj_name"    />
        <result property="path"    column="path"    />
        <result property="type"    column="type"    />
        <result property="module"    column="module"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectDoumuProductFjVo">
        select fi_id, product_id, fj_name, path,type,module, remark from doumu_product_fj
    </sql>

    <select id="selectDoumuProductFjList" parameterType="DoumuProductFj" resultMap="DoumuProductFjResult">
        <include refid="selectDoumuProductFjVo"/>
        <where>  
            <if test="productId != null "> and product_id = #{productId}</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="module != null  and module != ''"> and module = #{module}</if>
        </where>
    </select>
    
    <select id="selectDoumuProductFjByFiId" parameterType="Long" resultMap="DoumuProductFjResult">
        <include refid="selectDoumuProductFjVo"/>
        where fi_id = #{fiId}
    </select>
        
    <insert id="insertDoumuProductFj" parameterType="DoumuProductFj" useGeneratedKeys="true" keyProperty="fiId">
        insert into doumu_product_fj
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="productId != null">product_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="module != null">module,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="productId != null">#{productId},</if>
            <if test="fjName != null and fjName != ''">#{fjName},</if>
            <if test="path != null">#{path},</if>
            <if test="type != null">#{type},</if>
            <if test="module != null">#{module},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateDoumuProductFj" parameterType="DoumuProductFj">
        update doumu_product_fj
        <trim prefix="SET" suffixOverrides=",">
            <if test="productId != null">product_id = #{productId},</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="module != null">module = #{module},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where fi_id = #{fiId}
    </update>

    <delete id="deleteDoumuProductFjByFiId" parameterType="Long">
        delete from doumu_product_fj where fi_id = #{fiId}
    </delete>

    <delete id="deleteDoumuProductFjByFiIds" parameterType="String">
        delete from doumu_product_fj where fi_id in
        <foreach item="fiId" collection="array" open="(" separator="," close=")">
            #{fiId}
        </foreach>
    </delete>
    <delete id="deleteDoumuProductFjByProductId">
        delete from doumu_product_fj
        where product_id = #{productId}
        <if test="module != null  and module != ''"> and module = #{module}</if>
    </delete>
</mapper>