From 0a0541cbe86cf18b8555f0299ae48897f03be13b Mon Sep 17 00:00:00 2001 From: Curry4182 Date: Wed, 24 Jan 2024 16:07:10 +0900 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=EC=95=84=EC=9D=B4=ED=85=9C=20?= =?UTF-8?q?=EA=B2=80=EC=83=89=20=EB=B0=8F=20=EB=AA=A9=EB=A1=9D=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=EC=97=90=20=EC=B7=A8=EB=AF=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lime/domains/item/api/ItemController.java | 6 ++++-- .../lime/domains/item/application/ItemService.java | 9 +++++++-- .../domains/item/implementation/ItemCursorReader.java | 7 +++++-- .../domains/item/repository/ItemRepositoryForCursor.java | 9 +++++---- .../item/repository/ItemRepositoryForCursorImpl.java | 6 ++++-- 5 files changed, 25 insertions(+), 12 deletions(-) diff --git a/lime-api/src/main/java/com/programmers/lime/domains/item/api/ItemController.java b/lime-api/src/main/java/com/programmers/lime/domains/item/api/ItemController.java index 39b4c11f1..10ef3a21f 100644 --- a/lime-api/src/main/java/com/programmers/lime/domains/item/api/ItemController.java +++ b/lime-api/src/main/java/com/programmers/lime/domains/item/api/ItemController.java @@ -108,12 +108,14 @@ public ResponseEntity getItemNames(@RequestParam final Str public ResponseEntity getItemsByCursor( @RequestParam final String keyword, @ModelAttribute("request") @Valid final CursorRequest request, - @RequestParam(required = false) final String itemSortCondition + @RequestParam(required = false) final String itemSortCondition, + @RequestParam(required = false) final String hobbyName ) { ItemGetByCursorServiceResponse serviceResponse = itemService.getItemsByCursor( keyword, request.toParameters(), - itemSortCondition + itemSortCondition, + hobbyName ); ItemGetByCursorResponse response = ItemGetByCursorResponse.from(serviceResponse); diff --git a/lime-api/src/main/java/com/programmers/lime/domains/item/application/ItemService.java b/lime-api/src/main/java/com/programmers/lime/domains/item/application/ItemService.java index abcc3317f..cf26e1a8c 100644 --- a/lime-api/src/main/java/com/programmers/lime/domains/item/application/ItemService.java +++ b/lime-api/src/main/java/com/programmers/lime/domains/item/application/ItemService.java @@ -6,6 +6,7 @@ import com.programmers.lime.common.cursor.CursorPageParameters; import com.programmers.lime.common.cursor.CursorSummary; +import com.programmers.lime.common.model.Hobby; import com.programmers.lime.common.model.ItemRemovalList; import com.programmers.lime.domains.item.api.dto.response.MemberItemFavoritesGetResponse; import com.programmers.lime.domains.item.application.dto.MemberItemCreateServiceResponse; @@ -136,14 +137,18 @@ public ItemGetNamesServiceResponse getItemNamesByKeyword(final String keyword) { public ItemGetByCursorServiceResponse getItemsByCursor( final String keyword, final CursorPageParameters parameters, - final String itemSortCondition + final String itemSortCondition, + final String hobbyName ) { + Hobby hobby = Hobby.from(hobbyName); + ItemSortCondition sortCondition = ItemSortCondition.from(itemSortCondition); CursorSummary itemCursorSummaryCursorSummary = itemCursorReader.readByCursor( keyword, parameters, - sortCondition + sortCondition, + hobby ); int itemTotalCount = itemReader.getItemTotalCountByKeyword(keyword); diff --git a/lime-domain/src/main/java/com/programmers/lime/domains/item/implementation/ItemCursorReader.java b/lime-domain/src/main/java/com/programmers/lime/domains/item/implementation/ItemCursorReader.java index 0cc99a794..f384d39b3 100644 --- a/lime-domain/src/main/java/com/programmers/lime/domains/item/implementation/ItemCursorReader.java +++ b/lime-domain/src/main/java/com/programmers/lime/domains/item/implementation/ItemCursorReader.java @@ -9,6 +9,7 @@ import com.programmers.lime.common.cursor.CursorPageParameters; import com.programmers.lime.common.cursor.CursorSummary; import com.programmers.lime.common.cursor.CursorUtils; +import com.programmers.lime.common.model.Hobby; import com.programmers.lime.domains.item.model.ItemCursorSummary; import com.programmers.lime.domains.item.model.ItemSortCondition; import com.programmers.lime.domains.item.repository.ItemRepository; @@ -26,7 +27,8 @@ public class ItemCursorReader { public CursorSummary readByCursor( final String keyword, final CursorPageParameters parameters, - final ItemSortCondition itemSortCondition + final ItemSortCondition itemSortCondition, + final Hobby hobby ) { String trimmedKeyword = keyword.trim(); @@ -44,7 +46,8 @@ public CursorSummary readByCursor( trimmedKeyword, parameters.cursorId(), pageSize, - itemSortCondition + itemSortCondition, + hobby ); return CursorUtils.getCursorSummaries(itemCursorSummaries); diff --git a/lime-domain/src/main/java/com/programmers/lime/domains/item/repository/ItemRepositoryForCursor.java b/lime-domain/src/main/java/com/programmers/lime/domains/item/repository/ItemRepositoryForCursor.java index f79b49c6f..4b0b4a3ce 100644 --- a/lime-domain/src/main/java/com/programmers/lime/domains/item/repository/ItemRepositoryForCursor.java +++ b/lime-domain/src/main/java/com/programmers/lime/domains/item/repository/ItemRepositoryForCursor.java @@ -9,10 +9,11 @@ public interface ItemRepositoryForCursor { List findAllByCursor( - String keyword, - String cursorId, - int pageSize, - final ItemSortCondition itemSortCondition + final String keyword, + final String cursorId, + final int pageSize, + final ItemSortCondition itemSortCondition, + final Hobby hobby ); List findReviewedItemByCursor( diff --git a/lime-domain/src/main/java/com/programmers/lime/domains/item/repository/ItemRepositoryForCursorImpl.java b/lime-domain/src/main/java/com/programmers/lime/domains/item/repository/ItemRepositoryForCursorImpl.java index 5591aee34..7c868f220 100644 --- a/lime-domain/src/main/java/com/programmers/lime/domains/item/repository/ItemRepositoryForCursorImpl.java +++ b/lime-domain/src/main/java/com/programmers/lime/domains/item/repository/ItemRepositoryForCursorImpl.java @@ -36,7 +36,8 @@ public List findAllByCursor( final String keyword, final String cursorId, final int pageSize, - final ItemSortCondition itemSortCondition + final ItemSortCondition itemSortCondition, + final Hobby hobby ) { return jpaQueryFactory .select( @@ -55,7 +56,8 @@ public List findAllByCursor( ).from(item) .where( cursorIdCondition(cursorId), - item.name.contains(keyword) + item.name.contains(keyword), + hobbyCondition(hobby) ).orderBy(orderBySortCondition(itemSortCondition), item.id.desc()) .groupBy(item.id) .leftJoin(review).on(item.id.eq(review.itemId)) From 83cf6f95f83ec6dfb6e8b2044fdc932234008c00 Mon Sep 17 00:00:00 2001 From: Curry4182 Date: Wed, 24 Jan 2024 16:08:27 +0900 Subject: [PATCH 2/3] =?UTF-8?q?rename:=20=EC=95=84=EC=9D=B4=ED=85=9C=20?= =?UTF-8?q?=EB=93=B1=EB=A1=9D=20api=EC=97=90=EC=84=9C=20hobbyValue?= =?UTF-8?q?=EB=A5=BC=20hobbyName=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lime/domains/item/api/dto/request/ItemEnrollRequest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lime-api/src/main/java/com/programmers/lime/domains/item/api/dto/request/ItemEnrollRequest.java b/lime-api/src/main/java/com/programmers/lime/domains/item/api/dto/request/ItemEnrollRequest.java index 2ad7ed2c0..08ca984e1 100644 --- a/lime-api/src/main/java/com/programmers/lime/domains/item/api/dto/request/ItemEnrollRequest.java +++ b/lime-api/src/main/java/com/programmers/lime/domains/item/api/dto/request/ItemEnrollRequest.java @@ -9,7 +9,7 @@ public record ItemEnrollRequest( @Schema(description = "취미", example = "농구") - String hobbyValue, + String hobbyName, @Schema(description = "아이템 URL", example = "https://www.coupang.com/vp/products/5720604355?itemId=9567481661") @NotNull(message = "아이템 URL을 입력하지 않았습니다.") @@ -17,7 +17,7 @@ public record ItemEnrollRequest( ) { public ItemEnrollServiceRequest toEnrollItemServiceRequest() { - Hobby hobby = Hobby.from(hobbyValue); + Hobby hobby = Hobby.from(hobbyName); return new ItemEnrollServiceRequest(hobby, itemUrl); } From 5693a96b6d5f8d239cace697bb3532244a2e011e Mon Sep 17 00:00:00 2001 From: Curry4182 Date: Wed, 24 Jan 2024 16:10:42 +0900 Subject: [PATCH 3/3] =?UTF-8?q?docs:=20=EC=95=84=EC=9D=B4=ED=85=9C=20?= =?UTF-8?q?=EB=AA=A9=EB=A1=9D=EC=A1=B0=ED=9A=8C=EC=97=90=20=EC=8A=A4?= =?UTF-8?q?=EC=9B=A8=EA=B1=B0=20=EC=84=A4=EB=AA=85=20=EB=AC=B8=EC=84=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/programmers/lime/domains/item/api/ItemController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lime-api/src/main/java/com/programmers/lime/domains/item/api/ItemController.java b/lime-api/src/main/java/com/programmers/lime/domains/item/api/ItemController.java index 10ef3a21f..a39b95e22 100644 --- a/lime-api/src/main/java/com/programmers/lime/domains/item/api/ItemController.java +++ b/lime-api/src/main/java/com/programmers/lime/domains/item/api/ItemController.java @@ -94,7 +94,7 @@ public ResponseEntity deleteMyItem( return ResponseEntity.ok().build(); } - @Operation(summary = "키워드로 아이템 이름 목록 조회", description = "키워드를 이용하여 아이템 이름 목록 조회 합니다") + @Operation(summary = "아이템 이름 목록 조회", description = "키워드를 이용하여 아이템 이름 목록 조회 합니다") @GetMapping("/item-names") public ResponseEntity getItemNames(@RequestParam final String keyword) { ItemGetNamesServiceResponse serviceResponse = itemService.getItemNamesByKeyword(keyword); @@ -103,7 +103,7 @@ public ResponseEntity getItemNames(@RequestParam final Str return ResponseEntity.ok(response); } - @Operation(summary = "아이템 검색 및 목록조회", description = "키워드를 이용하여 아이템 검색 및 목록조회 합니다.") + @Operation(summary = "아이템 목록조회", description = "키워드, 취미를 이용하여 아이템 목록조회 합니다.") @GetMapping("/search") public ResponseEntity getItemsByCursor( @RequestParam final String keyword,