<?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.interfaces.mapper.MdModelFileMapper">

    <resultMap type="com.ruoyi.interfaces.domain.MdModelFile" id="MdModelFileResult">
        <result property="fileid"    column="fileid"    />
        <result property="mdid"    column="mdid"    />
        <result property="filename"    column="filename"    />
        <result property="relativePath"    column="relativePath"    />
        <result property="isMainLibrary"    column="isMainLibrary"    />
        <result property="isDocument"    column="isDocument"    />
        <result property="signature"    column="signature"    />
        <result property="createBy"    column="createBy"    />
        <result property="modifyBy"    column="modifyBy"    />
    </resultMap>

    <sql id="selectMdModelFileVo">
        select fileid, mdid, filename, relativePath, isMainLibrary, isDocument, signature, createBy, modifyBy from md_model_file
    </sql>

    <select id="selectMdModelFileList" parameterType="com.ruoyi.interfaces.domain.MdModelFile" resultMap="MdModelFileResult">
        <include refid="selectMdModelFileVo"/>
        <where>
            <if test="mdid != null  and mdid != ''"> and mdid = #{mdid}</if>
            <if test="filename != null  and filename != ''"> and filename like concat('%', #{filename}, '%')</if>
            <if test="relativePath != null  and relativePath != ''"> and relativePath = #{relativePath}</if>
            <if test="isMainLibrary != null  and isMainLibrary != ''"> and isMainLibrary = #{isMainLibrary}</if>
            <if test="isDocument != null "> and isDocument = #{isDocument}</if>
            <if test="signature != null  and signature != ''"> and signature = #{signature}</if>
            <if test="createBy != null "> and createBy = #{createBy}</if>
            <if test="modifyBy != null "> and modifyBy = #{modifyBy}</if>
        </where>
    </select>

    <select id="selectMdModelFileByFileid" parameterType="String" resultMap="MdModelFileResult">
        <include refid="selectMdModelFileVo"/>
        where fileid = #{fileid}
    </select>

    <insert id="insertMdModelFile" parameterType="com.ruoyi.interfaces.domain.MdModelFile">
        insert into md_model_file
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="fileid != null">fileid,</if>
            <if test="mdid != null">mdid,</if>
            <if test="filename != null">filename,</if>
            <if test="relativePath != null">relativePath,</if>
            <if test="isMainLibrary != null">isMainLibrary,</if>
            <if test="isDocument != null">isDocument,</if>
            <if test="signature != null">signature,</if>
            <if test="createBy != null">createBy,</if>
            <if test="modifyBy != null">modifyBy,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="fileid != null">#{fileid},</if>
            <if test="mdid != null">#{mdid},</if>
            <if test="filename != null">#{filename},</if>
            <if test="relativePath != null">#{relativePath},</if>
            <if test="isMainLibrary != null">#{isMainLibrary},</if>
            <if test="isDocument != null">#{isDocument},</if>
            <if test="signature != null">#{signature},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="modifyBy != null">#{modifyBy},</if>
        </trim>
    </insert>

    <update id="updateMdModelFile" parameterType="com.ruoyi.interfaces.domain.MdModelFile">
        update md_model_file
        <trim prefix="SET" suffixOverrides=",">
            <if test="mdid != null">mdid = #{mdid},</if>
            <if test="filename != null">filename = #{filename},</if>
            <if test="relativePath != null">relativePath = #{relativePath},</if>
            <if test="isMainLibrary != null">isMainLibrary = #{isMainLibrary},</if>
            <if test="isDocument != null">isDocument = #{isDocument},</if>
            <if test="signature != null">signature = #{signature},</if>
            <if test="createBy != null">createBy = #{createBy},</if>
            <if test="modifyBy != null">modifyBy = #{modifyBy},</if>
        </trim>
        where fileid = #{fileid}
    </update>

    <delete id="deleteMdModelFileByFileid" parameterType="String">
        delete from md_model_file where fileid = #{fileid}
    </delete>

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