refactor(phase1): 完成包名重构 (org.example → com.superbiz.agent)
Task 4.1: 包名统一重构 - 重命名 41 个 Java 文件的包名 - 更新所有 import 语句 - 恢复枚举类(FaultCategory、DiagnosisStatus、SourceType) - 更新测试类的 import 重构范围: - domain/entity: 3 个实体类 - domain/model: 2 个数据类 - domain/enums: 3 个枚举类 - repository: 3 个接口 - service/session: 2 个类(接口 + 实现) - config: 9 个配置类 - controller: 2 个控制器 - agent/tool: 4 个工具类 - client: 1 个客户端 - Main.java: 主类 验证结果: - 编译成功,无错误 - 所有测试通过 (27/27) - ApiDocumentRepositoryTest: 7/7 ✅ - CaseLibraryRepositoryTest: 6/6 ✅ - DiagnosisRecordRepositoryTest: 6/6 ✅ - RedisSessionManagerTest: 8/8 ✅ Progress: 21/33 tasks completed (64%)
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
package com.superbiz.agent.repository;
|
||||
|
||||
import com.superbiz.agent.domain.enums.FaultCategory;
|
||||
import com.superbiz.agent.domain.entity.ApiDocument;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* API 文档 Repository
|
||||
*/
|
||||
@Repository
|
||||
public interface ApiDocumentRepository extends JpaRepository<ApiDocument, Long> {
|
||||
|
||||
/**
|
||||
* 根据文档ID查询
|
||||
*/
|
||||
Optional<ApiDocument> findByDocId(String docId);
|
||||
|
||||
/**
|
||||
* 根据文件hash查询(去重)
|
||||
*/
|
||||
Optional<ApiDocument> findByFileHash(String fileHash);
|
||||
|
||||
/**
|
||||
* 根据故障源查询
|
||||
*/
|
||||
List<ApiDocument> findByFaultSource(String faultSource);
|
||||
|
||||
/**
|
||||
* 根据故障类别和故障源查询
|
||||
*/
|
||||
List<ApiDocument> findByFaultCategoryAndFaultSource(FaultCategory category, String faultSource);
|
||||
|
||||
/**
|
||||
* 根据状态查询
|
||||
*/
|
||||
List<ApiDocument> findByStatus(String status);
|
||||
|
||||
/**
|
||||
* 根据状态查询(分页)
|
||||
*/
|
||||
Page<ApiDocument> findByStatus(String status, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 查询已索引的文档
|
||||
*/
|
||||
List<ApiDocument> findByStatusAndChunkCountGreaterThan(String status, Integer chunkCount);
|
||||
|
||||
/**
|
||||
* 模糊搜索文件名
|
||||
*/
|
||||
Page<ApiDocument> findByFileNameContaining(String keyword, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 根据故障源模糊搜索(分页)
|
||||
*/
|
||||
Page<ApiDocument> findByFaultSourceContaining(String keyword, Pageable pageable);
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.superbiz.agent.repository;
|
||||
|
||||
import com.superbiz.agent.domain.enums.FaultCategory;
|
||||
import com.superbiz.agent.domain.enums.SourceType;
|
||||
import com.superbiz.agent.domain.entity.CaseLibrary;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* 案例库 Repository
|
||||
*/
|
||||
@Repository
|
||||
public interface CaseLibraryRepository extends JpaRepository<CaseLibrary, Long> {
|
||||
|
||||
/**
|
||||
* 根据案例ID查询
|
||||
*/
|
||||
Optional<CaseLibrary> findByCaseId(String caseId);
|
||||
|
||||
/**
|
||||
* 根据诊断ID查询
|
||||
*/
|
||||
Optional<CaseLibrary> findByDiagnosisId(String diagnosisId);
|
||||
|
||||
/**
|
||||
* 根据故障类别查询
|
||||
*/
|
||||
List<CaseLibrary> findByFaultCategory(FaultCategory category);
|
||||
|
||||
/**
|
||||
* 根据错误码查询
|
||||
*/
|
||||
List<CaseLibrary> findByErrorCode(String errorCode);
|
||||
|
||||
/**
|
||||
* 根据故障类别和错误码查询
|
||||
*/
|
||||
List<CaseLibrary> findByFaultCategoryAndErrorCode(FaultCategory category, String errorCode);
|
||||
|
||||
/**
|
||||
* 根据故障类别、故障源和错误码查询(精确匹配)
|
||||
*/
|
||||
List<CaseLibrary> findByFaultCategoryAndFaultSourceAndErrorCode(
|
||||
FaultCategory category, String faultSource, String errorCode);
|
||||
|
||||
/**
|
||||
* 根据来源类型查询(分页)
|
||||
*/
|
||||
Page<CaseLibrary> findBySourceType(SourceType sourceType, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 查询热门案例(按引用次数排序)
|
||||
*/
|
||||
List<CaseLibrary> findTop10ByOrderByReferenceCountDesc();
|
||||
|
||||
/**
|
||||
* 根据故障类别查询热门案例
|
||||
*/
|
||||
List<CaseLibrary> findTop5ByFaultCategoryOrderByReferenceCountDesc(FaultCategory category);
|
||||
|
||||
/**
|
||||
* 模糊搜索标题
|
||||
*/
|
||||
Page<CaseLibrary> findByTitleContaining(String keyword, Pageable pageable);
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.superbiz.agent.repository;
|
||||
|
||||
import com.superbiz.agent.domain.enums.DiagnosisStatus;
|
||||
import com.superbiz.agent.domain.enums.FaultCategory;
|
||||
import com.superbiz.agent.domain.entity.DiagnosisRecord;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* 诊断记录 Repository
|
||||
*/
|
||||
@Repository
|
||||
public interface DiagnosisRecordRepository extends JpaRepository<DiagnosisRecord, Long> {
|
||||
|
||||
/**
|
||||
* 根据诊断ID查询
|
||||
*/
|
||||
Optional<DiagnosisRecord> findByDiagnosisId(String diagnosisId);
|
||||
|
||||
/**
|
||||
* 根据业务ID查询
|
||||
*/
|
||||
Optional<DiagnosisRecord> findByBusinessId(String businessId);
|
||||
|
||||
/**
|
||||
* 根据链路追踪ID查询
|
||||
*/
|
||||
Optional<DiagnosisRecord> findByTraceId(String traceId);
|
||||
|
||||
/**
|
||||
* 根据会话ID查询所有记录
|
||||
*/
|
||||
List<DiagnosisRecord> findBySessionId(String sessionId);
|
||||
|
||||
/**
|
||||
* 根据故障类别和错误码查询
|
||||
*/
|
||||
List<DiagnosisRecord> findByFaultCategoryAndErrorCode(FaultCategory category, String errorCode);
|
||||
|
||||
/**
|
||||
* 根据故障类别、故障源和错误码查询
|
||||
*/
|
||||
List<DiagnosisRecord> findByFaultCategoryAndFaultSourceAndErrorCode(
|
||||
FaultCategory category, String faultSource, String errorCode);
|
||||
|
||||
/**
|
||||
* 根据状态查询
|
||||
*/
|
||||
List<DiagnosisRecord> findByStatus(DiagnosisStatus status);
|
||||
|
||||
/**
|
||||
* 根据时间范围查询(分页)
|
||||
*/
|
||||
Page<DiagnosisRecord> findByCreatedAtBetween(
|
||||
LocalDateTime start, LocalDateTime end, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 根据故障类别和时间范围查询(分页)
|
||||
*/
|
||||
Page<DiagnosisRecord> findByFaultCategoryAndCreatedAtBetween(
|
||||
FaultCategory category, LocalDateTime start, LocalDateTime end, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 查询有用反馈的高置信度记录(用于生成案例)
|
||||
*/
|
||||
List<DiagnosisRecord> findByFeedbackAndConfidenceGreaterThanEqual(String feedback, Integer confidence);
|
||||
}
|
||||
Reference in New Issue
Block a user