Skip to content

Commit bdc8cf0

Browse files
authored
Merge pull request #47 from Today-s-Sound/refactor/#41-test1
[refactor] #41 PathVariable ์˜ค๋ฅ˜ ์ˆ˜์ •
2 parents ad45ade + 9218c50 commit bdc8cf0

File tree

4 files changed

+41
-19
lines changed

4 files changed

+41
-19
lines changed

โ€Žsrc/main/java/com/todaysound/todaysound_server/domain/alarm/controller/InternalAlertController.javaโ€Ž

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.todaysound.todaysound_server.domain.subscription.repository.SubscriptionRepository;
77
import com.todaysound.todaysound_server.global.exception.BaseException;
88
import com.todaysound.todaysound_server.global.exception.CommonErrorCode;
9+
import com.fasterxml.jackson.annotation.JsonProperty;
910
import lombok.RequiredArgsConstructor;
1011
import org.springframework.web.bind.annotation.PostMapping;
1112
import org.springframework.web.bind.annotation.RequestBody;
@@ -37,33 +38,39 @@ public class InternalAlertController implements InternalAlertApi {
3738

3839
@PostMapping("/alerts")
3940
public void createAlert(@RequestBody InternalAlertRequest request) {
40-
Subscription subscription = subscriptionRepository.findById(request.subscription_id())
41+
Subscription subscription = subscriptionRepository.findById(request.subscriptionId())
4142
.orElseThrow(() -> BaseException.type(CommonErrorCode.ENTITY_NOT_FOUND));
4243

43-
// ๊ฐ„๋‹จํ•œ ์†Œ์œ ์ž ๊ฒ€์ฆ (user_id ๊ฐ€ ๋‹ค๋ฅด๋ฉด ๊ฑฐ๋ถ€)
44-
if (!subscription.getUser().getId().equals(request.user_id())) {
44+
// ๊ฐ„๋‹จํ•œ ์†Œ์œ ์ž ๊ฒ€์ฆ (userId ๊ฐ€ ๋‹ค๋ฅด๋ฉด ๊ฑฐ๋ถ€)
45+
if (!subscription.getUser().getId().equals(request.userId())) {
4546
throw BaseException.type(CommonErrorCode.FORBIDDEN);
4647
}
4748

48-
// site_post_id ๋ฅผ ํ•ด์‹œ ํ‚ค๋กœ ์‚ฌ์šฉ
49+
// sitePostId ๋ฅผ ํ•ด์‹œ ํ‚ค๋กœ ์‚ฌ์šฉ
4950
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(),
5256
subscription
5357
);
5458

5559
summaryRepository.save(summary);
5660
}
5761

5862
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
6774
) {
6875
}
6976
}

โ€Žsrc/main/java/com/todaysound/todaysound_server/domain/subscription/controller/InternalSubscriptionController.javaโ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public List<InternalSubscriptionResponseDto> getSubscriptions() {
4040
@PatchMapping("/subscriptions/{id}/last_seen")
4141
@Transactional
4242
public void updateLastSeenPostId(
43-
@PathVariable Long id,
43+
@PathVariable("id") Long id,
4444
@RequestBody UpdateLastSeenPostRequest request
4545
) {
4646
Subscription subscription = subscriptionRepository.findById(id)

โ€Žsrc/main/java/com/todaysound/todaysound_server/domain/summary/entity/Summary.javaโ€Ž

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ public class Summary extends BaseEntity {
2929
@Column(name = "title", nullable = false)
3030
private String title;
3131

32+
@Column(name = "post_url", nullable = false)
33+
private String postUrl;
34+
35+
@Column(name = "post_date")
36+
private String postDate;
37+
3238
@Column(name = "is_read", nullable = false)
3339
private boolean isRead;
3440

@@ -43,10 +49,15 @@ public class Summary extends BaseEntity {
4349
private Subscription subscription;
4450

4551
// Summary ์ƒ์„ฑ ํŒฉํ† ๋ฆฌ ๋ฉ”์„œ๋“œ
46-
public static Summary create(String hash, String content, Subscription subscription) {
52+
public static Summary create(String hash, String title, String content,
53+
String postUrl, String postDate,
54+
Subscription subscription) {
4755
Summary summary = new Summary();
4856
summary.hash = hash;
57+
summary.title = title;
4958
summary.content = content;
59+
summary.postUrl = postUrl;
60+
summary.postDate = postDate;
5061
summary.isRead = false;
5162
summary.createdAt = LocalDateTime.now();
5263
summary.updatedAt = LocalDateTime.now();

โ€Žsrc/main/resources/application-local.ymlโ€Ž

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
spring:
22
datasource:
3-
url: ${DB_URL}
4-
username: ${DB_USERNAME}
5-
password: ${DB_PASSWORD}
3+
# url: ${DB_URL}
4+
# username: ${DB_USERNAME}
5+
# password: ${DB_PASSWORD}
6+
7+
url: jdbc:mysql://localhost:3306/today_sound_local?serverTimezone=Asia/Seoul
8+
username: root
9+
password: 1234
610

711
driver-class-name: com.mysql.cj.jdbc.Driver
812

0 commit comments

Comments
ย (0)