You've already forked DataMate
feat(knowledge-management): 添加知识管理搜索功能和统计接口
- 新增知识条目搜索查询和响应DTO - 实现知识管理统计功能,包括总数、文件数和总大小 - 添加数据库查询方法支持文件搜索和统计计算 - 创建知识条目搜索控制器提供REST API - 在前端添加知识管理搜索页面和相关组件 - 更新前端路由配置添加搜索页面入口 - 移除RAG索引服务中的重复统计功能 - 优化前端页面统计数据显示和刷新逻辑
This commit is contained in:
@@ -140,17 +140,6 @@ public class KnowledgeBaseService {
|
||||
return PagedResponse.of(respList, page.getCurrent(), page.getTotal(), page.getPages());
|
||||
}
|
||||
|
||||
public KnowledgeBaseStatisticsResp getStatistics() {
|
||||
KnowledgeBaseStatisticsResp resp = new KnowledgeBaseStatisticsResp();
|
||||
resp.setTotalKnowledgeBases(knowledgeBaseRepository.count());
|
||||
|
||||
RagFileStatistics fileStatistics = ragFileRepository.getStatistics();
|
||||
if (fileStatistics != null) {
|
||||
resp.setTotalFiles(fileStatistics.getTotalFiles() != null ? fileStatistics.getTotalFiles() : 0L);
|
||||
resp.setTotalSize(fileStatistics.getTotalSize() != null ? fileStatistics.getTotalSize() : 0L);
|
||||
}
|
||||
return resp;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void addFiles(AddFilesReq request) {
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.extension.repository.IRepository;
|
||||
import com.datamate.rag.indexer.domain.model.RagFile;
|
||||
import com.datamate.rag.indexer.interfaces.dto.KnowledgeBaseFileSearchReq;
|
||||
import com.datamate.rag.indexer.interfaces.dto.RagFileReq;
|
||||
import com.datamate.rag.indexer.interfaces.dto.RagFileStatistics;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -25,6 +24,4 @@ public interface RagFileRepository extends IRepository<RagFile> {
|
||||
IPage<RagFile> page(IPage<RagFile> page, RagFileReq request);
|
||||
|
||||
IPage<RagFile> searchPage(IPage<RagFile> page, KnowledgeBaseFileSearchReq request);
|
||||
|
||||
RagFileStatistics getStatistics();
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.datamate.rag.indexer.domain.repository.RagFileRepository;
|
||||
import com.datamate.rag.indexer.infrastructure.persistence.mapper.RagFileMapper;
|
||||
import com.datamate.rag.indexer.interfaces.dto.KnowledgeBaseFileSearchReq;
|
||||
import com.datamate.rag.indexer.interfaces.dto.RagFileReq;
|
||||
import com.datamate.rag.indexer.interfaces.dto.RagFileStatistics;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -61,11 +60,6 @@ public class RagFileRepositoryImpl extends CrudRepository<RagFileMapper, RagFile
|
||||
.page(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RagFileStatistics getStatistics() {
|
||||
return baseMapper.getStatistics();
|
||||
}
|
||||
|
||||
private String normalizeRelativePath(String relativePath) {
|
||||
if (!StringUtils.hasText(relativePath)) {
|
||||
return "";
|
||||
|
||||
@@ -3,9 +3,7 @@ package com.datamate.rag.indexer.infrastructure.persistence.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.datamate.rag.indexer.domain.model.RagFile;
|
||||
import com.datamate.rag.indexer.interfaces.dto.RagFileStatistics;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
/**
|
||||
* RAG文件映射器接口
|
||||
@@ -15,9 +13,4 @@ import org.apache.ibatis.annotations.Select;
|
||||
*/
|
||||
@Mapper
|
||||
public interface RagFileMapper extends BaseMapper<RagFile> {
|
||||
@Select("SELECT COUNT(*) AS totalFiles, " +
|
||||
"COALESCE(SUM(df.file_size), 0) AS totalSize " +
|
||||
"FROM t_rag_file rf " +
|
||||
"LEFT JOIN t_dm_dataset_files df ON rf.file_id = df.id")
|
||||
RagFileStatistics getStatistics();
|
||||
}
|
||||
|
||||
@@ -80,15 +80,6 @@ public class KnowledgeBaseController {
|
||||
return knowledgeBaseService.list(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取知识库统计信息
|
||||
*
|
||||
* @return 知识库统计信息
|
||||
*/
|
||||
@GetMapping("/statistics")
|
||||
public KnowledgeBaseStatisticsResp statistics() {
|
||||
return knowledgeBaseService.getStatistics();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加文件到知识库
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.datamate.rag.indexer.interfaces.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* 知识库统计响应
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class KnowledgeBaseStatisticsResp {
|
||||
private Long totalKnowledgeBases = 0L;
|
||||
private Long totalFiles = 0L;
|
||||
private Long totalSize = 0L;
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.datamate.rag.indexer.interfaces.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* 知识库文件统计
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class RagFileStatistics {
|
||||
private Long totalFiles = 0L;
|
||||
private Long totalSize = 0L;
|
||||
}
|
||||
Reference in New Issue
Block a user