|
...
|
...
|
@@ -68,6 +68,8 @@ public class QuestionEmbeddingMapper { |
|
|
|
countParams.add("%" + questionEmbedding.getAnswer() + "%");
|
|
|
|
}
|
|
|
|
|
|
|
|
sql.append(" ORDER BY (metadata->>'knowledgeId') ASC NULLS LAST, question ASC");
|
|
|
|
|
|
|
|
// 添加分页
|
|
|
|
sql.append(" LIMIT ? OFFSET ?");
|
|
|
|
params.add(pageSize);
|
|
...
|
...
|
@@ -91,23 +93,6 @@ public class QuestionEmbeddingMapper { |
|
|
|
throw new RuntimeException("查询数据时发生数据库错误", e);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 2. 获取知识库名称映射
|
|
|
|
Map<String, String> knowledgeNameMap = getKnowledgeNameMap(results);
|
|
|
|
|
|
|
|
// 3. 设置知识库名称并处理空值
|
|
|
|
for (QuestionEmbedding record : results) {
|
|
|
|
String knowledgeId = record.getKnowledgeId();
|
|
|
|
String name = knowledgeNameMap.get(knowledgeId);
|
|
|
|
record.setKnowledgeName(name != null ? name : "");
|
|
|
|
}
|
|
|
|
|
|
|
|
// 4. 安全排序(处理空值)
|
|
|
|
results.sort(Comparator
|
|
|
|
.comparing(QuestionEmbedding::getKnowledgeName,
|
|
|
|
Comparator.nullsLast(Comparator.naturalOrder()))
|
|
|
|
.thenComparing(QuestionEmbedding::getQuestion,
|
|
|
|
Comparator.nullsLast(Comparator.naturalOrder())));
|
|
|
|
|
|
|
|
// 执行计数查询
|
|
|
|
long total = 0;
|
|
|
|
try(Connection conn = getConnection();
|
...
|
...
|
|