Skip to content

Commit e01e13b

Browse files
authored
[Fix/#277] API 수정(룩북 코디 개수 반환 로직, 일일조회 기록 본인 여부 필드 추가) (#278)
* update: 코디 개수 반환 * update: 기록 작성자 본인 여부 필드 추가
1 parent 1d7e1e1 commit e01e13b

7 files changed

Lines changed: 13 additions & 8 deletions

File tree

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public record DailyHistoryResponse(
99
@Schema(description = "프로필 이미지 URL", example = "https://example.com/profile.jpg")
1010
String profileImageUrl,
1111
@Schema(description = "닉네임", example = "포테토남") String nickname,
12+
@Schema(description = "작성자 본인 여부", example = "true") Boolean isMine,
1213
@Schema(description = "기록 이미지 목록") List<DailyHistoryResponse.ImagePayload> images,
1314
@Schema(description = "좋아요 개수", example = "10") Long likeCount,
1415
@Schema(description = "좋아요 여부", example = "true") Boolean liked,
@@ -24,6 +25,7 @@ public static DailyHistoryResponse of(
2425
Long memberId,
2526
String profileImageUrl,
2627
String nickname,
28+
Boolean isMine,
2729
List<ImagePayload> images,
2830
Long likeCount,
2931
boolean liked,
@@ -38,6 +40,7 @@ public static DailyHistoryResponse of(
3840
memberId,
3941
profileImageUrl,
4042
nickname,
43+
isMine,
4144
images,
4245
likeCount,
4346
liked,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ public DailyHistoryResponse getDailyHistory(Long historyId) {
266266
history.getMember().getId(),
267267
history.getMember().getProfileImageUrl(),
268268
history.getMember().getNickname(),
269+
history.getMember().getId().equals(currentMember.getId()),
269270
images,
270271
likeCount,
271272
liked,

clokey-api/src/main/java/org/clokey/domain/lookbook/dto/response/LookBookListResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
public record LookBookListResponse(
66
@Schema(description = "룩북 ID", example = "1") Long lookBookId,
77
@Schema(description = "룩북 이름", example = "데이트 룩") String lookBookName,
8-
@Schema(description = "룩북 개수", example = "3") Long count,
8+
@Schema(description = "코디 개수", example = "3") Long count,
99
@Schema(description = "대표 코디 사진 (첫 번째 코디)", example = "https://example.jpg")
1010
String imageUrl) {}

clokey-api/src/main/java/org/clokey/domain/lookbook/repository/LookBookRepositoryImpl.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import lombok.RequiredArgsConstructor;
1212
import org.clokey.domain.lookbook.dto.response.LookBookListResponse;
1313
import org.clokey.global.paging.SortDirection;
14-
import org.clokey.lookbook.entity.QLookBook;
1514
import org.springframework.data.domain.PageRequest;
1615
import org.springframework.data.domain.Slice;
1716
import org.springframework.data.domain.SliceImpl;
@@ -26,18 +25,16 @@ public class LookBookRepositoryImpl implements LookBookRepositoryCustom {
2625
@Override
2726
public Slice<LookBookListResponse> findAllLookBookByMemberId(
2827
Long currentMemberId, Long lastLookBookId, int size, SortDirection direction) {
29-
QLookBook lookBookSub = new QLookBook("lookBookSub");
30-
3128
List<LookBookListResponse> results =
3229
queryFactory
3330
.select(
3431
Projections.constructor(
3532
LookBookListResponse.class,
3633
lookBook.id,
3734
lookBook.name,
38-
JPAExpressions.select(lookBookSub.count())
39-
.from(lookBookSub)
40-
.where(lookBookSub.member.id.eq(currentMemberId)),
35+
JPAExpressions.select(coordinate.count())
36+
.from(coordinate)
37+
.where(coordinate.lookBook.id.eq(lookBook.id)),
4138
JPAExpressions.select(coordinate.imageUrl)
4239
.from(coordinate)
4340
.where(coordinate.lookBook.id.eq(lookBook.id))

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,7 @@ class 일별_기록_조회_요청_시 {
721721
1L,
722722
"testProfileImageUrl",
723723
"testNickname",
724+
true,
724725
List.of(
725726
new DailyHistoryResponse.ImagePayload(1L, "testImageUrl1"),
726727
new DailyHistoryResponse.ImagePayload(2L, "testImageUrl2")),
@@ -749,6 +750,7 @@ class 일별_기록_조회_요청_시 {
749750
.andExpect(jsonPath("$.result.memberId").value(1L))
750751
.andExpect(jsonPath("$.result.profileImageUrl").value("testProfileImageUrl"))
751752
.andExpect(jsonPath("$.result.nickname").value("testNickname"))
753+
.andExpect(jsonPath("$.result.isMine").value(true))
752754
.andExpect(jsonPath("$.result.images").isArray())
753755
.andExpect(jsonPath("$.result.images.length()").value(2))
754756
.andExpect(jsonPath("$.result.images[0].imageId").value(1L))

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,7 @@ void setUp() {
10541054
assertThat(response)
10551055
.extracting(
10561056
DailyHistoryResponse::memberId,
1057+
DailyHistoryResponse::isMine,
10571058
DailyHistoryResponse::historyDate,
10581059
DailyHistoryResponse::situationId,
10591060
DailyHistoryResponse::situationName,
@@ -1063,6 +1064,7 @@ void setUp() {
10631064
DailyHistoryResponse::commentCount)
10641065
.containsExactly(
10651066
1L,
1067+
true,
10661068
LocalDate.now(),
10671069
1L,
10681070
"testSituation1",

clokey-api/src/test/java/org/clokey/domain/lookbook/service/LookBookServiceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ void setUp() {
317317
() ->
318318
assertThat(response.content())
319319
.extracting("count")
320-
.containsExactly(3L, 3L, 3L));
320+
.containsExactly(1L, 1L, 0L));
321321
}
322322

323323
@Test

0 commit comments

Comments
 (0)