Skip to content

Conversation

@karneva
Copy link

@karneva karneva commented Dec 31, 2025

✅ PR 유형

어떤 변경 사항이 있었나요?

  • [ V ] 새로운 기능 추가
  • [ V ] 코드에 영향을 주지 않는 변경사항(오타 수정, 탭 사이즈 변경, 변수명 변경)

🚀 작업 내용

이번 PR에서 작업한 내용을 구체적으로 설명해주세요. (이미지 첨부 가능)

  • 작업한 내용 1

    • 상품 모델 생성 (products)
    • 상품 생성, 전체 조회, 단건 조회, 수정, 삭제 API 추가
      • 공통 응답 구조 상속 받아서 리턴
  • 작업한 내용 2

    • docker에 db 연결
    • postman으로 API 전송 시 products 테이블에 항목 CRUD 되는 것 확인

📝️ 관련 이슈

본인이 작업한 내용이 어떤 Issue와 관련이 있는지 작성해주세요.


💬 기타 사항 or 추가 코멘트

남기고 싶은 말, 참고 블로그 등이 있다면 기록해주세요.


Comment on lines 42 to 51
// READ: 단건 조회
public Product getProduct(Long productid) {
return productRepository.findById(productid)
.orElseThrow(() -> new CustomException(ProductErrorStatus._INVALID_PRODUCT));
}

// READ: 전체 조회
public List<Product> getProducts() {
return productRepository.findAll();
}
Copy link
Member

Choose a reason for hiding this comment

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

조회 메서드에 @Transactional(readOnly = true)를 명시할 경우 여러 이점이 있습니다!
JPA 관련해서, 코드의 가독성 부분에서,,, 등등

Comment on lines 56 to 62
public void removeStock(int quantity) {
if (this.stockQuantity < quantity) {
// 충분한 재고가 없을 경우 예외 처리
throw new IllegalArgumentException("재고가 부족합니다.");
}
this.stockQuantity -= quantity;
}
Copy link
Member

Choose a reason for hiding this comment

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

전역적으로 예외처리를 RestControllerAdvice를 통해 하고 있어, 저희 컨벤션에 맞게 Error코드 추가하고 CustomException을 던지는 방식으로 수정하시면 좋을것 같아요!

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.

[feat] : 상품 모델 생성

3 participants