Skip to content

Commit 0f10994

Browse files
authored
[DEPLOY] 일별 기록 조회 API 수정
Co-authored-by: 나용준 <141994188+youngJun99@users.noreply.github.com>
2 parents b8dd568 + e3662a6 commit 0f10994

4 files changed

Lines changed: 42 additions & 7 deletions

File tree

clokey-api/src/main/java/org/clokey/domain/history/dto/response/DailyHistoryResponse.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ public record DailyHistoryResponse(
1515
@Schema(description = "기록 날짜", example = "2025-01-01") LocalDate historyDate,
1616
@Schema(description = "상황 ID", example = "1") Long situationId,
1717
@Schema(description = "상황 이름", example = "데일리") String situationName,
18-
@Schema(description = "스타일 목록") List<DailyHistoryResponse.StylePayload> styles) {
18+
@Schema(description = "본문 내용", example = "오늘 날씨가 좋아서 산책을 다녀왔어요") String content,
19+
@Schema(description = "스타일 목록") List<DailyHistoryResponse.StylePayload> styles,
20+
@Schema(description = "해시태그 목록", example = "[\"데일리룩\", \"오늘의코디\"]") List<String> hashtags) {
1921

2022
public static DailyHistoryResponse of(
2123
Long memberId,
@@ -27,7 +29,9 @@ public static DailyHistoryResponse of(
2729
LocalDate historyDate,
2830
Long situationId,
2931
String situationName,
30-
List<StylePayload> styles) {
32+
String content,
33+
List<StylePayload> styles,
34+
List<String> hashtags) {
3135
return new DailyHistoryResponse(
3236
memberId,
3337
profileImageUrl,
@@ -38,7 +42,9 @@ public static DailyHistoryResponse of(
3842
historyDate,
3943
situationId,
4044
situationName,
41-
styles);
45+
content,
46+
styles,
47+
hashtags);
4248
}
4349

4450
@Schema(name = "DailyHistoryResponseImagePayload", description = "기록 이미지 정보")

clokey-api/src/main/java/org/clokey/domain/history/service/HistoryServiceImpl.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,11 @@ public DailyHistoryResponse getDailyHistory(Long historyId) {
245245
historyStyle.getStyle().getName()))
246246
.toList();
247247

248+
List<String> hashtags =
249+
historyHashtagRepository.findAllByHistoryIdWithHashtag(historyId).stream()
250+
.map(historyHashtag -> historyHashtag.getHashtag().getName())
251+
.toList();
252+
248253
return DailyHistoryResponse.of(
249254
history.getMember().getId(),
250255
history.getMember().getProfileImageUrl(),
@@ -255,7 +260,9 @@ public DailyHistoryResponse getDailyHistory(Long historyId) {
255260
history.getHistoryDate(),
256261
history.getSituation().getId(),
257262
history.getSituation().getName(),
258-
styles);
263+
history.getContent(),
264+
styles,
265+
hashtags);
259266
}
260267

261268
@Override

clokey-api/src/test/java/org/clokey/domain/history/controller/HistoryControllerTest.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -729,9 +729,11 @@ class 일별_기록_조회_요청_시 {
729729
java.time.LocalDate.of(2025, 1, 1),
730730
1L,
731731
"testSituation",
732+
"testContent",
732733
List.of(
733734
new DailyHistoryResponse.StylePayload(1L, "testStyle1"),
734-
new DailyHistoryResponse.StylePayload(2L, "testStyle2")));
735+
new DailyHistoryResponse.StylePayload(2L, "testStyle2")),
736+
List.of("testHashtag1", "testHashtag2"));
735737

736738
given(historyService.getDailyHistory(1L)).willReturn(testDailyHistoryResponse);
737739

@@ -755,10 +757,15 @@ class 일별_기록_조회_요청_시 {
755757
.andExpect(jsonPath("$.result.historyDate").value("2025-01-01"))
756758
.andExpect(jsonPath("$.result.situationId").value(1L))
757759
.andExpect(jsonPath("$.result.situationName").value("testSituation"))
760+
.andExpect(jsonPath("$.result.content").value("testContent"))
758761
.andExpect(jsonPath("$.result.styles").isArray())
759762
.andExpect(jsonPath("$.result.styles.length()").value(2))
760763
.andExpect(jsonPath("$.result.styles[0].styleId").value(1L))
761-
.andExpect(jsonPath("$.result.styles[0].styleName").value("testStyle1"));
764+
.andExpect(jsonPath("$.result.styles[0].styleName").value("testStyle1"))
765+
.andExpect(jsonPath("$.result.hashtags").isArray())
766+
.andExpect(jsonPath("$.result.hashtags.length()").value(2))
767+
.andExpect(jsonPath("$.result.hashtags[0]").value("testHashtag1"))
768+
.andExpect(jsonPath("$.result.hashtags[1]").value("testHashtag2"));
762769
}
763770
}
764771

clokey-api/src/test/java/org/clokey/domain/history/service/HistoryServiceImplTest.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1014,6 +1014,10 @@ void setUp() {
10141014
Style style2 = Style.createStyle("testStyle2");
10151015
styleRepository.saveAll(List.of(style1, style2));
10161016

1017+
Hashtag hashtag1 = Hashtag.createHashtag("testhashtag1");
1018+
Hashtag hashtag2 = Hashtag.createHashtag("testhashtag2");
1019+
hashtagRepository.saveAll(List.of(hashtag1, hashtag2));
1020+
10171021
History history1 =
10181022
History.createHistory(LocalDate.now(), "testContent1", member1, situation1);
10191023
History history2 =
@@ -1031,6 +1035,11 @@ void setUp() {
10311035
List.of(
10321036
HistoryStyle.createHistoryStyle(history1, style1),
10331037
HistoryStyle.createHistoryStyle(history1, style2)));
1038+
1039+
historyHashtagRepository.bulkInsertHistoryHashtags(
1040+
List.of(
1041+
HistoryHashtag.createHistoryHashtag(history1, hashtag1),
1042+
HistoryHashtag.createHistoryHashtag(history1, hashtag2)));
10341043
}
10351044

10361045
@Test
@@ -1045,9 +1054,11 @@ void setUp() {
10451054
DailyHistoryResponse::historyDate,
10461055
DailyHistoryResponse::situationId,
10471056
DailyHistoryResponse::situationName,
1057+
DailyHistoryResponse::content,
10481058
DailyHistoryResponse::likeCount,
10491059
DailyHistoryResponse::commentCount)
1050-
.containsExactly(1L, LocalDate.now(), 1L, "testSituation1", 0L, 0L);
1060+
.containsExactly(
1061+
1L, LocalDate.now(), 1L, "testSituation1", "testContent1", 0L, 0L);
10511062

10521063
assertThat(response.images()).hasSize(2);
10531064
assertThat(response.images())
@@ -1063,6 +1074,10 @@ void setUp() {
10631074
DailyHistoryResponse.StylePayload::styleId,
10641075
DailyHistoryResponse.StylePayload::styleName)
10651076
.containsExactlyInAnyOrder(tuple(1L, "testStyle1"), tuple(2L, "testStyle2"));
1077+
1078+
assertThat(response.hashtags()).hasSize(2);
1079+
assertThat(response.hashtags())
1080+
.containsExactlyInAnyOrder("testhashtag1", "testhashtag2");
10661081
}
10671082

10681083
@Test

0 commit comments

Comments
 (0)