Skip to content

Commit f87e69b

Browse files
authored
Merge pull request #167 from YAPP-Github/feat/PRODUCT-255
[Feat] '최신 응원 검색 API'의 유저 정보 추가
2 parents 8d683aa + b36108c commit f87e69b

File tree

6 files changed

+29
-14
lines changed

6 files changed

+29
-14
lines changed
Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package eatda.controller.cheer;
22

33
import eatda.domain.cheer.Cheer;
4-
import eatda.domain.store.Store;
54

65
public record CheerPreviewResponse(
76
long storeId,
@@ -11,19 +10,23 @@ public record CheerPreviewResponse(
1110
String storeNeighborhood,
1211
String storeCategory,
1312
long cheerId,
14-
String cheerDescription
13+
String cheerDescription,
14+
long memberId,
15+
String memberNickname
1516
) {
1617

17-
public CheerPreviewResponse(Cheer cheer, Store store, String imageUrl) {
18+
public CheerPreviewResponse(Cheer cheer, String imageUrl) {
1819
this(
19-
store.getId(),
20+
cheer.getStore().getId(),
2021
imageUrl,
21-
store.getName(),
22-
store.getAddressDistrict(),
23-
store.getAddressNeighborhood(),
24-
store.getCategory().getCategoryName(),
22+
cheer.getStore().getName(),
23+
cheer.getStore().getAddressDistrict(),
24+
cheer.getStore().getAddressNeighborhood(),
25+
cheer.getStore().getCategory().getCategoryName(),
2526
cheer.getId(),
26-
cheer.getDescription()
27+
cheer.getDescription(),
28+
cheer.getMember().getId(),
29+
cheer.getMember().getNickname()
2730
);
2831
}
2932
}

src/main/java/eatda/repository/cheer/CheerRepository.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@
77
import java.util.List;
88
import java.util.Optional;
99
import org.springframework.data.domain.Pageable;
10+
import org.springframework.data.jpa.repository.EntityGraph;
1011
import org.springframework.data.jpa.repository.JpaRepository;
1112
import org.springframework.data.jpa.repository.Query;
1213

1314
public interface CheerRepository extends JpaRepository<Cheer, Long> {
1415

16+
@EntityGraph(attributePaths = {"store", "member"})
1517
List<Cheer> findAllByOrderByCreatedAtDesc(Pageable pageable);
1618

19+
@EntityGraph(attributePaths = {"member"})
1720
List<Cheer> findAllByStoreOrderByCreatedAtDesc(Store store, Pageable pageable);
1821

1922
@Query("""

src/main/java/eatda/service/cheer/CheerService.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ public CheersResponse getCheers(int page, int size) {
7171

7272
private CheersResponse toCheersResponse(List<Cheer> cheers) {
7373
return new CheersResponse(cheers.stream()
74-
.map(cheer -> new CheerPreviewResponse(cheer, cheer.getStore(),
75-
imageStorage.getPreSignedUrl(cheer.getImageKey())))
74+
.map(cheer -> new CheerPreviewResponse(cheer, imageStorage.getPreSignedUrl(cheer.getImageKey())))
7675
.toList());
7776
}
7877

src/main/resources/application.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ spring:
66
properties:
77
hibernate:
88
format_sql: true
9+
jdbc:
10+
batch_size: 100
11+
order_inserts: true
12+
order_updates: true
913
defer-datasource-initialization: false
1014
open-in-view: false
1115

src/test/java/eatda/document/store/CheerDocumentTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,9 @@ class GetCheers {
156156
fieldWithPath("cheers[].storeNeighborhood").type(STRING).description("가게 주소 (동)"),
157157
fieldWithPath("cheers[].storeCategory").type(STRING).description("가게 카테고리"),
158158
fieldWithPath("cheers[].cheerId").type(NUMBER).description("응원 ID"),
159-
fieldWithPath("cheers[].cheerDescription").type(STRING).description("응원 내용")
159+
fieldWithPath("cheers[].cheerDescription").type(STRING).description("응원 내용"),
160+
fieldWithPath("cheers[].memberId").type(NUMBER).description("응원 작성자 회원 ID"),
161+
fieldWithPath("cheers[].memberNickname").type(STRING).description("응원 작성자 닉네임")
160162
);
161163

162164
@Test
@@ -165,9 +167,9 @@ class GetCheers {
165167
int size = 2;
166168
CheersResponse responses = new CheersResponse(List.of(
167169
new CheerPreviewResponse(2L, "https://example.image", "농민백암순대 본점", "강남구", "선릉구", "한식", 2L,
168-
"너무 맛있어요!"),
170+
"너무 맛있어요!", 5L, "커찬"),
169171
new CheerPreviewResponse(1L, null, "석관동떡볶이", "성북구", "석관동", "기타", 1L,
170-
"너무 매워요! 하지만 맛있어요!")
172+
"너무 매워요! 하지만 맛있어요!", 8L, "찬커")
171173
));
172174
doReturn(responses).when(cheerService).getCheers(page, size);
173175

src/test/resources/application.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ spring:
2929
properties:
3030
hibernate:
3131
format_sql: true
32+
jdbc:
33+
batch_size: 100
34+
order_inserts: true
35+
order_updates: true
3236
hibernate:
3337
ddl-auto: create-drop
3438
open-in-view: false

0 commit comments

Comments
 (0)