feat: 상품 이름으로 검색하여 페이징 처리하는 API 구현#109
Open
whxogus215 wants to merge 3 commits into
Open
Conversation
gogo1414
approved these changes
Feb 21, 2025
| 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); |
Member
There was a problem hiding this comment.
Suggested change
| Page<Product> pages = productRepository.findByNameContaining(keyword, pageable); | |
| Page<Product> pages = productRepository.findAllByNameContaining(keyword, pageable); |
사소한건데 All 붙이기로 했었던걸로 기억하고 있어용
Comment on lines
+139
to
+153
| 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(); |
Member
There was a problem hiding this comment.
Suggested change
| 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(); | |
멤버는 바깥에서 분리하는건 어떤가용??
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
요약
GET /campaigns/search?keyword=보약&size=10&page=0keyword,size,page입력 시, 해당 값을 토대로 페이징 처리