-
Notifications
You must be signed in to change notification settings - Fork 1
API Spec 분석 및 모델링
SR edited this page Sep 25, 2021
·
22 revisions
사용자 관련
도메인 | METHOD | URI | Prarameter | Authentication | RETURN |
---|---|---|---|---|---|
User | POST | /api/users/login | email, password | X | UserResponse |
User | POST | /api/users | email, username, password | X | UserResponse |
User | GET | /api/user | - | O | UserResponse |
User | PUT | /api/user | email, username, password, image, bio | O | UserResponse |
Profile | GET | /api/prifiles/:username | username | O/X | ProfileResponse |
Profile | POST | /api/prifiles/:username/follow | username | O | ProfileResponse |
Profile | DELETE | /api/prifiles/:username/follow | username | O | ProfileResponse |
글 관련
도메인 | METHOD | URI | Prarameter | Authentication | RETURN |
---|---|---|---|---|---|
Articles | GET | /api/articles/feed | limit, offset | O | MultiArticlesResponse |
Articles | GET | /api/articles | tag, author, favorited, limit, offset | X | MultiArticlesResponse |
Articles | POST | /api/articles | article | O | SingleArticleResponse |
Articles | GET | /api/articles/:slug | slug | X | SingleArticleResponse |
Articles | PUT | /api/articles/:slug | slug, article | O | SingleArticleResponse |
Articles | DELETE | /api/articles/:slug | slug | O | - |
Comments | GET | /api/articles/:slug/comments | slug | X | MultipleCommentsResponse |
Comments | POST | /api/articles/:slug/comments | slug, comment | O | SingleCommentResponse |
Comments | POST | /api/articles/:slug/comments/:id | slug, id | O | - |
글 좋아요 관련
도메인 | METHOD | URI | Prarameter | Authentication | RETURN |
---|---|---|---|---|---|
Favorites | POST | /api/articles/:slug/favorite | slug | O | SingleArticleResponse |
Favorites | DELETE | /api/articles/:slug/favorite | slug | O | SingleArticleResponse |
태그 관련
도메인 | METHOD | URI | Prarameter | Authentication | RETURN |
---|---|---|---|---|---|
Tag | DELETE | /api/tags | - | X | TagResponse |
- username은 유니크한가?
- 확인된 API Spec을 기준으로 TDD를 통해 Entity 설계
- 설계된 Entity를 기준으로 POJO 테스트 코드 작성
- @DataJpaTest를 통해 Jpa 테스트
- User내에 Profile 관련 필드를 포함하고 있는 것으로 구성 JPA를 사용하므로 @Embedded와 @Embeddable 어노테이션을 활용하여 구현하였다.
-
Follow는 엔티티로 가져가느냐 User와의 관계로 정의하고 가느냐 엔티티 구성이 달라진다.
-
User 내에 Follow를 포함하는 방식으로 구성하느냐, User와 Follow 엔티티를 따로 구성하느냐 관련 로직의 위치가 달라진다.
-
User와 Follow 간는 1:N, N:1 구성으로 FromUser-Follow-ToUser 관계를 갖도록 구성하여 Follow 엔티티를 구성하였다.
- 사용자가 다수의 글을 작성할 수 있으므로 1:N 관계를 가지며 양방향 연관관계를 갖도록 구성하였다.
© 2021 Copyright SR