From 333420fd98a216e784d33af81d93253f664b6592 Mon Sep 17 00:00:00 2001 From: coPpark Date: Sat, 7 Sep 2024 10:01:43 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=EA=B8=B0=EC=A1=B4=20=EC=B5=9C?= =?UTF-8?q?=EC=8B=A0=EB=A6=AC=EC=8A=A4=ED=8A=B8API=20->=20=EC=B5=9C?= =?UTF-8?q?=EC=8B=A0=EB=A6=AC=EC=8A=A4=ED=8A=B8=EC=99=80=20=ED=8C=94?= =?UTF-8?q?=EB=A1=9C=EC=9E=89=EB=A6=AC=EC=8A=A4=ED=8A=B8=20API=EB=A1=9C=20?= =?UTF-8?q?=EB=B6=84=EB=A6=AC=20(#292)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 기존 optionalAuth에 대한 최신리스트 API 에서 최신리스트 API, 팔로잉리스트 API로 분해 * test: 분리된 최신리스트 조회 API에 맞게 테스트 코드 수정 * fix: 코드 리뷰를 통해 명칭 변경 --- .../common/auth/AuthorizationInterceptor.java | 1 + .../application/domain/list/ListEntity.java | 7 +++ .../dto/response/ListRecentResponse.java | 37 ++-------------- .../list/application/service/ListService.java | 33 +++++++------- .../controller/ListController.java | 14 +++++- .../list/custom/CustomListRepository.java | 2 +- .../custom/impl/CustomListRepositoryImpl.java | 5 +-- .../acceptance/list/ListAcceptanceTest.java | 44 +++++-------------- .../list/ListAcceptanceTestHelper.java | 8 ++-- .../listywave/list/fixture/ListFixture.java | 7 +++ 10 files changed, 66 insertions(+), 92 deletions(-) diff --git a/src/main/java/com/listywave/common/auth/AuthorizationInterceptor.java b/src/main/java/com/listywave/common/auth/AuthorizationInterceptor.java index d0ae5120..66cbe6c9 100644 --- a/src/main/java/com/listywave/common/auth/AuthorizationInterceptor.java +++ b/src/main/java/com/listywave/common/auth/AuthorizationInterceptor.java @@ -27,6 +27,7 @@ public class AuthorizationInterceptor implements HandlerInterceptor { new UriAndMethod("/lists/upload-url", GET), new UriAndMethod("/lists/upload-complete", GET), new UriAndMethod("/lists/{listId}/histories", GET), + new UriAndMethod("/lists", GET), new UriAndMethod("/users/{userId}/lists", GET), new UriAndMethod("/users/{userId}/followers", GET), new UriAndMethod("/users/{userId}/followings", GET), diff --git a/src/main/java/com/listywave/list/application/domain/list/ListEntity.java b/src/main/java/com/listywave/list/application/domain/list/ListEntity.java index bca172d6..fcd0a3ed 100644 --- a/src/main/java/com/listywave/list/application/domain/list/ListEntity.java +++ b/src/main/java/com/listywave/list/application/domain/list/ListEntity.java @@ -91,6 +91,9 @@ public class ListEntity { @Embedded private Items items; + @Column(nullable = false) + private int updateCount; + @CreatedDate @Temporal(TIMESTAMP) @Column(updatable = false) @@ -259,4 +262,8 @@ public void validateUpdateAuthority(User loginUser, Collaborators beforeCollabor } throw new CustomException(INVALID_ACCESS); } + + public void increaseUpdateCount(){ + this.updateCount++; + } } diff --git a/src/main/java/com/listywave/list/application/dto/response/ListRecentResponse.java b/src/main/java/com/listywave/list/application/dto/response/ListRecentResponse.java index 9a433495..34df3a3b 100644 --- a/src/main/java/com/listywave/list/application/dto/response/ListRecentResponse.java +++ b/src/main/java/com/listywave/list/application/dto/response/ListRecentResponse.java @@ -1,7 +1,6 @@ package com.listywave.list.application.dto.response; import com.listywave.list.application.domain.item.Item; -import com.listywave.list.application.domain.label.Label; import com.listywave.list.application.domain.list.ListEntity; import java.time.LocalDateTime; import java.util.Comparator; @@ -25,15 +24,13 @@ public static ListRecentResponse of(List lists, LocalDateTime cursor @Builder public record ListResponse( Long id, - String category, - String backgroundColor, Long ownerId, String ownerNickname, String ownerProfileImage, - List labels, String title, String description, - List items + List items, + int updateCount ) { public static List toList(List lists) { @@ -45,35 +42,13 @@ public static List toList(List lists) { public static ListResponse of(ListEntity list) { return ListResponse.builder() .id(list.getId()) - .category(list.getCategory().getViewName()) - .backgroundColor(list.getBackgroundColor().name()) .ownerId(list.getUser().getId()) .ownerNickname(list.getUser().getNickname()) .ownerProfileImage(list.getUser().getProfileImageUrl()) - .labels(LabelsResponse.toList(list.getLabels().getValues())) .title(list.getTitle().getValue()) .description(list.getDescription().getValue()) .items(ItemsResponse.toList(list.getTop3Items().getValues())) - .build(); - } - } - - @Builder - public record LabelsResponse( - Long id, - String name - ) { - - public static List toList(List