Skip to content

Commit d850cc5

Browse files
authored
Merge pull request #5 from Kimjipang/round02
docs: 요구사항 명세서, 시퀀스 다이어그램, 클래스 다이어그램, ERD 설계
2 parents 0540076 + 9752de6 commit d850cc5

4 files changed

Lines changed: 426 additions & 0 deletions

File tree

docs/design/01-requirements.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# 요구사항 명세
2+
3+
> 상품 목록 조회
4+
>
5+
6+
```java
7+
[유저 스토리]
8+
- 사용자는 상품 목록을 조회할 수 있다.
9+
10+
[기능 흐름]
11+
1. 모든 사용자가 조회 가능
12+
2. 상품 목록 조회 클릭
13+
3. 상품 목록이
14+
3-1. 존재하면 목록을 반환
15+
3-2. 존재하지 않으면 200 OK + 빈 배열을 반환
16+
```
17+
18+
> 상품 상세 조회
19+
>
20+
21+
```java
22+
[유저 스토리]
23+
- 사용자는 특정 상품의 상세 정보를 조회할 수 있다.
24+
25+
[기능 흐름]
26+
1. 모든 사용자가 조회 가능
27+
2. 특정 상품 상세 조회 클릭
28+
3. 상세 조회하고자 하는 상품이
29+
3-1. 존재하면 해당 상품의 상세 정보를 반환
30+
3-2. 존재하지 않으면 404 NOT_FOUND 에러를 반환
31+
```
32+
33+
> 브랜드 조회
34+
>
35+
36+
```java
37+
[유저 스토리]
38+
- 사용자는 상품의 브랜드 목록을 조회할 수 있다.
39+
40+
[기능 흐름]
41+
1. 모든 사용자가 조회 가능
42+
2. 브랜드 목록 조회 클릭
43+
3. 브랜드가
44+
3-1. 존재하면 브랜드 목록을 반환
45+
3-2. 존재하지 않으면 200 OK + 빈 배열 반환
46+
```
47+
48+
> 상품 좋아요 등록/취소 (멱등 동작)
49+
>
50+
51+
```java
52+
[유저 스토리]
53+
- 사용자는 상품 좋아요를 등록하거나 취소할 수 있다.
54+
55+
[기능 흐름]
56+
1. 로그인한 사용자만 상품 좋아요 등록/취소 가능
57+
2. 사용자가 좋아요 상품에 대한 좋아요 등록/취소 클릭
58+
2.1. 좋아요 등록/취소 클릭한 사용자가
59+
2.1.1. 존재하지 않는 사용자이면 404 NOT_FOUND 에러 반환
60+
2.1.2. 존재하는 사용자라면 200 OK 반환
61+
62+
2.2. 상품이 존재하는지 확인
63+
2.2.1. 존재하지 않는 상품이면 404 NOT_FOUND 에러 반환
64+
2.2.2. 존재하는 상품이면 200 OK 반환
65+
66+
2.3. 해당 상품에 대해 좋아요 등록/취소를 이미 했는지 확인
67+
2.3.1. 좋아요 등록/취소가 이미 이루어진 상태면 400 BAD_REQUEST 반환
68+
2.3.2. 좋아요 등록/취소가 최초이면 201 CREATED + 등록/취소 반영
69+
```
70+
71+
> 주문 생성 및 결제 흐름 (재고 차감, 포인트 차감, 외부 시스템 연동)
72+
>
73+
74+
75+
```java
76+
[유저 스토리]
77+
- 사용자는 상품을 구매할 수 있다.
78+
79+
[기능 흐름]
80+
1. 로그인한 사용자만 상품을 구매할 수 있다.
81+
2. 구매하고자 하는 상품을 장바구니에 담기 클릭
82+
2.1. 담고자 하는 상품의 재고가 구매하려는 수량 이상 존재하는지 확인
83+
2.1.1. 존재하지 않으면 400 BAD_REQUEST 반환
84+
2.1.2. 존재하면 장바구니에 담기
85+
3. 장바구니 내에서 최종 구매 원하는 상품 주문 클릭
86+
3.1. 구매 원하는 상품의 재고 여부 확인
87+
3.1.1. 재고가 없으면 400 BAD_REQUEST 반환
88+
3.1.2. 재고가 있으면 200 OK
89+
3.2. 주문 생성 및 결제 시스템 호출
90+
3.3. 결제 종류(신용카드, 체크 카드)에 따라 카드사에 잔고 확인 요청
91+
3.3.1. if(잔고 < 결제 금액) 이면 400 BAD_REQUEST 반환 -> 결제 실패
92+
3.3.2. else 이면 200 OK + 결제 성공
93+
3.4. 재고 차감, 포인트 차감
94+
95+
```
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# 시퀀스 다이어그램
2+
3+
> 상품 목록 조회
4+
>
5+
6+
```mermaid
7+
sequenceDiagram
8+
participant User
9+
participant ProductController
10+
participant ProductService
11+
participant ProductRepository
12+
13+
User->>ProductController: GET /products
14+
ProductController->>ProductService: findAllProduct()
15+
ProductService->>ProductRepository: findAllProduct()
16+
ProductRepository-->>ProductService: productList
17+
18+
alt 상품 목록이 존재하지 않을 경우
19+
ProductService-->>ProductController: { } -> 빈 배열
20+
ProductController-->>User: 200 OK + 빈 배열 반환
21+
else 상품 목록이 존재하는 경우
22+
ProductService-->>ProductController: productList
23+
ProductController-->>User: 200 OK + productList
24+
end
25+
```
26+
27+
> 상품 좋아요 등록 (멱등 동작)
28+
>
29+
30+
```mermaid
31+
sequenceDiagram
32+
actor User
33+
participant LikeController
34+
participant LikeService
35+
participant UserService
36+
participant ProductService
37+
participant LikeRepository
38+
39+
User->>LikeController: POST /likes
40+
LikeController->>LikeService: cratedLike(userId, productId)
41+
42+
%% 사용자 검증
43+
LikeService->>UserService: findUser(userId)
44+
alt 회원이 아닌 경우
45+
LikeService-->>LikeController: 404 NOT_FOUND + "존재하지 않는 회원입니다." 반환
46+
LikeController-->>User: 404 NOT_FOUND + "존재하지 않는 회원입니다." 반환
47+
48+
end
49+
50+
%% 상품 검증
51+
LikeService->>ProductService: findProduct(productId)
52+
alt 상품이 존재하지 않는 경우
53+
LikeService-->> LikeController: 404 NOT_FOUND + "존재하지 않는 상품입니다." 반환
54+
LikeController-->> User: 404 NOT_FOUND + "존재하지 않는 상품입니다." 반환
55+
end
56+
57+
%% 좋아요 존재 여부 확인
58+
LikeService->>LikeRepository: findByUserIdAndProductId(userId, productId)
59+
alt 좋아요가 이미 존재하는 경우
60+
LikeService-->> LikeController: 200 OK + "좋아요 등록이 되어 있는 상품입니다." 반환
61+
LikeController-->> User: 200 OK
62+
else 좋아요가 존재하지 않는 경우
63+
LikeService->>LikeRepository: save(like)
64+
LikeRepository-->>LikeService: Like created
65+
LikeService-->>LikeController: 201 CREATED
66+
LikeController-->>User: 201 CREATED
67+
68+
end
69+
70+
```
71+
72+
> 상품 좋아요 취소 (멱등 동작)
73+
>
74+
75+
```mermaid
76+
sequenceDiagram
77+
actor User
78+
participant LikeController
79+
participant LikeService
80+
participant LikeRepository
81+
82+
User->>LikeController: DELETE /likes/{productId}
83+
LikeController->>LikeService: cancelLike(userId, productId)
84+
85+
%% 사용자 검증
86+
LikeService->>UserService: findUser(userId)
87+
alt 회원이 아닌 경우
88+
LikeService-->>LikeController: 404 NOT_FOUND + "존재하지 않는 회원입니다." 반환
89+
LikeController-->>User: 404 NOT_FOUND + "존재하지 않는 회원입니다." 반환
90+
91+
end
92+
93+
%% 상품 검증
94+
LikeService->>ProductService: findProduct(productId)
95+
alt 상품이 존재하지 않는 경우
96+
LikeService-->> LikeController: 404 NOT_FOUND + "존재하지 않는 상품입니다." 반환
97+
LikeController-->> User: 404 NOT_FOUND + "존재하지 않는 상품입니다." 반환
98+
end
99+
100+
LikeService->>LikeRepository: findByUserIdAndProductId(userId, productId)
101+
alt 좋아요가 존재하지 않는 경우
102+
LikeService-->>LikeController: 204 NO_CONTENT + "취소할 좋아요가 없습니다." 반환
103+
LikeController-->>User: 204 No Content + "취소할 좋아요가 없습니다." 반환
104+
else 좋아요가 존재하는 경우
105+
LikeService->>LikeRepository: delete(like)
106+
LikeRepository-->>LikeService: Deleted
107+
LikeService-->>LikeController: 200 OK
108+
LikeController-->>User: 200 OK
109+
end
110+
111+
```

docs/design/03-class-diagram.md

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# 클래스 다이어그램
2+
3+
```mermaid
4+
classDiagram
5+
class Users {
6+
- Long id
7+
- String loginId
8+
- String email
9+
- Gender gender
10+
- String password
11+
12+
+ void changePassword(String password)
13+
+ void changeEmail(String email)
14+
}
15+
16+
class Point {
17+
- Long id
18+
- Long refUserId
19+
- int balance
20+
21+
+ void chargePoint(int amount)
22+
+ void usePoint(int amount)
23+
}
24+
25+
class Brand {
26+
- Long id
27+
- String name
28+
29+
}
30+
31+
class Product {
32+
- Long id
33+
- Long refBrandId
34+
- String name
35+
- BigDecimal price
36+
- int stock
37+
38+
+ void changePrice(BigDecimal newPrice)
39+
+ void discountPrice(BigDecimal rate)
40+
+ void increaseStock(int amount)
41+
+ void decreaseStock(int amount)
42+
+ boolean availableStock(int amount)
43+
44+
}
45+
46+
class Like {
47+
- Long id
48+
- Long refUserId
49+
- Long refProductId
50+
51+
+ static void createLike(Long userId, Long productId)
52+
53+
}
54+
55+
class Cart {
56+
- Long id
57+
- Long refUserId
58+
59+
+ void addItemToCart(Long productId, int amount)
60+
+ void deleteItemFromCart(Long productId, int amount)
61+
}
62+
63+
class CartItem {
64+
- Long id
65+
- String name
66+
- Long refCartId
67+
- Long refProductId
68+
- int quantity
69+
70+
+ void changeQuantity(int amount)
71+
}
72+
73+
class Order {
74+
- Long id
75+
- Long refUserId
76+
- OrderStatus status
77+
78+
+ void addItemToOrder(Product product, int quantity)
79+
+ BigDecimal calculateTotalPrice()
80+
+ void complete()
81+
+ void cancel()
82+
83+
}
84+
85+
class OrderItem {
86+
- Long id
87+
- Long refOrderId
88+
- Long refProductId
89+
- Integer quantity
90+
- BigDecimal orderPrice
91+
}
92+
93+
class Payment {
94+
- Long id
95+
- Long refOrderId
96+
- BigDecimal totalPrice
97+
- PaymentStatus status
98+
- PaymentMethod method
99+
100+
+ void requestPayment(Order order)
101+
+ void completePayment()
102+
+ void cancelPayment()
103+
+ boolean isCompleted()
104+
+ boolean isRefundable()
105+
}
106+
107+
Order "1" *-- "0..*" OrderItem
108+
Cart "1" *-- "0..*" CartItem
109+
Product "0..*" --> "1" Brand
110+
Like "0..*" --> "1" Users
111+
Like "0..*" --> "1" Product
112+
Order "0..*" --> "1" Users
113+
Point "1" --> "1" Users
114+
Payment "1" --> "1" Order
115+
```

0 commit comments

Comments
 (0)