-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 상품 이름으로 검색하여 페이징 처리하는 API 구현 #109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
gogo1414
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다!
사소한 코멘트 몇개 달았어용!
| public List<ReadCampaignResponse> searchByProductName(String keyword, int page, int size) { | ||
| keyword = keyword.trim(); | ||
| Pageable pageable = PageRequest.of(page, size, Sort.by("id").ascending()); | ||
| Page<Product> pages = productRepository.findByNameContaining(keyword, pageable); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Page<Product> pages = productRepository.findByNameContaining(keyword, pageable); | |
| Page<Product> pages = productRepository.findAllByNameContaining(keyword, pageable); |
사소한건데 All 붙이기로 했었던걸로 기억하고 있어용
| return pages.getContent().stream() | ||
| .map(product -> { | ||
| Campaign campaign = product.getCampaign(); | ||
| return new ReadCampaignResponse( | ||
| campaign.getId(), | ||
| campaign.getStartDate().toString(), | ||
| campaign.getEndDate().toString(), | ||
| campaign.getGoalQuantity(), | ||
| campaign.getSoldQuantity(), | ||
| product.getStock().getTotalQuantity(), | ||
| campaign.getState(), | ||
| new ProductResponse(product), | ||
| campaign.getMember().orElse(Member.createEmpty()).getId() | ||
| ); | ||
| }).toList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| return pages.getContent().stream() | |
| .map(product -> { | |
| Campaign campaign = product.getCampaign(); | |
| return new ReadCampaignResponse( | |
| campaign.getId(), | |
| campaign.getStartDate().toString(), | |
| campaign.getEndDate().toString(), | |
| campaign.getGoalQuantity(), | |
| campaign.getSoldQuantity(), | |
| product.getStock().getTotalQuantity(), | |
| campaign.getState(), | |
| new ProductResponse(product), | |
| campaign.getMember().orElse(Member.createEmpty()).getId() | |
| ); | |
| }).toList(); | |
| return pages.getContent().stream() | |
| .map(product -> { | |
| Campaign campaign = product.getCampaign(); | |
| Member member = campaign.getMember().orElse(Member.createEmpty()); | |
| return new ReadCampaignResponse( | |
| campaign.getId(), | |
| campaign.getStartDate().toString(), | |
| campaign.getEndDate().toString(), | |
| campaign.getGoalQuantity(), | |
| campaign.getSoldQuantity(), | |
| product.getStock().getTotalQuantity(), | |
| campaign.getState(), | |
| new ProductResponse(product), | |
| member.getId() | |
| ); | |
| }).toList(); | |
멤버는 바깥에서 분리하는건 어떤가용??
요약
GET /campaigns/search?keyword=보약&size=10&page=0keyword,size,page입력 시, 해당 값을 토대로 페이징 처리