<?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="org.springblade.system.mapper.FilesMultiClassifyMapper">
    <insert id="addKyFilesMultiClassify">
        insert into da_ky_files_multi_classify
        (classify_name,dimension,classify_desc,create_time,update_time,create_user_id,create_user_name,update_user_id,update_user_name,file_related)
        values (#{classifyName},#{dimension},#{classifyDesc},#{createTime},#{updateTime},#{createUserId},#{createUserName},#{updateUserId},#{updateUserName},#{fileRelatedId})
    </insert>
    <update id="updateKyFilesMultiClassify">
        update da_ky_files_multi_classify
        <trim prefix="set" suffixOverrides=",">
            <if test="classifyName!=null">
                classify_name =#{classifyName},
            </if>
            <if test="dimension!=null">
                dimension =#{dimension},
            </if>
            <if test="classifyDesc!=null">
                classify_desc =#{classifyDesc},
            </if>
            <if test="updateUserId!=null">
                update_user_id =#{updateUserId},
            </if>
            <if test="updateUserName!=null">
                update_user_name =#{updateUserName},
            </if>
            <if test="updateTime!=null">
                update_time =#{updateTime},
            </if>
            <if test="fileRelatedId!=null">
                file_related =#{fileRelatedId},
            </if>
        </trim>
        where id = #{id}
    </update>
    <delete id="delKyFilesMultiClassify">
        update da_ky_files_multi_classify set del_flag='0' where id = #{id}
    </delete>


    <select id="selectKyFilesMultiClassifyList" resultType="org.springblade.common.core.domain.entity.KyFilesMultiClassify">
        select dkfmc.id,dkfmc.classify_name,dkfmc.dimension,dkfmc.classify_desc,dkfmc.update_time,
               dkfmc.update_user_id,dkfmc.update_user_name,dksdd.dict_label as dictLabel,dksdd2.dict_label as fileRelated,dksdd2.dict_value as fileRelatedId
        from da_ky_files_multi_classify dkfmc
        left join da_ky_sys_dict_data dksdd on dkfmc.dimension = dksdd.dict_value and dksdd.dict_type = 'dimension'
        left join da_ky_sys_dict_data dksdd2 on dkfmc.file_related = dksdd2.dict_value and dksdd2.dict_type = 'file_related_type'
        where dkfmc.del_flag='1'
        <if test="classifyName!=null">
            AND INSTR(classify_name, #{classifyName}) > 0
        </if>
    </select>
    <select id="getKyFilesMultiClassifyByClassifyName"
            resultType="org.springblade.common.core.domain.entity.KyFilesMultiClassify">
        select dkfmc.id,dkfmc.classify_name,dkfmc.dimension,dkfmc.classify_desc,dkfmc.update_time,
               dkfmc.update_user_id,dkfmc.update_user_name
        from da_ky_files_multi_classify dkfmc
        where dkfmc.del_flag='1' and dkfmc.classify_name = #{classifyName}
    </select>
    <select id="getDetail" resultType="org.springblade.common.core.domain.entity.KyFilesMultiClassify">
        select dkfmc.id,dkfmc.classify_name,dkfmc.dimension,dkfmc.classify_desc,dkfmc.update_time,
        dkfmc.update_user_id,dkfmc.update_user_name,dksdd.dict_label as dictLabel,dksdd2.dict_label as fileRelated,dksdd2.dict_value as fileRelatedId
        from da_ky_files_multi_classify dkfmc
        left join da_ky_sys_dict_data dksdd on dkfmc.dimension = dksdd.dict_value and dksdd.dict_type = 'dimension'
        left join da_ky_sys_dict_data dksdd2 on dkfmc.file_related = dksdd2.dict_value and dksdd2.dict_type = 'file_related_type'
        where dkfmc.del_flag='1' and dkfmc.id = #{id}
    </select>
</mapper>
