Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Feature/1 #2

wants to merge 3 commits into from

Conversation

dothisdev
Copy link
Collaborator

No description provided.

dothisdev and others added 3 commits February 5, 2025 16:40
페이지네이션, 상품 이름과 내용을 조건으로 사용하고 정렬 적용이 가능하고
기초적인 필터(품절 여부)를 포함한 상품 검색 기능 구현

Fixes : #1

import java.util.Objects;

@Entity

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

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;

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 {

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 {

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);

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();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

orElseThrow(() -> new Exception("해당하는 id 에 값이 없습니다."))

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);

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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants