fix: 知识库文档管理搜索条件修改

This commit is contained in:
wenjinbo 2025-09-29 09:35:03 +08:00
parent 996bb9481a
commit e29ac67a91
2 changed files with 28 additions and 17 deletions

View File

@ -13,7 +13,7 @@ import java.util.HashSet;
/**
* fegin 配置文件
*
*
*
* 2019年3月29日
*/
@ -62,7 +62,7 @@ public class FeignConfiguration extends FeignSudoUtil implements RequestIntercep
if (!existHeaders.contains("__Permission__")) {
template.header("__Permission__", "*:*:*");
}
// } for ZB
// } for ZB
}

View File

@ -37,24 +37,30 @@
FROM t_dataset_files
WHERE dify_dataset_id = #{difyDatasetId}
AND is_deleted = false
<if test="parentId != null">
AND parent_id = #{parentId}
</if>
<if test="parentId == null">
AND parent_id IS NULL
</if>
<if test="fileName != null and fileName != ''">
AND name ILIKE CONCAT('%', #{fileName}, '%')
</if>
<choose>
<when test="fileName != null and fileName != ''">
<!-- 当 fileName 不为空时,忽略 parentId 条件 -->
AND name ILIKE CONCAT('%', #{fileName}, '%')
</when>
<otherwise>
<!-- 当 fileName 为空时,应用 parentId 条件 -->
<if test="parentId != null">
AND parent_id = #{parentId}
</if>
<if test="parentId == null">
AND parent_id IS NULL
</if>
</otherwise>
</choose>
<if test="orderBy != null and orderBy != ''">
ORDER BY
CASE WHEN type = 'folder' THEN 0 ELSE 1 END,
${orderBy} ${orderDirection}
ORDER BY
CASE WHEN type = 'folder' THEN 0 ELSE 1 END,
${orderBy} ${orderDirection}
</if>
<if test="orderBy == null or orderBy == ''">
ORDER BY
CASE WHEN type = 'folder' THEN 0 ELSE 1 END,
name ASC
ORDER BY
CASE WHEN type = 'folder' THEN 0 ELSE 1 END,
name ASC
</if>
<if test="limit != null and limit > 0">
LIMIT #{limit}
@ -64,6 +70,9 @@
</if>
</select>
<!-- 根据知识库id和parent_id 查询总数 -->
<select id="countByDatasetIdAndParentId" resultType="int">
SELECT COUNT(*)
@ -81,6 +90,8 @@
</if>
</select>
<!-- 根据知识库id和name查询 文件/文件夹 -->
<select id="selectByDatasetIdAndName" resultMap="TDatasetFilesResultMap">
SELECT <include refid="Base_Column_List"/>