|
6 | 6 | import com.todaysound.todaysound_server.domain.subscription.repository.SubscriptionRepository; |
7 | 7 | import com.todaysound.todaysound_server.global.exception.BaseException; |
8 | 8 | import com.todaysound.todaysound_server.global.exception.CommonErrorCode; |
| 9 | +import com.fasterxml.jackson.annotation.JsonProperty; |
9 | 10 | import lombok.RequiredArgsConstructor; |
10 | 11 | import org.springframework.web.bind.annotation.PostMapping; |
11 | 12 | import org.springframework.web.bind.annotation.RequestBody; |
@@ -37,33 +38,39 @@ public class InternalAlertController implements InternalAlertApi { |
37 | 38 |
|
38 | 39 | @PostMapping("/alerts") |
39 | 40 | public void createAlert(@RequestBody InternalAlertRequest request) { |
40 | | - Subscription subscription = subscriptionRepository.findById(request.subscription_id()) |
| 41 | + Subscription subscription = subscriptionRepository.findById(request.subscriptionId()) |
41 | 42 | .orElseThrow(() -> BaseException.type(CommonErrorCode.ENTITY_NOT_FOUND)); |
42 | 43 |
|
43 | | - // ๊ฐ๋จํ ์์ ์ ๊ฒ์ฆ (user_id ๊ฐ ๋ค๋ฅด๋ฉด ๊ฑฐ๋ถ) |
44 | | - if (!subscription.getUser().getId().equals(request.user_id())) { |
| 44 | + // ๊ฐ๋จํ ์์ ์ ๊ฒ์ฆ (userId ๊ฐ ๋ค๋ฅด๋ฉด ๊ฑฐ๋ถ) |
| 45 | + if (!subscription.getUser().getId().equals(request.userId())) { |
45 | 46 | throw BaseException.type(CommonErrorCode.FORBIDDEN); |
46 | 47 | } |
47 | 48 |
|
48 | | - // site_post_id ๋ฅผ ํด์ ํค๋ก ์ฌ์ฉ |
| 49 | + // sitePostId ๋ฅผ ํด์ ํค๋ก ์ฌ์ฉ |
49 | 50 | Summary summary = Summary.create( |
50 | | - request.site_post_id(), |
51 | | - request.content_summary(), |
| 51 | + request.sitePostId(), |
| 52 | + request.title(), |
| 53 | + request.contentSummary(), |
| 54 | + request.url(), |
| 55 | + request.publishedAt(), |
52 | 56 | subscription |
53 | 57 | ); |
54 | 58 |
|
55 | 59 | summaryRepository.save(summary); |
56 | 60 | } |
57 | 61 |
|
58 | 62 | public record InternalAlertRequest( |
59 | | - Long user_id, |
60 | | - Long subscription_id, |
61 | | - String site_post_id, |
62 | | - String title, |
63 | | - String url, |
64 | | - String content_raw, |
65 | | - String content_summary, |
66 | | - boolean is_urgent |
| 63 | + @JsonProperty("user_id") Long userId, |
| 64 | + @JsonProperty("subscription_id") Long subscriptionId, |
| 65 | + @JsonProperty("site_post_id") String sitePostId, |
| 66 | + @JsonProperty("site_alias") String siteAlias, |
| 67 | + @JsonProperty("title") String title, |
| 68 | + @JsonProperty("url") String url, |
| 69 | + @JsonProperty("published_at") String publishedAt, |
| 70 | + @JsonProperty("content_raw") String contentRaw, |
| 71 | + @JsonProperty("content_summary") String contentSummary, |
| 72 | + @JsonProperty("is_urgent") boolean isUrgent, |
| 73 | + @JsonProperty("keyword_matched") boolean keywordMatched |
67 | 74 | ) { |
68 | 75 | } |
69 | 76 | } |
|
0 commit comments