From 6a6b720ca71f844d5038cdf1f91b7aea0ea01f16 Mon Sep 17 00:00:00 2001 From: chanwoo7 Date: Thu, 19 Sep 2024 01:46:44 +0900 Subject: [PATCH] =?UTF-8?q?[delete]=20#153=20ensureRecommendationsCount=20?= =?UTF-8?q?=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/book/controller/BookController.java | 2 +- .../backend/domain/book/service/BookService.java | 16 ---------------- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/src/main/java/com/book/backend/domain/book/controller/BookController.java b/src/main/java/com/book/backend/domain/book/controller/BookController.java index 8ec2da4..af5fffe 100644 --- a/src/main/java/com/book/backend/domain/book/controller/BookController.java +++ b/src/main/java/com/book/backend/domain/book/controller/BookController.java @@ -59,8 +59,8 @@ public ResponseEntity recommend(@RequestParam String isbn) throws Exception { HashSet duplicateCheckSet = new HashSet<>(); LinkedList duplicateRemovedList = bookService.duplicateChecker(response, duplicateCheckSet); - bookService.ensureRecommendationsCount(duplicateRemovedList, duplicateCheckSet); response = RandomPicker.randomPick(duplicateRemovedList, 10); // 10개 랜덤 추출 + return responseTemplate.success(response, HttpStatus.OK); } diff --git a/src/main/java/com/book/backend/domain/book/service/BookService.java b/src/main/java/com/book/backend/domain/book/service/BookService.java index d6a4ef6..695f5d4 100644 --- a/src/main/java/com/book/backend/domain/book/service/BookService.java +++ b/src/main/java/com/book/backend/domain/book/service/BookService.java @@ -46,22 +46,6 @@ public LinkedList recommend(RecommendListRequestDto re return responseList; } - /* 추천 책 수가 10보다 작으면 추천된 isbn 으로 recommend() 다시 호출 */ - public void ensureRecommendationsCount(LinkedList list, HashSet set) throws Exception { - log.trace("BookService > ensureRecommendationsCount()"); - LinkedList originalList = new LinkedList<>(list); - Iterator iterator = originalList.iterator(); - while (originalList.size() < 10 && iterator.hasNext()) { - RecommendListRequestDto newRequestDto = RecommendListRequestDto.builder().isbn13(iterator.next().getIsbn13()).build(); // 추천된 다른 책의 isbn13 - LinkedList newRecommendList = recommend(newRequestDto); - // 기존에 추가된 책인지 확인 - for(RecommendListResponseDto dto : newRecommendList){ - String key = dto.getBookname() + dto.getAuthors(); - if(set.add(key)) list.add(dto); - } - } - } - public LinkedList duplicateChecker(LinkedList list, HashSet set){ log.trace("BookService > duplicateChecker()"); LinkedList duplicateRemovedList = new LinkedList<>();