|
3 | 3 | import jakarta.servlet.http.HttpServletRequest; |
4 | 4 | import jakarta.servlet.http.HttpServletResponse; |
5 | 5 | import lombok.RequiredArgsConstructor; |
| 6 | +import lombok.extern.slf4j.Slf4j; |
6 | 7 | import org.fontory.fontorybe.authentication.adapter.inbound.annotation.Login; |
7 | 8 | import org.fontory.fontorybe.authentication.application.port.CookieUtils; |
8 | 9 | import org.fontory.fontorybe.authentication.domain.UserPrincipal; |
9 | 10 | import org.fontory.fontorybe.common.application.DevTokenInitializer; |
| 11 | +import org.fontory.fontorybe.file.application.port.CloudStorageService; |
| 12 | +import org.fontory.fontorybe.font.FontCreateRequestNotificationEvent; |
| 13 | +import org.fontory.fontorybe.font.domain.Font; |
10 | 14 | import org.fontory.fontorybe.font.service.dto.FontRequestProduceDto; |
| 15 | +import org.fontory.fontorybe.font.service.port.FontRepository; |
11 | 16 | import org.fontory.fontorybe.font.service.port.FontRequestProducer; |
| 17 | +import org.fontory.fontorybe.member.domain.Member; |
| 18 | +import org.fontory.fontorybe.member.service.MemberLookupServiceImpl; |
| 19 | +import org.fontory.fontorybe.member.service.port.MemberRepository; |
12 | 20 | import org.slf4j.MDC; |
13 | 21 | import org.springframework.beans.factory.annotation.Value; |
| 22 | +import org.springframework.context.ApplicationEventPublisher; |
14 | 23 | import org.springframework.web.bind.annotation.GetMapping; |
| 24 | +import org.springframework.web.bind.annotation.PostMapping; |
15 | 25 | import org.springframework.web.bind.annotation.RestController; |
16 | 26 |
|
17 | 27 | import java.util.Optional; |
18 | 28 |
|
19 | 29 | import static org.fontory.fontorybe.authentication.application.AuthConstants.*; |
20 | 30 |
|
| 31 | +@Slf4j |
21 | 32 | @RestController |
22 | 33 | @RequiredArgsConstructor |
23 | 34 | public class DebugController { |
| 35 | + private final FontRepository fontRepository; |
| 36 | + private final CloudStorageService cloudStorageService; |
| 37 | + private final MemberLookupServiceImpl memberLookupService; |
24 | 38 | private final DevTokenInitializer devTokenInitializer; |
25 | 39 | private final FontRequestProducer fontRequestProducer; |
| 40 | + private final ApplicationEventPublisher eventPublisher; |
26 | 41 | private final CookieUtils cookieUtils; |
27 | 42 |
|
28 | 43 | @Value("${commit.hash}") |
@@ -72,4 +87,32 @@ public void login(HttpServletResponse res) { |
72 | 87 | public void logout(HttpServletResponse res) { |
73 | 88 | devTokenInitializer.removeTestAccessCookies(res); |
74 | 89 | } |
| 90 | + |
| 91 | + @PostMapping("/debug/re_request/fonts") |
| 92 | + public Boolean reRequestFonts( |
| 93 | + Long fontId, |
| 94 | + String notificationPhoneNumber |
| 95 | + ) { |
| 96 | + Optional<Font> optionalFont = fontRepository.findById(fontId); |
| 97 | + if (optionalFont.isEmpty()) { |
| 98 | + return false; |
| 99 | + } |
| 100 | + |
| 101 | + Font savedFont = optionalFont.get(); |
| 102 | + Member member = memberLookupService.getOrThrowById(savedFont.getMemberId()); |
| 103 | + |
| 104 | + // SQS 재요청 |
| 105 | + String fontPaperUrl = cloudStorageService.getFontPaperUrl(savedFont.getKey()); |
| 106 | + fontRequestProducer.sendFontRequest(FontRequestProduceDto.from(savedFont, member, fontPaperUrl)); |
| 107 | + |
| 108 | + // SMS 알림을 위한 레디스에 폰번호 다시 저장 |
| 109 | + if (notificationPhoneNumber != null && notificationPhoneNumber.isBlank()) { |
| 110 | + eventPublisher.publishEvent(new FontCreateRequestNotificationEvent(savedFont, notificationPhoneNumber)); |
| 111 | + } |
| 112 | + |
| 113 | + log.info("Response sent: Font created with ID: {}, name: {}, phone: {}", |
| 114 | + savedFont.getId(), savedFont.getName(), notificationPhoneNumber); |
| 115 | + |
| 116 | + return true; |
| 117 | + } |
75 | 118 | } |
0 commit comments