-
Notifications
You must be signed in to change notification settings - Fork 0
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
[Feat]: Category, Article 도메인 및 JPA 모델 설계 및 초기 UseCase, API 구현 #5
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아직 Read API 설계는 하지 않았지만, ReadModel에는 기존서버의 user 정보가 필요합니다.
Read작업을 할 때마다 기존서버와 HTTP 통신을 통해서 가져올 수는 있지만 시스템간 결합 문제가 발생해 MSA의 장점이 사라진다고 생각합니다. 따라서 아래의 방법 중 하나로 해결해야 할 것 같습니다!!
- HTTP 통신으로 들고 오지만 들고온 데이터는 커뮤니티 서버에서 캐싱(만약 update되면 데이터 정합성 맞추기 힘들듯?)
- 기존 서버에 Batch를 돌려 user 정보를 메시지 큐에 발행하고 해당 서버에서 컨슘해 자체적으로 저장
data class ArticleImage( | ||
val images: List<String>? | ||
) { | ||
|
||
init { | ||
verifySize(images) | ||
} | ||
|
||
private fun verifySize(images: List<String>?) { | ||
if (!images.isNullOrEmpty() && images.size > 3) { | ||
throw ArticleImageSizeOverException() | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
회의 내용!! 기록
도메인의 대한 유효성 검사는 init + require()을 활용하기로 하였습니다.
require 함수를 사용하도록 수정하겠습니당
data class ArticleLike( | ||
val userId: UserId, | ||
val article: Article, | ||
val id: Long? = null, | ||
) { | ||
init { | ||
verifyArticle(article) | ||
} | ||
|
||
private fun verifyArticle(article: Article) { | ||
if (article.id == null) { | ||
throw RuntimeException("ArticleLike 생성 오류 : 영속화 되지 않은 Article을 입력으로 받았습니다.") | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ArticleLike
도메인을 생성할 때는 무조건 영속화된(Id를 가진) Aritcle을 받아야 합니다.
테스트 코드 작성중 발견한 도메인 유효성인데 해당 유효성 검증이 올바른지는 모르겠네요 ㅎ.ㅎ
plugins { | ||
id("java-test-fixtures") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
domain에서 정의한 test Fixture을 다른 모듈에서도 활용할 수 있도록하기 위해 java-test-fixtures을 활용하였습니다.
참고 블로그
resolved #4
작업한 일 🥹
논의 정리
카테고리를 Enum이 아닌 Table로 설계한 이유
카테고리는 현재 기획 상 정해져 있는 형식(Admin 페이지에서 직접 관리자가 등록안하는)이기 때문에 Enum으로 관리할 수 있지만, 이후 카테고리에 대한 변경 사항이 많이 발생할 것이라고 발생하고, Admin페이지에서 직접 카테고리를 관리자가 관리하게 확장하게 된다면 Table로 관리되어져야되기 때문에 유지보수 및 확장성을 생각하여 Table로 설계하였습니다.
DDL