<?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.fdkankan.scene.mapper.IFolderMapper">

    <select id="selectByCondition" resultType="com.fdkankan.scene.entity.Folder">

        SELECT *
        FROM t_folder
        WHERE tb_status = 0
        <if test="recStatus != null and recStatus != ''">
            and rec_status = #{recStatus}
        </if>
        <if test="folderName != null and folderName != ''">
            and folder_name = #{folderName}
        </if>
        <if test="userId != null">
            and user_id = #{userId}
        </if>
        <if test= 'parentId != null'>
            and parent_id = #{parentId}
        </if>
        <if test= 'parentId == null'>
            and parent_id is null
        </if>

    </select>

    <select id="selectByUserIdAndType" resultType="com.fdkankan.scene.entity.Folder">
        SELECT *
        FROM t_folder
        WHERE tb_status = 0
        and rec_status = 'A'
        and user_id = #{userId}
        and folder_type = #{folderType}
        <if test= "name != null">
            and folder_name like CONCAT('%',#{folderName},'%')
        </if>
    </select>

</mapper>
