feat : 분석api 개발

This commit is contained in:
lsh9672 2025-06-16 14:30:58 +09:00
parent 84ef442775
commit e61e98ed7d
4 changed files with 17 additions and 5 deletions

View File

@ -445,7 +445,7 @@ public class AnalyticsService implements AnalyticsUseCase {
try { try {
// 1. AI 피드백 조회 // 1. AI 피드백 조회
var aiFeedback = analyticsPort.findAIFeedbackByStoreId(feedbackId); // 실제로는 feedbackId로 조회하는 메서드 필요 var aiFeedback = analyticsPort.findAIFeedbackById(feedbackId);
if (aiFeedback.isEmpty()) { if (aiFeedback.isEmpty()) {
throw new RuntimeException("AI 피드백을 찾을 수 없습니다: " + feedbackId); throw new RuntimeException("AI 피드백을 찾을 수 없습니다: " + feedbackId);

View File

@ -25,7 +25,13 @@ public interface AnalyticsPort {
* 매장 ID로 AI 피드백 조회 * 매장 ID로 AI 피드백 조회
*/ */
Optional<AiFeedback> findAIFeedbackByStoreId(Long storeId); Optional<AiFeedback> findAIFeedbackByStoreId(Long storeId);
/**
* AI 피드백 ID로 조회 (추가된 메서드)
*/
Optional<AiFeedback> findAIFeedbackById(Long feedbackId);
/** /**
* AI 피드백 저장 * AI 피드백 저장
*/ */

View File

@ -55,6 +55,12 @@ public class AnalyticsRepositoryAdapter implements AnalyticsPort {
AiFeedbackEntity saved = aiFeedbackJpaRepository.save(entity); AiFeedbackEntity saved = aiFeedbackJpaRepository.save(entity);
return toAiFeedbackDomain(saved); return toAiFeedbackDomain(saved);
} }
@Override
public Optional<AiFeedback> findAIFeedbackById(Long feedbackId) {
return aiFeedbackJpaRepository.findById(feedbackId)
.map(this::toAiFeedbackDomain);
}
/** /**
* Analytics Entity를 Domain으로 변환 * Analytics Entity를 Domain으로 변환

View File

@ -21,13 +21,13 @@ public interface AiFeedbackJpaRepository extends JpaRepository<AiFeedbackEntity,
* 매장 ID로 AI 피드백 조회 (최신순) * 매장 ID로 AI 피드백 조회 (최신순)
*/ */
Optional<AiFeedbackEntity> findByStoreId(Long storeId); Optional<AiFeedbackEntity> findByStoreId(Long storeId);
/** /**
* 매장 ID로 최신 AI 피드백 조회 * 매장 ID로 최신 AI 피드백 조회
*/ */
@Query("SELECT af FROM AiFeedbackEntity af WHERE af.storeId = :storeId ORDER BY af.generatedAt DESC") @Query("SELECT af FROM AiFeedbackEntity af WHERE af.storeId = :storeId ORDER BY af.createdAt DESC LIMIT 1")
Optional<AiFeedbackEntity> findLatestByStoreId(@Param("storeId") Long storeId); Optional<AiFeedbackEntity> findLatestByStoreId(@Param("storeId") Long storeId);
/** /**
* 특정 기간 이후 생성된 AI 피드백 조회 * 특정 기간 이후 생성된 AI 피드백 조회
*/ */