# 상품 엔티티 개발(비즈니스 로직 추가)

구현 기능

* 상품 등록
* 상품 목록 조회 상품 수정

구현 순서

* 상품  엔티티 개발(비즈니스 로직 추가)
* 상품  리포지토리 개발
* 상품  서비스 개발
* 상품  기능 테스트

재고 수량을 증감시키는 로직은 stockQuantity 데이터가 있는 클래스 내부에서 구현하는 것이 좋다!\
Setter로 외부에서 변경하는 것이 아니라!\
도메인 주도 설계 : 엔티티 자체가 할 수 있는 것들은 비즈니스 로직을 넣는 것이 좋다!(객체 지향적)\
stockQuantity가 Item 안에 있기 때문에 현재 가진 데이터에 대해 로직을 처리해주는 것이 응집도 있는 설계이기 때문이다!

비즈니스 로직 분석

1. **addStock()** : 파라미터로 넘어온 수만큼 재고를 늘린다. 이 메서드는 재고가 증가하거나 상품 주 문을 취소해서 재고를 다시 늘려야 할 때 사용한다.
2. **removeStock()** : 파라미터로 넘어온 수만큼 재고를 줄인다. 만약 재고가 부족하면 예외가 발생한 다. 주로 상품을 주문할 때 사용한다.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://heunnajo.gitbook.io/jpa/5./undefined.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
