-
Notifications
You must be signed in to change notification settings - Fork 2
MOSU-166 refactor : 알림톡 연동 #169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ea8536c
3b8858b
4b13985
86a2830
8255989
61189a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,21 @@ | ||
| package life.mosu.mosuserver.application.notify; | ||
|
|
||
| import java.time.LocalDate; | ||
| import life.mosu.mosuserver.application.notify.dto.ApplicationNotifyRequest; | ||
| import life.mosu.mosuserver.application.notify.dto.Exam1DayBeforeNotifyRequest; | ||
| import life.mosu.mosuserver.application.notify.dto.Exam1WeekBeforeNotifyRequest; | ||
| import life.mosu.mosuserver.application.notify.dto.Exam3DayBeforeNotifyRequest; | ||
| import life.mosu.mosuserver.application.notify.dto.InquiryAnswerNotifyRequest; | ||
| import life.mosu.mosuserver.application.notify.dto.RefundNotifyRequest; | ||
| import life.mosu.mosuserver.application.notify.dto.SignUpNotifyRequest; | ||
| import life.mosu.mosuserver.domain.exam.ExamJpaRepository; | ||
| import life.mosu.mosuserver.domain.examapplication.ExamApplicationJpaRepository; | ||
| import life.mosu.mosuserver.domain.examapplication.projection.ExamApplicationNotifyProjection; | ||
| import life.mosu.mosuserver.domain.examapplication.ExamInfoProjection; | ||
| import life.mosu.mosuserver.domain.examapplication.projection.ExamApplicationNotifyProjection; | ||
| import life.mosu.mosuserver.domain.examapplication.projection.ExamInfoWithExamNumberProjection; | ||
| import life.mosu.mosuserver.domain.inquiry.InquiryJpaEntity; | ||
| import life.mosu.mosuserver.domain.inquiry.InquiryJpaRepository; | ||
| import life.mosu.mosuserver.domain.refund.RefundJpaRepository; | ||
| import life.mosu.mosuserver.domain.refund.RefundNotifyProjection; | ||
| import life.mosu.mosuserver.global.exception.CustomRuntimeException; | ||
| import life.mosu.mosuserver.global.exception.ErrorCode; | ||
| import life.mosu.mosuserver.infra.notify.dto.NotificationEvent; | ||
|
|
@@ -61,29 +62,21 @@ private NotificationVariable createInquiryAnswerVariable(Long targetId) { | |
| } | ||
|
|
||
| private NotificationVariable createRefundVariable(Long targetId) { | ||
| // RefundNotifyProjection projection = refundJpaRepository.findRefundByApplicationSchoolId( | ||
| // targetId) | ||
| // .orElseThrow( | ||
| // () -> new CustomRuntimeException(ErrorCode.APPLICATION_SCHOOL_NOT_FOUND)); | ||
| // return new RefundNotifyRequest( | ||
| // projection.paymentKey(), projection.examDate(), projection.schoolName(), | ||
| // projection.paymentMethod().getName(), projection.reason() | ||
| // ); | ||
| return null; | ||
| RefundNotifyProjection projection = refundJpaRepository.findRefundByExamApplicationId( | ||
| targetId) | ||
| .orElseThrow( | ||
| () -> new CustomRuntimeException(ErrorCode.APPLICATION_SCHOOL_NOT_FOUND)); | ||
|
Comment on lines
+66
to
+68
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The error code () -> new CustomRuntimeException(ErrorCode.EXAM_APPLICATION_NOT_FOUND)); |
||
| return new RefundNotifyRequest( | ||
| projection.paymentKey(), projection.examDate(), projection.schoolName(), | ||
| projection.refundAmount(), projection.paymentMethod().getName(), projection.reason() | ||
| ); | ||
| } | ||
|
Comment on lines
64
to
73
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainVerify error code consistency and consider null safety. The implementation looks correct, but there are a couple of points to verify:
Please verify the following: Consider this improvement for null safety: return new RefundNotifyRequest(
projection.paymentKey(), projection.examDate(), projection.schoolName(),
- projection.refundAmount(), projection.paymentMethod().getName(), projection.reason()
+ projection.refundAmount(),
+ projection.paymentMethod() != null ? projection.paymentMethod().getName() : "N/A",
+ projection.reason()
);🏁 Script executed: #!/bin/bash
# Check if REFUND_NOT_FOUND or similar error code exists in ErrorCode enum
ast-grep --pattern 'enum ErrorCode {
$$$
}'Length of output: 47 🏁 Script executed: #!/bin/bash
set -e
# Locate the ErrorCode enum definition
file=$(fd ErrorCode.java | head -n1)
echo "Found ErrorCode enum in: $file"
# Dump its contents to list all defined error codes
sed -n '/enum ErrorCode/,/};/p' "$file"Length of output: 6687 🏁 Script executed: #!/bin/bash
set -e
# Locate and print the RefundNotifyProjection interface to check paymentMethod() return type
proj_file=$(fd RefundNotifyProjection.java | head -n1)
echo "=== $proj_file ==="
sed -n '1,200p' "$proj_file"
# Locate and inspect the Refund entity for the paymentMethod field nullability
entity_file=$(fd Refund.java | head -n1)
echo "=== $entity_file ==="
grep -R -n "paymentMethod" "$entity_file" -n
sed -n '1,200p' "$entity_file"Length of output: 1198 Use a dedicated REFUND_NOT_FOUND error code and guard against null paymentMethod Your implementation should throw a semantically correct error when no refund is found and only assume • In ErrorCode enum ( REFUND_NOT_FOUND(HttpStatus.NOT_FOUND, "환불 정보를 찾을 수 없습니다."),• In NotifyVariableFactory#createRefundVariable ( - .orElseThrow(() -> new CustomRuntimeException(ErrorCode.APPLICATION_SCHOOL_NOT_FOUND));
+ .orElseThrow(() -> new CustomRuntimeException(ErrorCode.REFUND_NOT_FOUND));
return new RefundNotifyRequest(
projection.paymentKey(),
projection.examDate(),
projection.schoolName(),
projection.refundAmount(),
- projection.paymentMethod().getName(),
+ projection.paymentMethod() != null
+ ? projection.paymentMethod().getName()
+ : "N/A",
projection.reason()
);• If 🤖 Prompt for AI Agents |
||
|
|
||
| // TODO : Exception custom 필요 | ||
| private NotificationVariable createApplicationVariable(Long targetId) { | ||
| // ExamApplicationNotifyProjection projection = examApplicationRepository.findExamAndPaymentByExamApplicationId( | ||
| // targetId) | ||
| // .orElseThrow(() -> new RuntimeException()); | ||
| ExamApplicationNotifyProjection projection = new ExamApplicationNotifyProjection( | ||
| "paymentKey", | ||
| LocalDate.of(2025, 7, 25), | ||
| "schoolName", | ||
| true, | ||
| "고구마" | ||
| ); | ||
| ExamApplicationNotifyProjection projection = examApplicationRepository.findExamAndPaymentByExamApplicationId( | ||
| targetId) | ||
| .orElseThrow( | ||
| () -> new CustomRuntimeException(ErrorCode.EXAM_APPLICATION_NOT_FOUND)); | ||
| return ApplicationNotifyRequest.from(projection); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,6 +7,9 @@ | |||||||||||||||||
| import life.mosu.mosuserver.domain.user.UserRole; | ||||||||||||||||||
| import life.mosu.mosuserver.global.exception.CustomRuntimeException; | ||||||||||||||||||
| import life.mosu.mosuserver.global.exception.ErrorCode; | ||||||||||||||||||
| import life.mosu.mosuserver.infra.notify.NotifyEventPublisher; | ||||||||||||||||||
| import life.mosu.mosuserver.infra.notify.dto.NotificationEvent; | ||||||||||||||||||
| import life.mosu.mosuserver.infra.notify.dto.NotificationStatus; | ||||||||||||||||||
| import life.mosu.mosuserver.presentation.profile.dto.EditProfileRequest; | ||||||||||||||||||
| import life.mosu.mosuserver.presentation.profile.dto.ProfileDetailResponse; | ||||||||||||||||||
| import life.mosu.mosuserver.presentation.profile.dto.SignUpProfileRequest; | ||||||||||||||||||
|
|
@@ -21,6 +24,7 @@ public class ProfileService { | |||||||||||||||||
|
|
||||||||||||||||||
| private final UserJpaRepository userRepository; | ||||||||||||||||||
| private final ProfileJpaRepository profileJpaRepository; | ||||||||||||||||||
| private final NotifyEventPublisher notifier; | ||||||||||||||||||
|
|
||||||||||||||||||
| @Transactional | ||||||||||||||||||
| public void registerProfile(Long userId, SignUpProfileRequest request) { | ||||||||||||||||||
|
|
@@ -34,6 +38,8 @@ public void registerProfile(Long userId, SignUpProfileRequest request) { | |||||||||||||||||
|
|
||||||||||||||||||
| user.grantUserRole(); | ||||||||||||||||||
| syncUserInfoFromProfile(user, request); | ||||||||||||||||||
|
|
||||||||||||||||||
| sendNotification(); | ||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| @Transactional | ||||||||||||||||||
|
|
@@ -65,5 +71,10 @@ private void syncUserInfoFromProfile(UserJpaEntity user, SignUpProfileRequest re | |||||||||||||||||
| request.phoneNumber(), request.birth()); | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| private void sendNotification() { | ||||||||||||||||||
| NotificationEvent event = NotificationEvent.create(NotificationStatus.SIGN_UP_SUCCESS); | ||||||||||||||||||
| notifier.notify(event); | ||||||||||||||||||
| } | ||||||||||||||||||
|
Comment on lines
+75
to
+78
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The To fix this, the
Suggested change
|
||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider adding error handling for notification failures.
Similar to the refund notification, consider adding error handling to prevent inquiry answer creation from failing due to notification issues.
private void sendNotification(Long userId, Long postId) { + try { NotificationEvent event = NotificationEvent.create( NotificationStatus.INQUIRY_ANSWER_SUCCESS, userId, postId); notifier.notify(event); + } catch (Exception e) { + log.error("문의 답변 완료 알림톡 발송 실패: userId={}, postId={}", + userId, postId, e); + } }📝 Committable suggestion
🤖 Prompt for AI Agents