Skip to content
This repository has been archived by the owner on May 19, 2024. It is now read-only.

Commit

Permalink
[WEAV-164] VO 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
waterfogSW committed Feb 3, 2024
1 parent 219eafd commit f683fff
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.studentcenter.weave.bootstrap.user.dto.UserGetMyProfileResponse
import com.studentcenter.weave.bootstrap.user.dto.UserRegisterRequest
import com.studentcenter.weave.bootstrap.user.dto.UserRegisterResponse
import com.studentcenter.weave.domain.user.vo.BirthYear
import com.studentcenter.weave.domain.user.vo.Mbti
import com.studentcenter.weave.support.common.uuid.UuidCreator
import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
Expand All @@ -29,7 +30,7 @@ class UserRestController(
email = registerTokenClaim.email,
socialLoginProvider = registerTokenClaim.socialLoginProvider,
gender = request.gender,
mbti = request.mbti,
mbti = Mbti(request.mbti),
birthYear = BirthYear(request.birthYear),
universityId = request.universityId,
majorId = request.majorId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.studentcenter.weave.bootstrap.user.dto

import com.studentcenter.weave.domain.user.enums.Gender
import com.studentcenter.weave.domain.user.vo.Mbti
import io.swagger.v3.oas.annotations.media.Schema
import java.util.*

Expand All @@ -12,7 +11,7 @@ import java.util.*
data class UserRegisterRequest(
val gender: Gender,
val birthYear: Int,
val mbti: Mbti,
val mbti: String,
val universityId: UUID,
val majorId: UUID,
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package com.studentcenter.weave.domain.user.vo
import java.time.Year

@JvmInline
value class BirthYear(val year: Int) {
value class BirthYear(val value: Int) {

init {
require(year in 1900..Year.now().value) {
require(value in 1900..Year.now().value) {
"생년월일은 1900년 이후, 현재 년도 이전이어야 합니다"
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.studentcenter.weave.domain.user.vo

@JvmInline
value class Height(val height: Int) {
value class Height(val value: Int) {

init {
require(height in 1..300) {
require(value in 1..300) {
"키는 1cm 이상 300cm 이하여야 합니다."
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.studentcenter.weave.infrastructure.persistence.university.entity

import com.studentcenter.weave.domain.university.vo.MajorName
import jakarta.persistence.Column
import jakarta.persistence.Entity
import jakarta.persistence.Id
Expand All @@ -13,9 +12,10 @@ import java.util.*
class MajorJpaEntity(
id: UUID,
univId: UUID,
name: MajorName,
name: String,
createdAt: LocalDateTime,
) {

@Id
var id: UUID = id
private set
Expand All @@ -25,7 +25,7 @@ class MajorJpaEntity(
private set

@Column(nullable = false)
var name: MajorName = name
var name: String = name
private set

@Column(nullable = false)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.studentcenter.weave.infrastructure.persistence.university.entity

import com.studentcenter.weave.domain.university.vo.UniversityName
import jakarta.persistence.Column
import jakarta.persistence.Entity
import jakarta.persistence.Id
Expand All @@ -12,18 +11,19 @@ import java.util.*
@Table(name = "university")
class UniversityJpaEntity(
id: UUID,
name: UniversityName,
name: String,
domainAddress: String,
logoAddress: String,
createdAt: LocalDateTime,
updatedAt: LocalDateTime,
) {

@Id
var id: UUID = id
private set

@Column(unique = true, nullable = false)
var name: UniversityName = name
var name: String = name
private set

@Column(nullable = false, columnDefinition = "varchar(255)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.studentcenter.weave.infrastructure.persistence.user.entity

import com.studentcenter.weave.domain.user.entity.DeletedUserInfo
import com.studentcenter.weave.domain.user.enums.SocialLoginProvider
import com.studentcenter.weave.support.common.vo.Email
import jakarta.persistence.Column
import jakarta.persistence.Entity
import jakarta.persistence.EnumType
Expand All @@ -14,21 +13,21 @@ import java.util.*

@Entity
@Table(name = "deleted_user_info")
class DeletedUserInfoJpaEntity (
class DeletedUserInfoJpaEntity(
id: UUID,
email: Email,
email: String,
socialLoginProvider: SocialLoginProvider,
reason: String? = null,
registeredAt: LocalDateTime,
deletedAt: LocalDateTime
){
) {

@Id
var id: UUID = id
private set

@Column(nullable = false)
var email: Email = email
var email: String = email
private set

@Column(nullable = false, columnDefinition = "varchar(255)")
Expand All @@ -49,10 +48,11 @@ class DeletedUserInfoJpaEntity (
private set

companion object {

fun DeletedUserInfo.toJpaEntity(): DeletedUserInfoJpaEntity {
return DeletedUserInfoJpaEntity(
id = id,
email = email,
email = email.value,
socialLoginProvider = socialLoginProvider,
reason = reason,
registeredAt = registeredAt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import java.util.*
class UserAuthInfoJpaEntity(
id: UUID,
userId: UUID,
email: Email,
email: String,
socialLoginProvider: SocialLoginProvider,
registeredAt: LocalDateTime,
) {
Expand All @@ -31,7 +31,7 @@ class UserAuthInfoJpaEntity(
private set

@Column(unique = true, nullable = false)
var email: Email = email
var email: String = email
private set

@Column(nullable = false, columnDefinition = "varchar(255)")
Expand All @@ -49,7 +49,7 @@ class UserAuthInfoJpaEntity(
return UserAuthInfoJpaEntity(
id = id,
userId = userId,
email = email,
email = email.value,
socialLoginProvider = socialLoginProvider,
registeredAt = registeredAt,
)
Expand All @@ -61,7 +61,7 @@ class UserAuthInfoJpaEntity(
return UserAuthInfo(
id = id,
userId = userId,
email = email,
email = Email(email),
socialLoginProvider = socialLoginProvider,
registeredAt = registeredAt,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ package com.studentcenter.weave.infrastructure.persistence.user.entity
import com.studentcenter.weave.domain.user.entity.User
import com.studentcenter.weave.domain.user.enums.AnimalType
import com.studentcenter.weave.domain.user.enums.Gender
import com.studentcenter.weave.domain.user.vo.Mbti
import com.studentcenter.weave.domain.user.vo.BirthYear
import com.studentcenter.weave.domain.user.vo.Height
import com.studentcenter.weave.domain.user.vo.Mbti
import com.studentcenter.weave.domain.user.vo.Nickname
import com.studentcenter.weave.support.common.vo.Email
import com.studentcenter.weave.support.common.vo.Url
import jakarta.persistence.Column
import jakarta.persistence.Embedded
import jakarta.persistence.Entity
import jakarta.persistence.EnumType
import jakarta.persistence.Enumerated
Expand All @@ -23,15 +22,15 @@ import java.util.*
@Table(name = "`user`")
class UserJpaEntity(
id: UUID,
nickname: Nickname,
email: Email,
nickname: String,
email: String,
gender: Gender,
mbti: Mbti,
birthYear: BirthYear,
mbti: String,
birthYear: Int,
universityId: UUID,
majorId: UUID,
avatar: Url? = null,
height: Height? = null,
avatar: String? = null,
height: Int? = null,
animalType: AnimalType? = null,
registeredAt: LocalDateTime,
updatedAt: LocalDateTime,
Expand All @@ -43,11 +42,11 @@ class UserJpaEntity(
private set

@Column(nullable = false, updatable = false)
var nickname: Nickname = nickname
var nickname: String = nickname
private set

@Column(nullable = false, updatable = false)
var email: Email = email
var email: String = email
private set

@Column(nullable = false, updatable = false, columnDefinition = "varchar(255)")
Expand All @@ -56,16 +55,15 @@ class UserJpaEntity(
private set

@Column(nullable = false, columnDefinition = "varchar(255)")
var mbti: Mbti = mbti
var mbti: String = mbti
private set

@Column(nullable = false)
var birthYear: BirthYear = birthYear
var birthYear: Int = birthYear
private set

@Embedded
@Column(nullable = true, updatable = true, columnDefinition = "integer")
var height: Height? = height
var height: Int? = height
private set

@Column(nullable = false, updatable = false)
Expand All @@ -77,7 +75,7 @@ class UserJpaEntity(
private set

@Column(nullable = true)
var avatar: Url? = avatar
var avatar: String? = avatar
private set

@Column(nullable = true, updatable = true, columnDefinition = "varchar(255)")
Expand All @@ -98,15 +96,15 @@ class UserJpaEntity(
fun User.toJpaEntity(): UserJpaEntity {
return UserJpaEntity(
id = id,
nickname = nickname,
email = email,
nickname = nickname.value,
email = email.value,
gender = gender,
mbti = mbti,
birthYear = birthYear,
mbti = mbti.value,
birthYear = birthYear.value,
universityId = universityId,
majorId = majorId,
avatar = avatar,
height = height,
avatar = avatar?.value,
height = height?.value,
animalType = animalType,
registeredAt = registeredAt,
updatedAt = updatedAt,
Expand All @@ -117,15 +115,15 @@ class UserJpaEntity(
fun toDomain(): User {
return User(
id = id,
nickname = nickname,
email = email,
nickname = Nickname(nickname),
email = Email(email),
gender = gender,
mbti = mbti,
birthYear = birthYear,
mbti = Mbti(mbti),
birthYear = BirthYear(birthYear),
universityId = universityId,
majorId = majorId,
avatar = avatar,
height = height,
avatar = avatar?.let { Url(it) },
height = height?.let { Height(it) },
animalType = animalType,
registeredAt = registeredAt,
updatedAt = updatedAt,
Expand Down

0 comments on commit f683fff

Please sign in to comment.