<?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.project.business.mapper.TtFileDirectoryMapper">

    <resultMap id="BaseResultMap" type="com.ruoyi.project.business.domain.train.TtFileDirectory">
        <id property="id" column="id" jdbcType="BIGINT"/>
        <result property="derectoryName" column="derectory_name" jdbcType="VARCHAR"/>
        <result property="superDirectory" column="super_directory" jdbcType="VARCHAR"/>
        <result property="delFlag" column="del_flag" jdbcType="CHAR"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="createBy" column="create_by" jdbcType="BIGINT"/>
        <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
        <result property="updateBy" column="update_by" jdbcType="BIGINT"/>
        <result property="remark" column="remark" jdbcType="VARCHAR"/>
    </resultMap>

    <sql id="Base_Column_List">
        id,derectory_name,super_directory,
        del_flag,create_time,create_by,
        update_time,update_by,remark
    </sql>
    
    
    <select id="listRange" resultType="com.ruoyi.project.business.domain.train.TtFileDirectory">
        SELECT tfd.*
            FROM tt_file_directory tfd
        /*LEFT JOIN sys_role r ON FIND_IN_SET(r.role_key, tfd.visible_range1)
        LEFT JOIN tb_area ta ON FIND_IN_SET(ta.area_id, tfd.visible_range2)*/

        <where>
            <if test="roleKeys != null and roleKeys.size() > 0 or areaIds != null and areaIds.size() > 0">
                and (
                <trim prefixOverrides="or">
                    <if test="roleKeys != null and roleKeys.size() > 0">
                        <foreach collection="roleKeys" item="roleKey" separator="or">
                            find_in_set(#{roleKey}, tfd.visible_range1)
                        </foreach>
                    </if>
                    or
                    <if test="areaIds != null and areaIds.size() > 0">
                        <foreach collection="areaIds" item="areaId" separator="or">
                            find_in_set(#{areaId}, tfd.visible_range2)
                        </foreach>
                    </if>
                </trim>
                )
            </if>
        </where>
        /*group by tfd.id*/
    </select>
</mapper>
