-
Notifications
You must be signed in to change notification settings - Fork 2
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
Feature/create user #38
Conversation
- user 도메인 계층, 응용 계층, 표현 계층 생성 - createUser, getUser 엔드 포인트 생성
- name, email, address 필드 유무 체크 - user 객체 단위 테스트 작성
- 기본 프로파일 일때 logging.xml import 제외
📝 테스트 커버리지 리포트입니다
|
📝 테스트 커버리지 리포트입니다
|
📝 테스트 커버리지 리포트입니다
|
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.
수고하셨습니다.
private val userWriter: UserWriter, | ||
) { | ||
|
||
fun createUser(request: CreateUserRequest): CreateUserResponse { |
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.
회원가입 로직으로 보이는데, 간단하게 중복검사 로직정도 추가하는 건 어떠신가요?
또한 실제 커머스라고 한다면 구매자와 판매자는 회원가입 과정에서 서로 다르게 요구사항이 발전하게 될 것 같습니다. User 도메인 모델을 하나로 쓰기로 논의했지만, API 와 서비스 레이어는 분리해서 정의하는 건 어떠신가요?
예를 들어, 구매자와 판매자는 회원가입 과정에서 다음과 같이 다를 수 있을 것다고 생각합니다.
- 구매자 - 장바구니 추가, 구매자 등급 부여, 회원가입 축하 쿠폰 부여 등
- 판매자 - 상점 추가 및 연결, 판매자 권한 부여 등
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 { | ||
if (name.isBlank()) { | ||
throw IllegalArgumentException("이름은 비어 있을 수 없습니다") | ||
} | ||
if (email.isBlank()) { | ||
throw IllegalArgumentException("이메일은 비어 있을 수 없습니다") | ||
} | ||
if (address.isBlank()) { | ||
throw IllegalArgumentException("주소는 비어 있을 수 없습니다") | ||
} | ||
} |
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.
프로퍼티들에 대한 유효성 검사 로직을 User 도메인 모델 안에 정의함으로써 응집도를 높일 수 있는 것 같아 좋은 것 같습니다.
val email: String, | ||
val address: String, | ||
val userType: UserType, | ||
var id: Long? = null, |
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.
id 를 var와 Nullable 타입으로 선언하신 이유가 궁금합니다! id는 Null을 허용하지 않고 재할당될 수 없는 프로퍼티라고 생각합니다.
UUID 혹은 ULID를 활용하면 DB의 시퀀스나 auto-increment를 사용하지않고 객체 생성 시점에 ID에 값을 할당할 수 있습니다.
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.
말씀해주신대로 값 변경이 안되도록 val 타입을 사용하는게 맞는것 같습니다. id값을 UUID로 사용하면 nullable 타입으로 사용안해도 괜찮을 것 같네요
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.
UserService 라는 네이밍에 대해 고민해볼 필요가 있을 것 같습니다. UserService라는 이름은 책임의 범위가 넓고 모호하게 느껴지는 것 같습니다.
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.
네 특징 별로 구분하는것이 좋을것 같네요
protected set | ||
var id: Long? = null, | ||
) { | ||
companion object { |
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.
Entity 와 Domain 모델 간의 변환에 있어서 공통된 컨벤션이 필요할 것 같습니다.
Entity Model -> Domain Model 변환하는 로직을 정적 팩토리 함수로 정의해주신 대로 결정해도 괜찮을 것 같습니다.
정적 팩토리 함수에 대한 네이밍을 고민해볼 수 있을 것 같은데, 이펙티브 코틀린에서 제시하는 다음과 같은 방법들은 어떠신가요?
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.
네 이펙티브 코틀린에서 제시한 메소드명 컨밴션을 참고하면 좋을것 같네요 😄
User( | ||
id = it.id!!, | ||
name = it.name!!, | ||
email = it.email!!, | ||
address = it.address!!, | ||
age = it.age, | ||
userType = it.userType, | ||
) |
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.
마찬가지로 UserEntity -> User 로 변환하는 정적 팩토리 함수를 정의해서 활용할 수 있을 것 같습니다!
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.
spring.config.import=logging.yml
구문은 공통적으로 application.yml 파일에 적용할 수 있을 것 같은데 옮기신 이유가 있을까요???
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.
logging.xml에서 환경변수 ${spring.profiles.active}값을 가져오는데 ci서버에서 test를 진행할 때 이 환경변수 값이 없어서 에러가 발생하여서 application.yml에 logging.yml을 제외하고 다른 프로파일 application.yml에만 추가하였습니다.
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.
수고하셨습니다 ~ : )
|
||
import com.hanghae.commerce.user.domain.UserType | ||
|
||
data class CreateUserRequest( |
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.
DTO에서는 유효성 검사가 필요없을까요?
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.
일단 도메인에만 유효성 검사를 추가하였는데 DTO단에서도 유효성 검사가 필요할 것 같네요 😄
|
||
@Entity | ||
@Table(name = "users") | ||
class UserEntity( |
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.
UserEntity는 equals, hashcode를 override할 필요가 없을까요?
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.
네 equals, hashcode메소드를 override할 필요가 있을것 같습니다
import org.springframework.stereotype.Service | ||
|
||
@Service | ||
class UserService( |
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.
application layer는 어떤 역할을 하고 Service를 해당 layer에 둔 이유는 무엇일까요?
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.
저는 응용계층을 표현계층에 최종적으로 보여주는 데이터를 만들어주는 계층으로 보고 있습니다. 그래서 UserService를 응용서비스 클래스로 보고 응용계층에 배치를 하게 된 것 같습니다. 혹시 은지님은 다른 관점에서 UserService클래스를 바라보셨을까요??
📝 테스트 커버리지 리포트입니다
|
- User.createUser -> User.of - UserEntity.toEntity -> userEntity.from
📝 테스트 커버리지 리포트입니다
|
📝 테스트 커버리지 리포트입니다
|
#31
📌 요약
📕 무엇을 작업하셨나요?
📖 변경사항
✅ 체크리스트