Skip to content

Commit

Permalink
Merge pull request #107 from Hooking-CEOS/feature/copy
Browse files Browse the repository at this point in the history
Feature/copy
  • Loading branch information
JiwonKim08 authored Aug 3, 2023
2 parents 5e6ec53 + 08ad3fc commit f5606d4
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/main/java/shop/hooking/hooking/service/CopyService.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public void saveCrawlingData(List<CrawlingData> dataList) {
public CopySearchRes copySearchList(HttpServletRequest httpRequest, String q, int index) {
CopySearchRes response = new CopySearchRes();
List<CopySearchResult> results = new ArrayList<>();
Integer startIndex = index*30;

q = checkKeyword(q);

Expand All @@ -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));
}

// 검색 결과가 없다면
Expand Down Expand Up @@ -256,7 +257,7 @@ public void setScrapCntWhenTokenNotProvided(HttpServletRequest httpRequest, List
}


public List<CopyRes> getLimitedCopyResByIndex(List<CopyRes> copyResList, int startIndex) {
public List<CopyRes> getLimitedCopyResByIndex(List<CopyRes> copyResList, int startIndex) { //0 //30
int endIndex = Math.min(startIndex + 30, copyResList.size());
return copyResList.subList(startIndex, endIndex);
}
Expand Down

0 comments on commit f5606d4

Please sign in to comment.