Skip to content

[BE-226] bug: 주차권 이벤트가 끝나지 않았을 때 이메일 전송 api 요청이 성공하는 오류 #477

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

Merged
merged 5 commits into from
Mar 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
import com.jnu.ticketdomain.domains.council.adaptor.CouncilAdaptor;
import com.jnu.ticketdomain.domains.council.domain.Council;
import com.jnu.ticketdomain.domains.council.exception.AlreadyExistEmailException;
import com.jnu.ticketdomain.domains.events.adaptor.EventAdaptor;
import com.jnu.ticketdomain.domains.events.domain.Event;
import com.jnu.ticketdomain.domains.events.domain.EventStatus;
import com.jnu.ticketdomain.domains.events.event.SendEmailEvent;
import com.jnu.ticketdomain.domains.events.exception.StillOpenEventException;
import com.jnu.ticketdomain.domains.user.adaptor.UserAdaptor;
import com.jnu.ticketdomain.domains.user.domain.User;
import com.jnu.ticketdomain.domains.user.exception.NotFoundUserException;
Expand All @@ -24,6 +28,7 @@
public class CouncilUseCase {
private final CouncilAdaptor councilAdaptor;
private final UserAdaptor userAdaptor;
private final EventAdaptor eventAdaptor;

@Transactional(readOnly = true)
public User findByEmail(String email) {
Expand All @@ -45,7 +50,14 @@ public SignUpCouncilResponse signUp(SignUpCouncilRequest signUpCouncilRequest) {

@Transactional
public SendEmailManuallyResponse sendEmail(Long eventId) {

try {
Event event = eventAdaptor.findById(eventId);

if (event.getEventStatus() != EventStatus.CLOSED) {
throw StillOpenEventException.EXCEPTION;
}

Comment on lines +55 to +60
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거 조금 헷갈리는 부분이 있는데 예외 메세지가 != EventStatus.CLOSED 보다 좁은 의미를 나타내고 있습니다. 수정해주세요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네 수정하겠습니다.

Events.raise(new SendEmailEvent(eventId));
log.info("SendEmailEvent published for eventId: {}", eventId);
return SendEmailManuallyResponse.of(ResponseMessage.SUCCESS_SEND_EMAIL_MANUALLY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public enum EventErrorCode implements BaseErrorCode {
CANNOT_UPDATE_CLOSED_EVENT(BAD_REQUEST, "EVENT_400_21", "종료된 이벤트는 수정할 수 없습니다."),
ALREADY_PUBLISHED_EVENT(BAD_REQUEST, "EVENT_400_22", "이미 게시된 이벤트입니다."),
NOT_PUBLISH_EVENT(BAD_REQUEST, "EVENT_400_23", "게시되지 않는 이벤트입니다."),
STILL_OPEN_EVENT(BAD_REQUEST, "EVENT_400_24", "주차권 이벤트가 만료된 상태에서만 메일 발송이 가능합니다."),
;
private final Integer status;
private final String code;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.jnu.ticketdomain.domains.events.exception;


import com.jnu.ticketcommon.exception.TicketCodeException;

public class StillOpenEventException extends TicketCodeException {
public static final TicketCodeException EXCEPTION = new StillOpenEventException();

private StillOpenEventException() {
super(EventErrorCode.STILL_OPEN_EVENT);
}
}
Loading