From ac05798d891e51a3c5c48fe219cf1b3eaefa4b0e Mon Sep 17 00:00:00 2001 From: FaberJoo Date: Fri, 10 Nov 2023 20:50:13 +0900 Subject: [PATCH 01/13] =?UTF-8?q?feat:=20=ED=9A=8C=EC=9B=90=20=EB=B6=81?= =?UTF-8?q?=EB=A7=88=ED=81=AC=20=EA=B0=AF=EC=88=98=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EC=9D=91=EB=8B=B5=20dto=20#98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/oduck/api/domain/bookmark/dto/BookmarkResDto.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/io/oduck/api/domain/bookmark/dto/BookmarkResDto.java b/src/main/java/io/oduck/api/domain/bookmark/dto/BookmarkResDto.java index 08dfe1f2..142f8b83 100644 --- a/src/main/java/io/oduck/api/domain/bookmark/dto/BookmarkResDto.java +++ b/src/main/java/io/oduck/api/domain/bookmark/dto/BookmarkResDto.java @@ -10,6 +10,13 @@ import lombok.NoArgsConstructor; public class BookmarkResDto { + @Getter + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class BookmarkCountRes { + private Long count; + } @Getter @Builder @NoArgsConstructor(access = AccessLevel.PROTECTED) From 3626ce504f50c062f4150d785712c4c153cea940 Mon Sep 17 00:00:00 2001 From: FaberJoo Date: Fri, 10 Nov 2023 20:50:38 +0900 Subject: [PATCH 02/13] =?UTF-8?q?feat:=20=ED=9A=8C=EC=9B=90=20=EB=B6=81?= =?UTF-8?q?=EB=A7=88=ED=81=AC=20=EA=B0=AF=EC=88=98=20=EC=A1=B0=ED=9A=8C?= =?UTF-8?q?=EB=A5=BC=20=EC=9C=84=ED=95=9C=20=EC=BF=BC=EB=A6=AC=20=EB=A9=94?= =?UTF-8?q?=EC=86=8C=EB=93=9C=20=EC=B6=94=EA=B0=80=20#98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../oduck/api/domain/bookmark/repository/BookmarkRepository.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/io/oduck/api/domain/bookmark/repository/BookmarkRepository.java b/src/main/java/io/oduck/api/domain/bookmark/repository/BookmarkRepository.java index 10affd8d..286e199d 100644 --- a/src/main/java/io/oduck/api/domain/bookmark/repository/BookmarkRepository.java +++ b/src/main/java/io/oduck/api/domain/bookmark/repository/BookmarkRepository.java @@ -7,6 +7,7 @@ @Repository public interface BookmarkRepository extends JpaRepository, BookmarkRepositoryCustom { + Long countByMemberId(Long memberId); Optional findByMemberIdAndAnimeId(Long memberId, Long animeId); } From 471a91d2983bb5851de5a8a6ce6c66d9e27205c0 Mon Sep 17 00:00:00 2001 From: FaberJoo Date: Fri, 10 Nov 2023 20:50:56 +0900 Subject: [PATCH 03/13] =?UTF-8?q?feat:=20=ED=9A=8C=EC=9B=90=20=EB=B6=81?= =?UTF-8?q?=EB=A7=88=ED=81=AC=20=EA=B0=AF=EC=88=98=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80=20#98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/domain/bookmark/service/BookmarkService.java | 2 ++ .../api/domain/bookmark/service/BookmarkServiceImpl.java | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/src/main/java/io/oduck/api/domain/bookmark/service/BookmarkService.java b/src/main/java/io/oduck/api/domain/bookmark/service/BookmarkService.java index 93baaae0..c2e320b0 100644 --- a/src/main/java/io/oduck/api/domain/bookmark/service/BookmarkService.java +++ b/src/main/java/io/oduck/api/domain/bookmark/service/BookmarkService.java @@ -1,5 +1,6 @@ package io.oduck.api.domain.bookmark.service; +import io.oduck.api.domain.bookmark.dto.BookmarkResDto.BookmarkCountRes; import io.oduck.api.domain.bookmark.dto.BookmarkResDto.BookmarkRes; import io.oduck.api.domain.bookmark.dto.BookmarkReqDto.Sort; import io.oduck.api.domain.bookmark.dto.BookmarkResDto.BookmarkedDateTimeRes; @@ -9,6 +10,7 @@ public interface BookmarkService { boolean toggleBookmark(Long memberId, Long animeId); BookmarkedDateTimeRes checkBookmarked(Long memberId, Long animeId); + BookmarkCountRes getBookmarksCountByMemberId(Long memberId); SliceResponse getBookmarksByMemberId(Long memberId, String cursor, Sort sort, OrderDirection order, int size); } diff --git a/src/main/java/io/oduck/api/domain/bookmark/service/BookmarkServiceImpl.java b/src/main/java/io/oduck/api/domain/bookmark/service/BookmarkServiceImpl.java index 9d256ca9..6470c875 100644 --- a/src/main/java/io/oduck/api/domain/bookmark/service/BookmarkServiceImpl.java +++ b/src/main/java/io/oduck/api/domain/bookmark/service/BookmarkServiceImpl.java @@ -6,6 +6,7 @@ import io.oduck.api.domain.anime.repository.AnimeRepository; import io.oduck.api.domain.bookmark.dto.BookmarkDslDto.BookmarkDsl; import io.oduck.api.domain.bookmark.dto.BookmarkReqDto; +import io.oduck.api.domain.bookmark.dto.BookmarkResDto.BookmarkCountRes; import io.oduck.api.domain.bookmark.dto.BookmarkResDto.BookmarkRes; import io.oduck.api.domain.bookmark.dto.BookmarkResDto.BookmarkedDateTimeRes; import io.oduck.api.domain.bookmark.entity.Bookmark; @@ -74,6 +75,14 @@ public BookmarkedDateTimeRes checkBookmarked(Long memberId, Long animeId) { throw new NotFoundException("bookmark"); } + @Override + public BookmarkCountRes getBookmarksCountByMemberId(Long memberId) { + Long count = bookmarkRepository.countByMemberId(memberId); + return BookmarkCountRes.builder() + .count(count) + .build(); + } + @Override public SliceResponse getBookmarksByMemberId(Long memberId, String cursor, BookmarkReqDto.Sort sort, OrderDirection order, int size) { Sort sortList = Sort.by( From 2157179c1ad1f548b243bc04305e1944b2a4c9a6 Mon Sep 17 00:00:00 2001 From: FaberJoo Date: Fri, 10 Nov 2023 20:52:23 +0900 Subject: [PATCH 04/13] =?UTF-8?q?feat:=20=ED=9A=8C=EC=9B=90=EC=9D=B4=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1=ED=95=9C=20=EC=A7=A7=EC=9D=80=20=EB=A6=AC?= =?UTF-8?q?=EB=B7=B0=20=EC=A1=B0=ED=9A=8C=20=EA=B0=AF=EC=88=98=20=EC=9D=91?= =?UTF-8?q?=EB=8B=B5=20dto=20=EC=B6=94=EA=B0=80=20#98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/oduck/api/domain/review/dto/ShortReviewResDto.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/io/oduck/api/domain/review/dto/ShortReviewResDto.java b/src/main/java/io/oduck/api/domain/review/dto/ShortReviewResDto.java index ef165115..fda1872f 100644 --- a/src/main/java/io/oduck/api/domain/review/dto/ShortReviewResDto.java +++ b/src/main/java/io/oduck/api/domain/review/dto/ShortReviewResDto.java @@ -54,4 +54,12 @@ public String bringCursor(String property) { }; } } + + @Getter + @Builder + @NoArgsConstructor + @AllArgsConstructor + public static class ShortReviewCountRes { + private Long count; + } } From 043a219d214e765a8d4026c1a38653a3b0048add Mon Sep 17 00:00:00 2001 From: FaberJoo Date: Fri, 10 Nov 2023 20:52:39 +0900 Subject: [PATCH 05/13] =?UTF-8?q?feat:=20=ED=9A=8C=EC=9B=90=EC=9D=B4=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1=ED=95=9C=20=EC=A7=A7=EC=9D=80=20=EB=A6=AC?= =?UTF-8?q?=EB=B7=B0=20=EA=B0=AF=EC=88=98=20=EC=BF=BC=EB=A6=AC=20=EB=A9=94?= =?UTF-8?q?=EC=86=8C=EB=93=9C=20=EC=B6=94=EA=B0=80=20#98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/domain/review/repository/ShortReviewRepository.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/io/oduck/api/domain/review/repository/ShortReviewRepository.java b/src/main/java/io/oduck/api/domain/review/repository/ShortReviewRepository.java index 59f17003..f26e0814 100644 --- a/src/main/java/io/oduck/api/domain/review/repository/ShortReviewRepository.java +++ b/src/main/java/io/oduck/api/domain/review/repository/ShortReviewRepository.java @@ -6,6 +6,5 @@ @Repository public interface ShortReviewRepository extends JpaRepository, ShortReviewRepositoryCustom { - - + Long countByMemberId(Long memberId); } From 29d44465e016f16e1ccb6e548bd1d999cd488226 Mon Sep 17 00:00:00 2001 From: FaberJoo Date: Fri, 10 Nov 2023 20:53:36 +0900 Subject: [PATCH 06/13] =?UTF-8?q?feat:=20=ED=9A=8C=EC=9B=90=EC=9D=B4=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1=ED=95=9C=20=EC=A7=A7=EC=9D=80=20=EB=A6=AC?= =?UTF-8?q?=EB=B7=B0=20=EA=B0=AF=EC=88=98=20=EC=A1=B0=ED=9A=8C=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=B6=94=EA=B0=80=20#98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/domain/review/service/ShortReviewService.java | 2 ++ .../domain/review/service/ShortReviewServiceImpl.java | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/src/main/java/io/oduck/api/domain/review/service/ShortReviewService.java b/src/main/java/io/oduck/api/domain/review/service/ShortReviewService.java index c6bdb495..0f53d71e 100644 --- a/src/main/java/io/oduck/api/domain/review/service/ShortReviewService.java +++ b/src/main/java/io/oduck/api/domain/review/service/ShortReviewService.java @@ -3,6 +3,7 @@ import io.oduck.api.domain.review.dto.ShortReviewReqDto.PatchShortReviewReq; import io.oduck.api.domain.review.dto.ShortReviewReqDto.PostShortReviewReq; import io.oduck.api.domain.review.dto.ShortReviewReqDto.Sort; +import io.oduck.api.domain.review.dto.ShortReviewResDto.ShortReviewCountRes; import io.oduck.api.domain.review.dto.ShortReviewResDto.ShortReviewRes; import io.oduck.api.global.common.OrderDirection; import io.oduck.api.global.common.SliceResponse; @@ -14,6 +15,7 @@ public interface ShortReviewService { //애니 짧은 리뷰 조회 SliceResponse getShortReviews(Long animeId, String cursor, Sort sort, OrderDirection order, int size); + ShortReviewCountRes getShortReviewCountByMemberId(Long memberId); //애니 리뷰 수정 void update(Long memberId, Long reviewId, PatchShortReviewReq req); diff --git a/src/main/java/io/oduck/api/domain/review/service/ShortReviewServiceImpl.java b/src/main/java/io/oduck/api/domain/review/service/ShortReviewServiceImpl.java index 15561939..47c72870 100644 --- a/src/main/java/io/oduck/api/domain/review/service/ShortReviewServiceImpl.java +++ b/src/main/java/io/oduck/api/domain/review/service/ShortReviewServiceImpl.java @@ -11,6 +11,7 @@ import io.oduck.api.domain.review.dto.ShortReviewReqDto; import io.oduck.api.domain.review.dto.ShortReviewReqDto.PatchShortReviewReq; import io.oduck.api.domain.review.dto.ShortReviewReqDto.PostShortReviewReq; +import io.oduck.api.domain.review.dto.ShortReviewResDto.ShortReviewCountRes; import io.oduck.api.domain.review.dto.ShortReviewResDto.ShortReviewRes; import io.oduck.api.domain.review.entity.ShortReview; import io.oduck.api.domain.review.repository.ShortReviewRepository; @@ -99,6 +100,14 @@ public SliceResponse getShortReviews(Long animeId, String cursor return SliceResponse.of(shortReviews, res, sort.getSort()); } + @Override + public ShortReviewCountRes getShortReviewCountByMemberId(Long memberId) { + Long count = shortReviewRepository.countByMemberId(memberId); + return ShortReviewCountRes.builder() + .count(count) + .build(); + } + @Override public void update(Long memberId, Long reviewId, PatchShortReviewReq req) { ShortReview findShortReview = getShortReview(reviewId); From 766d51fab6073d5e045127f18bdcd196f9282824 Mon Sep 17 00:00:00 2001 From: FaberJoo Date: Fri, 10 Nov 2023 20:54:03 +0900 Subject: [PATCH 07/13] =?UTF-8?q?feat:=20=ED=9A=8C=EC=9B=90=20=EB=B6=81?= =?UTF-8?q?=EB=A7=88=ED=81=AC=20=EA=B0=AF=EC=88=98=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EB=B0=8F=20=EC=9E=91=EC=84=B1=ED=95=9C=20=EC=A7=A7=EC=9D=80=20?= =?UTF-8?q?=EB=A6=AC=EB=B7=B0=20=EA=B0=AF=EC=88=98=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=ED=95=B8=EB=93=A4=EB=9F=AC=20=EC=B6=94=EA=B0=80=20#98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/controller/MemberController.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/oduck/api/domain/member/controller/MemberController.java b/src/main/java/io/oduck/api/domain/member/controller/MemberController.java index 8af7c2f9..10c04422 100644 --- a/src/main/java/io/oduck/api/domain/member/controller/MemberController.java +++ b/src/main/java/io/oduck/api/domain/member/controller/MemberController.java @@ -7,6 +7,7 @@ import io.oduck.api.domain.bookmark.dto.BookmarkReqDto.Sort; import io.oduck.api.domain.member.dto.MemberResDto.MemberProfileRes; import io.oduck.api.domain.member.service.MemberService; +import io.oduck.api.domain.review.service.ShortReviewService; import io.oduck.api.global.common.OrderDirection; import io.oduck.api.global.common.SliceResponse; import io.oduck.api.global.security.auth.dto.AuthUser; @@ -14,6 +15,7 @@ import jakarta.validation.Valid; import jakarta.validation.constraints.Max; import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.Positive; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; @@ -33,6 +35,7 @@ public class MemberController { private final MemberService memberService; private final BookmarkService bookmarkService; + private final ShortReviewService shortReviewService; // 로컬 회원 가입 @PostMapping @@ -70,7 +73,7 @@ public ResponseEntity patchProfile( @GetMapping("/{id}/bookmarks") public ResponseEntity getBookmaks( - @PathVariable("id") Long id, + @PathVariable("id") @Positive Long id, @RequestParam(required = false) String cursor, @RequestParam(required = false, defaultValue = "created_at") Sort sort, @RequestParam(required = false, defaultValue = "DESC") OrderDirection order, @@ -80,6 +83,13 @@ public ResponseEntity getBookmaks( SliceResponse res = bookmarkService.getBookmarksByMemberId(id, cursor, sort, order, size); return ResponseEntity.ok(res); } + + @GetMapping("/{id}/bookmarks/count") + public ResponseEntity getBookmarksCount( + @PathVariable("id") @Positive Long id + ) { + return ResponseEntity.ok(bookmarkService.getBookmarksCountByMemberId(id)); + } // // @GetMapping("/{name}/short-reviews") // public ResponseEntity getShortReviews( @@ -87,4 +97,11 @@ public ResponseEntity getBookmaks( // ) { // return ResponseEntity.ok(SliceResponse.of()); // } + + @GetMapping("/{id}/short-reviews/count") + public ResponseEntity getShoertReviewsCount( + @PathVariable("id") @Positive Long id + ) { + return ResponseEntity.ok(shortReviewService.getShortReviewCountByMemberId(id)); + } } From 3f5ba32354fcd9eb3a609af16b090fd5ad8a6326 Mon Sep 17 00:00:00 2001 From: FaberJoo Date: Fri, 10 Nov 2023 22:41:15 +0900 Subject: [PATCH 08/13] =?UTF-8?q?test:=20=ED=9A=8C=EC=9B=90=20=EB=B6=81?= =?UTF-8?q?=EB=A7=88=ED=81=AC=20=EA=B0=AF=EC=88=98=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?repository=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=B6=94=EA=B0=80?= =?UTF-8?q?=20#98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/BookmarkRepositoryTest.java | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/test/java/io/oduck/api/unit/bookmark/repository/BookmarkRepositoryTest.java b/src/test/java/io/oduck/api/unit/bookmark/repository/BookmarkRepositoryTest.java index 38123dfc..dbbf30e2 100644 --- a/src/test/java/io/oduck/api/unit/bookmark/repository/BookmarkRepositoryTest.java +++ b/src/test/java/io/oduck/api/unit/bookmark/repository/BookmarkRepositoryTest.java @@ -1,6 +1,7 @@ package io.oduck.api.unit.bookmark.repository; import static io.oduck.api.global.utils.PagingUtils.applyPageableForNonOffset; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import io.oduck.api.domain.bookmark.dto.BookmarkDslDto.BookmarkDsl; @@ -22,7 +23,7 @@ @ActiveProfiles("test") public class BookmarkRepositoryTest { @Autowired - BookmarkRepository memberRepository; + BookmarkRepository bookmarkRepository; @DisplayName("회원 북마크 애니 목록 조회") @Nested @@ -36,7 +37,7 @@ void selectBookmarksSuccess() { Pageable pageable = applyPageableForNonOffset(10, "createdAt", "desc"); // when - Slice bookmarks = memberRepository.selectBookmarks(memberId, null, pageable); + Slice bookmarks = bookmarkRepository.selectBookmarks(memberId, null, pageable); assertNotNull(bookmarks); assertNotNull(bookmarks.getContent().get(0).getAnimeId()); @@ -45,4 +46,21 @@ void selectBookmarksSuccess() { } } + @DisplayName("회원 북마크 애니 갯수 조회") + @Nested + class selectBookmarkCount { + @DisplayName("회원 ID로 회원이 북마크한 애니 갯수 조회 성공") + @Test + void selectBookmarkCountSuccess() { + // given + Long memberId = 1L; + + // when + Long bookmarkCount = bookmarkRepository.countByMemberId(memberId); + + // then + assertNotNull(bookmarkCount); + assertEquals(3L, bookmarkCount); + } + } } From 806a7e12eb812822bfb4294a748c679efe5ba2bb Mon Sep 17 00:00:00 2001 From: FaberJoo Date: Fri, 10 Nov 2023 22:41:36 +0900 Subject: [PATCH 09/13] =?UTF-8?q?test:=20=ED=9A=8C=EC=9B=90=20=EB=B6=81?= =?UTF-8?q?=EB=A7=88=ED=81=AC=20=EA=B0=AF=EC=88=98=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20#98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bookmark/service/BookmarkServiceTest.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/test/java/io/oduck/api/unit/bookmark/service/BookmarkServiceTest.java b/src/test/java/io/oduck/api/unit/bookmark/service/BookmarkServiceTest.java index 58194b02..830e9099 100644 --- a/src/test/java/io/oduck/api/unit/bookmark/service/BookmarkServiceTest.java +++ b/src/test/java/io/oduck/api/unit/bookmark/service/BookmarkServiceTest.java @@ -17,6 +17,7 @@ import io.oduck.api.domain.anime.repository.AnimeRepository; import io.oduck.api.domain.bookmark.dto.BookmarkDslDto.BookmarkDsl; import io.oduck.api.domain.bookmark.dto.BookmarkReqDto.Sort; +import io.oduck.api.domain.bookmark.dto.BookmarkResDto.BookmarkCountRes; import io.oduck.api.domain.bookmark.dto.BookmarkResDto.BookmarkRes; import io.oduck.api.domain.bookmark.dto.BookmarkResDto.BookmarkedDateTimeRes; import io.oduck.api.domain.bookmark.entity.Bookmark; @@ -134,6 +135,24 @@ void getBookmarksByMemberIdSuccess() { } } + @DisplayName("회원의 북마크 갯수 조회") + @Nested + class GetBookmarkCountByMemberId { + @DisplayName("회원의 북마크 갯수 조회 성공") + @Test + void getBookmarkCountByMemberIdSuccess() { + Long memberId = 1L; + Long count = 3L; + + when(bookmarkRepository.countByMemberId(memberId)).thenReturn(count); + + BookmarkCountRes result = bookmarkService.getBookmarksCountByMemberId(memberId); + + assertNotNull(result); + assertEquals(count, result.getCount()); + } + } + @DisplayName("북마크 체크") @Nested class checkBookmarked { From 83bdb795ce01516122840a3d487e4cc02d3fef4e Mon Sep 17 00:00:00 2001 From: FaberJoo Date: Fri, 10 Nov 2023 22:42:09 +0900 Subject: [PATCH 10/13] =?UTF-8?q?test:=20=ED=9A=8C=EC=9B=90=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=20=EB=A6=AC=EB=B7=B0=20=EA=B0=AF=EC=88=98=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20repository=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20#98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/ShortReviewRepositoryTest.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/test/java/io/oduck/api/unit/shortReview/repository/ShortReviewRepositoryTest.java b/src/test/java/io/oduck/api/unit/shortReview/repository/ShortReviewRepositoryTest.java index 2a234aae..633e20b9 100644 --- a/src/test/java/io/oduck/api/unit/shortReview/repository/ShortReviewRepositoryTest.java +++ b/src/test/java/io/oduck/api/unit/shortReview/repository/ShortReviewRepositoryTest.java @@ -195,4 +195,22 @@ void changeShortReviewContent() { assertEquals(updateShortReview.isHasSpoiler(), hasSpoiler); } } + + @DisplayName("회원 작성한 리뷰 갯수 조회") + @Nested + class selectShortReviewsCount { + @DisplayName("회원 ID로 회원이 작성한 리뷰 갯수 조회 성공") + @Test + void selectShortReviewsCountSuccess() { + // given + Long memberId = 1L; + + // when + Long shortReviewsCount = shortReviewRepository.countByMemberId(memberId); + + // then + assertNotNull(shortReviewsCount); + assertEquals(2L, shortReviewsCount); + } + } } \ No newline at end of file From 62550be36fac510a2346385b70042ab26629710e Mon Sep 17 00:00:00 2001 From: FaberJoo Date: Fri, 10 Nov 2023 22:42:28 +0900 Subject: [PATCH 11/13] =?UTF-8?q?test:=20=ED=9A=8C=EC=9B=90=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=20=EB=A6=AC=EB=B7=B0=20=EC=A1=B0=ED=9A=8C=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=B6=94=EB=8B=A4=20?= =?UTF-8?q?#98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/ShortReviewServiceTest.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/test/java/io/oduck/api/unit/shortReview/service/ShortReviewServiceTest.java b/src/test/java/io/oduck/api/unit/shortReview/service/ShortReviewServiceTest.java index 1740655b..d72c18d6 100644 --- a/src/test/java/io/oduck/api/unit/shortReview/service/ShortReviewServiceTest.java +++ b/src/test/java/io/oduck/api/unit/shortReview/service/ShortReviewServiceTest.java @@ -9,6 +9,7 @@ import io.oduck.api.domain.review.dto.ShortReviewReqDto.PatchShortReviewReq; import io.oduck.api.domain.review.dto.ShortReviewReqDto.PostShortReviewReq; import io.oduck.api.domain.review.dto.ShortReviewReqDto.Sort; +import io.oduck.api.domain.review.dto.ShortReviewResDto.ShortReviewCountRes; import io.oduck.api.domain.review.dto.ShortReviewResDto.ShortReviewRes; import io.oduck.api.domain.review.entity.ShortReview; import io.oduck.api.domain.review.repository.ShortReviewRepository; @@ -145,4 +146,25 @@ void patchShortReview(){ verify(shortReviewRepository, times(1)).findById(anyLong()); } } + + @DisplayName("회원 ID로 짧은 리뷰 갯수 조회") + @Nested + class GetShortReviewCountByMemberId { + + @Test + @DisplayName("회원 ID로 짧은 리뷰 갯수 조회 성공") + void getShortReviewCountByMemberId() { + //given + Long memberId = 1L; + Long count = 1L; + + given(shortReviewRepository.countByMemberId(memberId)).willReturn(count); + + //when + ShortReviewCountRes result = shortReviewService.getShortReviewCountByMemberId(memberId); + + //then + assertEquals(count, result.getCount()); + } + } } \ No newline at end of file From ce6c755bfc5ae3ee3556a929d06cd238de923cf4 Mon Sep 17 00:00:00 2001 From: FaberJoo Date: Fri, 10 Nov 2023 22:42:48 +0900 Subject: [PATCH 12/13] =?UTF-8?q?test:=20=ED=9A=8C=EC=9B=90=20=EB=B6=81?= =?UTF-8?q?=EB=A7=88=ED=81=AC,=20=EC=9E=91=EC=84=B1=20=EB=A6=AC=EB=B7=B0?= =?UTF-8?q?=20=EA=B0=AF=EC=88=98=20api=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20#98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/e2e/member/MemberControllerTest.java | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/src/test/java/io/oduck/api/e2e/member/MemberControllerTest.java b/src/test/java/io/oduck/api/e2e/member/MemberControllerTest.java index fe5c0e7f..12732bb5 100644 --- a/src/test/java/io/oduck/api/e2e/member/MemberControllerTest.java +++ b/src/test/java/io/oduck/api/e2e/member/MemberControllerTest.java @@ -633,5 +633,81 @@ void getBookmarksSuccessWithCursor() throws Exception { } } + @DisplayName("회원의 북마크 애니 갯수 조회") + @Nested + class GetBookmarkCount { + @DisplayName("회원의 북마크 애니 갯수 조회 성공시 200 OK 응답") + @Test + void getBookmarkCountSuccess() throws Exception { + // given + // 회원의 북마크 애니 갯수 조회에 필요한 데이터 + Long memberId = 1L; + + // when + ResultActions actions = mockMvc.perform( + get(BASE_URL + "/{memberId}/bookmarks/count", memberId) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON) + ); + + // then + actions + .andExpect(status().isOk()) + .andExpect(jsonPath("$.count").exists()) + .andDo( + document("getBookmarkCount/success", + preprocessRequest(prettyPrint()), + preprocessResponse(prettyPrint()), + pathParameters( + parameterWithName("memberId") + .description("회원 id")), + responseFields( + fieldWithPath("count") + .type(JsonFieldType.NUMBER) + .description("회원의 북마크 애니 갯수") + ) + ) + ); + } + } + // TODO: 회원 리뷰 목록 조회 + + @DisplayName("회원의 리뷰 갯수 조회") + @Nested + class GetReviewCount { + @DisplayName("회원의 리뷰 갯수 조회 성공시 200 OK 응답") + @Test + void getReviewCountSuccess() throws Exception { + // given + // 회원의 리뷰 갯수 조회에 필요한 데이터 + Long memberId = 1L; + + // when + ResultActions actions = mockMvc.perform( + get(BASE_URL + "/{memberId}/short-reviews/count", memberId) + .contentType(MediaType.APPLICATION_JSON) + .accept(MediaType.APPLICATION_JSON) + ); + + // then + actions + .andExpect(status().isOk()) + .andExpect(jsonPath("$.count").exists()) + .andDo( + document("getReviewCount/success", + preprocessRequest(prettyPrint()), + preprocessResponse(prettyPrint()), + pathParameters( + parameterWithName("memberId") + .description("회원 id")), + responseFields( + fieldWithPath("count") + .type(JsonFieldType.NUMBER) + .description("회원의 리뷰 갯수") + ) + ) + ); + } + } } From 4a206fc30291173fb42f520f8a603d8cd7b01869 Mon Sep 17 00:00:00 2001 From: FaberJoo Date: Fri, 10 Nov 2023 22:49:01 +0900 Subject: [PATCH 13/13] =?UTF-8?q?docs:=20=ED=9A=8C=EC=9B=90=20=EB=B6=81?= =?UTF-8?q?=EB=A7=88=ED=81=AC,=20=EB=A6=AC=EB=B7=B0=20=EA=B0=AF=EC=88=98?= =?UTF-8?q?=20api=20=EB=AC=B8=EC=84=9C=ED=99=94=20=EC=B6=94=EA=B0=80=20#98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/docs/asciidoc/index.adoc | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/docs/asciidoc/index.adoc b/src/docs/asciidoc/index.adoc index 8c7d3bde..a704991f 100644 --- a/src/docs/asciidoc/index.adoc +++ b/src/docs/asciidoc/index.adoc @@ -496,6 +496,46 @@ include::{snippets}/getBookmarks/successWithCursor/response-body.adoc[] .response-fields include::{snippets}/getBookmarks/successWithCursor/response-fields.adoc[]sho +=== GET api/v1/members/:id/bookmarks/count + +.curl-request +include::{snippets}/getBookmarkCount/success/curl-request.adoc[] + +.http-request +include::{snippets}/getBookmarkCount/success/http-request.adoc[] + +.request-param +include::{snippets}/getBookmarkCount/success/path-parameters.adoc[] + +.http-response +include::{snippets}/getBookmarkCount/success/http-response.adoc[] + +.response-body +include::{snippets}/getBookmarkCount/success/response-body.adoc[] + +.response-fields +include::{snippets}/getBookmarkCount/success/response-fields.adoc[] + +=== GET api/v1/members/:id/short-reviews/count + +.curl-request +include::{snippets}/getReviewCount/success/curl-request.adoc[] + +.http-request +include::{snippets}/getReviewCount/success/http-request.adoc[] + +.request-param +include::{snippets}/getReviewCount/success/path-parameters.adoc[] + +.http-response +include::{snippets}/getReviewCount/success/http-response.adoc[] + +.response-body +include::{snippets}/getReviewCount/success/response-body.adoc[] + +.response-fields +include::{snippets}/getReviewCount/success/response-fields.adoc[] + == animes === GET api/v1/animes .curl-request