<?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.DkFjMapper">
    
    <resultMap type="DkFj" id="DkFjResult">
        <result property="id"    column="id"    />
        <result property="dkId"    column="dk_id"    />
        <result property="fjName"    column="fj_name"    />
        <result property="path"    column="path"    />
        <result property="status"    column="status"    />
        <result property="grade"    column="grade"    />
        <result property="name"    column="name"    />

        <result property="type"    column="type"    />
        <result property="remark"    column="remark"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectDkFjVo">
        select id, dk_id, fj_name, path, status, grade,name, type, remark, create_time from dk_fj
    </sql>

    <select id="selectDkFjList" parameterType="DkFj" resultMap="DkFjResult">
        <include refid="selectDkFjVo"/>
        <where>  
            <if test="dkId != null "> and dk_id = #{dkId}</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="status != null  and status != ''"> and status = #{status}</if>
            <if test="grade != null  and grade != ''"> and grade = #{grade}</if>
            <if test="type != null  and type != ''"> and type = #{type}</if>
        </where>
    </select>
    
    <select id="selectDkFjById" parameterType="Long" resultMap="DkFjResult">
        <include refid="selectDkFjVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertDkFj" parameterType="DkFj" useGeneratedKeys="true" keyProperty="id">
        insert into dk_fj
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="dkId != null">dk_id,</if>
            <if test="fjName != null and fjName != ''">fj_name,</if>
            <if test="path != null">path,</if>
            <if test="status != null">status,</if>
            <if test="grade != null">grade,</if>
            <if test="name != null">name,</if>
            <if test="type != null">type,</if>
            <if test="remark != null">remark,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="dkId != null">#{dkId},</if>
            <if test="fjName != null and fjName != ''">#{fjName},</if>
            <if test="path != null">#{path},</if>
            <if test="status != null">#{status},</if>
            <if test="grade != null">#{grade},</if>
            <if test="name != null">#{name},</if>
            <if test="type != null">#{type},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateDkFj" parameterType="DkFj">
        update dk_fj
        <trim prefix="SET" suffixOverrides=",">
            <if test="dkId != null">dk_id = #{dkId},</if>
            <if test="fjName != null and fjName != ''">fj_name = #{fjName},</if>
            <if test="path != null">path = #{path},</if>
            <if test="status != null">status = #{status},</if>
            <if test="grade != null">grade = #{grade},</if>
            <if test="name != null">name = #{name},</if>
            <if test="type != null">type = #{type},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteDkFjById" parameterType="Long">
        delete from dk_fj where id = #{id}
    </delete>

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