diff --git a/cs25-batch/src/main/java/com/example/cs25batch/aop/MailLogAspect.java b/cs25-batch/src/main/java/com/example/cs25batch/aop/MailLogAspect.java index 2b50daec..89d00a0b 100644 --- a/cs25-batch/src/main/java/com/example/cs25batch/aop/MailLogAspect.java +++ b/cs25-batch/src/main/java/com/example/cs25batch/aop/MailLogAspect.java @@ -48,7 +48,7 @@ public Object logMailSend(ProceedingJoinPoint joinPoint) throws Throwable { caused = e.getMessage(); throw new CustomMailException(MailExceptionCode.EMAIL_SEND_FAILED_ERROR); } finally { - MailLog log = MailLog.builder() + MailLog mailLog = MailLog.builder() .subscription(subscription) .quiz(quiz) .sendDate(LocalDateTime.now()) @@ -56,10 +56,11 @@ public Object logMailSend(ProceedingJoinPoint joinPoint) throws Throwable { .caused(caused) .build(); - mailLogRepository.save(log); + mailLogRepository.save(mailLog); mailLogRepository.flush(); if (status == MailStatus.FAILED) { + log.info("메일 발송 실패 : subscriptionId - {}, cause - {}", subscription.getId(), caused); Map retryMessage = Map.of( "email", subscription.getEmail(), "subscriptionId", subscription.getId().toString(), diff --git a/cs25-entity/src/main/java/com/example/cs25entity/domain/mail/repository/MailLogRepository.java b/cs25-entity/src/main/java/com/example/cs25entity/domain/mail/repository/MailLogRepository.java index a9184764..3431079d 100644 --- a/cs25-entity/src/main/java/com/example/cs25entity/domain/mail/repository/MailLogRepository.java +++ b/cs25-entity/src/main/java/com/example/cs25entity/domain/mail/repository/MailLogRepository.java @@ -7,6 +7,8 @@ import java.util.Optional; import java.util.Set; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; @Repository @@ -23,5 +25,11 @@ default MailLog findByIdOrElseThrow(Long id) { void deleteAllByIdIn(Collection ids); - Set findDistinctQuiz_IdBySubscription_Id(Long subscriptionId); + @Query(""" + select distinct ml.quiz.id + from MailLog ml + where ml.subscription.id = :subscriptionId + and ml.status = com.example.cs25entity.domain.mail.enums.MailStatus.SENT + """) + Set findDistinctQuiz_IdBySubscription_Id(@Param("subscriptionId") Long subscriptionId); } diff --git a/cs25-service/src/main/java/com/example/cs25service/domain/ai/service/AiFeedbackStreamProcessor.java b/cs25-service/src/main/java/com/example/cs25service/domain/ai/service/AiFeedbackStreamProcessor.java index d9eee6cc..c159fb6d 100644 --- a/cs25-service/src/main/java/com/example/cs25service/domain/ai/service/AiFeedbackStreamProcessor.java +++ b/cs25-service/src/main/java/com/example/cs25service/domain/ai/service/AiFeedbackStreamProcessor.java @@ -4,6 +4,8 @@ import com.example.cs25entity.domain.user.repository.UserRepository; import com.example.cs25entity.domain.userQuizAnswer.repository.UserQuizAnswerRepository; import com.example.cs25service.domain.ai.client.AiChatClient; +//import com.example.cs25service.domain.ai.exception.AiException; +//import com.example.cs25service.domain.ai.exception.AiExceptionCode; import com.example.cs25service.domain.ai.prompt.AiPromptProvider; import com.fasterxml.jackson.databind.JsonNode; import java.io.IOException; @@ -89,9 +91,9 @@ public void stream(Long answerId, SseEmitter emitter) { send(emitter, "[종료]"); String feedback = fullFeedbackBuffer.toString(); - if (feedback == null || feedback.isEmpty()) { - throw new AiException(AiExceptionCode.INTERNAL_SERVER_ERROR); - } +// if (feedback == null || feedback.isEmpty()) { +// throw new AiException(AiExceptionCode.INTERNAL_SERVER_ERROR); +// } boolean isCorrect = isCorrect(feedback);