-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feature/1 #2
base: main
Are you sure you want to change the base?
Conversation
… 선택적으로 정렬을 사용가능한 쿼리 추가
페이지네이션, 상품 이름과 내용을 조건으로 사용하고 정렬 적용이 가능하고 기초적인 필터(품절 여부)를 포함한 상품 검색 기능 구현 Fixes : #1
|
||
import java.util.Objects; | ||
|
||
@Entity |
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.
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController |
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.
|
||
@RestController | ||
public class ProductController { | ||
private ProductService productService; |
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.
private final ProductService productService;
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class ProductServiceImpl implements ProductService { |
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.
implements ProductService 제거 해주세요.
import java.util.Objects; | ||
|
||
@Entity | ||
public class Product { |
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.
@AllArgConstructor
) { | ||
Page<Product> products = productService.getProducts(name, description, isOnlyExist, pageable); | ||
|
||
return new ResponseEntity<>(products, HttpStatus.OK); |
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 new ResponseEntity<>(productService.getProducts(name, description, isOnlyExist, pageable), HttpStatus.OK);
|
||
@Override | ||
public Product getProduct(long id) { | ||
return productRepository.findById(id).orElseThrow(); |
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.
orElseThrow(() -> new Exception("해당하는 id 에 값이 없습니다."))
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.
NoSuch~Exception
|
||
@Override | ||
public Page<Product> getProducts(String name, String description, boolean isOnlyExist, Pageable pageable) { | ||
return productRepository.findAllByNameOrDescriptionOrStockGreaterThanEqual(name, description, isOnlyExist ? 1 : 0, 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.
productRepository.findAllByNameOrDescriptionOrStockGreaterThanEqual(name, description, isOnlyExist, pageable);
No description provided.