This repository has been archived by the owner on May 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WEAV-113] Add domain University and Major (#30)
- Loading branch information
Showing
20 changed files
with
180 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
domain/src/main/kotlin/com/studentcenter/weave/domain/entity/Major.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.studentcenter.weave.domain.entity | ||
|
||
import com.studentcenter.weave.domain.vo.MajorName | ||
import com.studentcenter.weave.support.common.uuid.UuidCreator | ||
import java.time.LocalDateTime | ||
import java.util.* | ||
|
||
data class Major( | ||
val id: UUID = UuidCreator.create(), | ||
val univId:UUID, | ||
val name: MajorName, | ||
val createdAt: LocalDateTime = LocalDateTime.now(), | ||
) { | ||
|
||
|
||
companion object { | ||
fun create(univId: UUID, name: MajorName): Major { | ||
return Major(univId = univId, name = name) | ||
} | ||
} | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
domain/src/main/kotlin/com/studentcenter/weave/domain/entity/University.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.studentcenter.weave.domain.entity | ||
|
||
import com.studentcenter.weave.domain.vo.UniversityName | ||
import com.studentcenter.weave.support.common.uuid.UuidCreator | ||
import java.time.LocalDateTime | ||
import java.util.* | ||
|
||
data class University( | ||
val id: UUID = UuidCreator.create(), | ||
val name: UniversityName, | ||
val domainAddress: String, | ||
val logoAddress: String, | ||
val createdAt: LocalDateTime = LocalDateTime.now(), | ||
val updatedAt: LocalDateTime = LocalDateTime.now(), | ||
) { | ||
|
||
|
||
companion object { | ||
fun create( | ||
name: UniversityName, | ||
domainAddress: String, | ||
logoAddress: String, | ||
): University { | ||
return University( | ||
name = name, | ||
domainAddress = domainAddress, | ||
logoAddress = logoAddress, | ||
) | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 0 additions & 11 deletions
11
domain/src/main/kotlin/com/studentcenter/weave/domain/vo/Major.kt
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
domain/src/main/kotlin/com/studentcenter/weave/domain/vo/MajorName.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.studentcenter.weave.domain.vo | ||
|
||
@JvmInline | ||
value class MajorName(val value: String) { | ||
|
||
init { | ||
require(value.isNotBlank()) { "전공명은 공백일 수 없습니다." } | ||
require(value.length <= 30) { "전공명은 30자 이하여야 합니다." } | ||
} | ||
|
||
} |
11 changes: 0 additions & 11 deletions
11
domain/src/main/kotlin/com/studentcenter/weave/domain/vo/University.kt
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
domain/src/main/kotlin/com/studentcenter/weave/domain/vo/UniversityName.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.studentcenter.weave.domain.vo | ||
|
||
@JvmInline | ||
value class UniversityName(val value: String) { | ||
|
||
init { | ||
require(value.isNotBlank()) { "대학교 이름은 공백일 수 없습니다." } | ||
require(value.length <= 30) { "대학교 이름은 30자 이하여야 합니다." } | ||
} | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
domain/src/test/kotlin/com/studentcenter/weave/domain/entity/MajorTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.studentcenter.weave.domain.entity | ||
import com.studentcenter.weave.domain.vo.MajorName | ||
import com.studentcenter.weave.support.common.uuid.UuidCreator | ||
import io.kotest.core.spec.style.FunSpec | ||
import io.kotest.matchers.comparables.shouldBeLessThanOrEqualTo | ||
import io.kotest.matchers.shouldBe | ||
import java.time.LocalDateTime | ||
|
||
class MajorTest : FunSpec({ | ||
|
||
test("대학교 생성") { | ||
// arrange | ||
val name = MajorName(value = "컴퓨터공학과") | ||
|
||
// act | ||
val major = Major.create( | ||
univId = UuidCreator.create(), | ||
name = name | ||
) | ||
|
||
// assert | ||
major.name shouldBe name | ||
major.createdAt shouldBeLessThanOrEqualTo LocalDateTime.now() | ||
} | ||
|
||
}) |
31 changes: 31 additions & 0 deletions
31
domain/src/test/kotlin/com/studentcenter/weave/domain/entity/UniversityTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.studentcenter.weave.domain.entity | ||
|
||
import com.studentcenter.weave.domain.vo.UniversityName | ||
import io.kotest.core.spec.style.FunSpec | ||
import io.kotest.matchers.comparables.shouldBeLessThanOrEqualTo | ||
import io.kotest.matchers.shouldBe | ||
import java.time.LocalDateTime | ||
|
||
class UniversityTest : FunSpec({ | ||
|
||
test("대학교 생성") { | ||
// arrange | ||
val name = UniversityName("명지대학교") | ||
val domainAddress = "mju.ac.kr" | ||
val logoAddress = "/public/university/1/logo" | ||
|
||
// act | ||
val univ = University.create( | ||
name = name, | ||
domainAddress = domainAddress, | ||
logoAddress = logoAddress, | ||
) | ||
|
||
// assert | ||
univ.name shouldBe name | ||
univ.domainAddress shouldBe domainAddress | ||
univ.logoAddress shouldBe logoAddress | ||
univ.createdAt shouldBeLessThanOrEqualTo LocalDateTime.now() | ||
} | ||
|
||
}) |
2 changes: 0 additions & 2 deletions
2
domain/src/test/kotlin/com/studentcenter/weave/domain/entity/UserAuthInfoTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,14 +3,12 @@ package com.studentcenter.weave.domain.entity | |
import com.studentcenter.weave.domain.enum.Gender | ||
import com.studentcenter.weave.domain.enum.Mbti | ||
import com.studentcenter.weave.domain.vo.BirthYear | ||
import com.studentcenter.weave.domain.vo.Major | ||
import com.studentcenter.weave.domain.vo.MajorName | ||
import com.studentcenter.weave.domain.vo.Nickname | ||
import com.studentcenter.weave.domain.vo.University | ||
import com.studentcenter.weave.domain.vo.UniversityName | ||
import com.studentcenter.weave.support.common.vo.Email | ||
import io.kotest.core.spec.style.FunSpec | ||
import io.kotest.matchers.shouldBe | ||
import java.time.Instant | ||
import java.time.LocalDateTime | ||
|
||
class UserTest : FunSpec({ | ||
|
||
|
@@ -20,8 +18,8 @@ class UserTest : FunSpec({ | |
val email = Email("[email protected]") | ||
val gender = Gender.MAN | ||
val birthYear = BirthYear(1999) | ||
val university = University("서울대학교") | ||
val major = Major("컴퓨터 공학과") | ||
val university = UniversityName("서울대학교") | ||
val major = MajorName("컴퓨터 공학과") | ||
val mbti = Mbti.ENFJ | ||
|
||
// act | ||
|
@@ -44,10 +42,4 @@ class UserTest : FunSpec({ | |
user.major shouldBe major | ||
} | ||
|
||
test("test") { | ||
println(Instant.now()) | ||
println(LocalDateTime.now()) | ||
} | ||
|
||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.