Skip to content

Commit

Permalink
[feat] 스크랩 최신순
Browse files Browse the repository at this point in the history
  • Loading branch information
CYJhub committed Jul 29, 2023
1 parent 1f400e7 commit c5e28a7
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
import shop.hooking.hooking.dto.response.CopySearchResult;
import shop.hooking.hooking.entity.Brand;
import shop.hooking.hooking.entity.Card;
import shop.hooking.hooking.entity.Scrap;
import shop.hooking.hooking.entity.User;
import shop.hooking.hooking.repository.BrandRepository;
import shop.hooking.hooking.repository.CardJpaRepository;
import shop.hooking.hooking.repository.CardRepository;
import shop.hooking.hooking.repository.ScrapRepository;
import shop.hooking.hooking.service.CopyService;
import shop.hooking.hooking.service.JwtTokenProvider;
import springfox.documentation.annotations.Cacheable;
Expand All @@ -40,6 +42,7 @@ public class CopyController {

private final CardRepository cardRepository;

private final ScrapRepository scrapRepository;



Expand Down Expand Up @@ -79,7 +82,12 @@ public ResponseEntity<HttpRes<List<CopyRes>>> copyScrapList(HttpServletRequest h
List<CopyRes> copyRes = copyService.getCopyScrapList(user);
int startIndex = index * 30;
List<CopyRes> resultCopyRes = copyService.getLimitedCopyResByIndex(copyRes, startIndex);
resultCopyRes.sort((copy1, copy2) -> copy1.getCreatedAt().compareTo(copy2.getCreatedAt()));
for(CopyRes copyRes1 : resultCopyRes){
Scrap scrap = scrapRepository.findByUserAndCardId(user, copyRes1.getId());
copyRes1.setScrapTime(scrap.getCreatedAt());
}

Collections.sort(resultCopyRes);
return ResponseEntity.ok(new HttpRes<>(resultCopyRes));
}

Expand Down

0 comments on commit c5e28a7

Please sign in to comment.