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 {
// 1. AI 피드백 조회
var aiFeedback = analyticsPort.findAIFeedbackByStoreId(feedbackId); // 실제로는 feedbackId로 조회하는 메서드 필요
var aiFeedback = analyticsPort.findAIFeedbackById(feedbackId);
if (aiFeedback.isEmpty()) {
throw new RuntimeException("AI 피드백을 찾을 수 없습니다: " + feedbackId);

View File

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

View File

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

View File

@ -25,7 +25,7 @@ public interface AiFeedbackJpaRepository extends JpaRepository<AiFeedbackEntity,
/**
* 매장 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);
/**