diff --git a/src/main/java/shop/hooking/hooking/service/CopyService.java b/src/main/java/shop/hooking/hooking/service/CopyService.java index d7cbbef..1cc7fb9 100644 --- a/src/main/java/shop/hooking/hooking/service/CopyService.java +++ b/src/main/java/shop/hooking/hooking/service/CopyService.java @@ -87,6 +87,7 @@ public void saveCrawlingData(List dataList) { public CopySearchRes copySearchList(HttpServletRequest httpRequest, String q, int index) { CopySearchRes response = new CopySearchRes(); List results = new ArrayList<>(); + Integer startIndex = index*30; q = checkKeyword(q); @@ -100,21 +101,21 @@ public CopySearchRes copySearchList(HttpServletRequest httpRequest, String q, in moodCopyRes = cardJpaRepository.searchMood(q); setScrapCntWhenTokenNotProvided(httpRequest, moodCopyRes); Collections.shuffle(moodCopyRes); - results.add(createCopySearchResult("mood", q, moodCopyRes, index)); + results.add(createCopySearchResult("mood", q, moodCopyRes, startIndex)); if (!textCopyRes.isEmpty()) { setScrapCntWhenTokenNotProvided(httpRequest, textCopyRes); Collections.shuffle(textCopyRes); - results.add(createCopySearchResult("copy", q, textCopyRes, index)); + results.add(createCopySearchResult("copy", q, textCopyRes, startIndex)); } } else if (BrandType.containsKeyword(q)) { brandCopyRes = cardJpaRepository.searchBrand(q); setScrapCntWhenTokenNotProvided(httpRequest, brandCopyRes); Collections.shuffle(brandCopyRes); - results.add(createCopySearchResult("brand", q, brandCopyRes, index)); + results.add(createCopySearchResult("brand", q, brandCopyRes, startIndex)); } else if (!textCopyRes.isEmpty()) { setScrapCntWhenTokenNotProvided(httpRequest, textCopyRes); Collections.shuffle(textCopyRes); - results.add(createCopySearchResult("copy", q, textCopyRes, index)); + results.add(createCopySearchResult("copy", q, textCopyRes, startIndex)); } // 검색 결과가 없다면 @@ -256,7 +257,7 @@ public void setScrapCntWhenTokenNotProvided(HttpServletRequest httpRequest, List } - public List getLimitedCopyResByIndex(List copyResList, int startIndex) { + public List getLimitedCopyResByIndex(List copyResList, int startIndex) { //0 //30 int endIndex = Math.min(startIndex + 30, copyResList.size()); return copyResList.subList(startIndex, endIndex); }