-
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.
Merge pull request #100 from Sexy-Sisters/refactor
[Refactor] Wrap the primitive type of domain
- Loading branch information
Showing
77 changed files
with
577 additions
and
274 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
2 changes: 1 addition & 1 deletion
2
src/main/kotlin/com/sexysisters/tojserverv2/domain/approve/ApproveReader.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
4 changes: 2 additions & 2 deletions
4
src/main/kotlin/com/sexysisters/tojserverv2/domain/approve/policy/AlreadyJoinedPolicy.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
2 changes: 1 addition & 1 deletion
2
src/main/kotlin/com/sexysisters/tojserverv2/domain/approve/policy/ApprovePolicy.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
2 changes: 1 addition & 1 deletion
2
src/main/kotlin/com/sexysisters/tojserverv2/domain/approve/policy/SameSchoolPolicy.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
58 changes: 0 additions & 58 deletions
58
src/main/kotlin/com/sexysisters/tojserverv2/domain/school/School.kt
This file was deleted.
Oops, something went wrong.
2 changes: 2 additions & 0 deletions
2
src/main/kotlin/com/sexysisters/tojserverv2/domain/school/SchoolReader.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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
package com.sexysisters.tojserverv2.domain.school | ||
|
||
import com.sexysisters.tojserverv2.domain.school.domain.School | ||
|
||
interface SchoolReader { | ||
fun getSchool(code: String): School | ||
} |
2 changes: 2 additions & 0 deletions
2
src/main/kotlin/com/sexysisters/tojserverv2/domain/school/SchoolStore.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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
package com.sexysisters.tojserverv2.domain.school | ||
|
||
import com.sexysisters.tojserverv2.domain.school.domain.School | ||
|
||
interface SchoolStore { | ||
fun store(school: School): School | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/kotlin/com/sexysisters/tojserverv2/domain/school/domain/Address.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,19 @@ | ||
package com.sexysisters.tojserverv2.domain.school.domain | ||
|
||
import com.sexysisters.tojserverv2.domain.school.exception.SchoolException | ||
import javax.persistence.Column | ||
import javax.persistence.Embeddable | ||
import javax.validation.constraints.NotNull | ||
|
||
@Embeddable | ||
class Address( | ||
@field:NotNull | ||
@Column(name = "address", unique = true) | ||
val value: String | ||
) { | ||
init { | ||
val MAX_LENGTH = 34 | ||
if (value.isBlank()) throw SchoolException.SchoolNotValid() | ||
if (value.length > MAX_LENGTH) throw SchoolException.SchoolNotValid() | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/kotlin/com/sexysisters/tojserverv2/domain/school/domain/Belong.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,19 @@ | ||
package com.sexysisters.tojserverv2.domain.school.domain | ||
|
||
import com.sexysisters.tojserverv2.domain.school.exception.SchoolException | ||
import javax.persistence.Column | ||
import javax.persistence.Embeddable | ||
import javax.validation.constraints.NotNull | ||
|
||
@Embeddable | ||
class Belong( | ||
@field:NotNull | ||
@Column(name = "belong") | ||
val value: String | ||
) { | ||
init { | ||
val BELONG_FORMAT = "κ΅μ‘μ²" | ||
if (value.isBlank()) throw SchoolException.SchoolNotValid() | ||
if (!value.endsWith(BELONG_FORMAT)) throw SchoolException.SchoolNotValid() | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/kotlin/com/sexysisters/tojserverv2/domain/school/domain/Birthday.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,17 @@ | ||
package com.sexysisters.tojserverv2.domain.school.domain | ||
|
||
import com.sexysisters.tojserverv2.domain.school.exception.SchoolException | ||
import javax.persistence.Column | ||
import javax.persistence.Embeddable | ||
import javax.validation.constraints.NotNull | ||
|
||
@Embeddable | ||
class Birthday( | ||
@field:NotNull | ||
@Column(name = "code") | ||
val value: String | ||
) { | ||
init { | ||
if (value.isBlank()) throw SchoolException.SchoolNotValid() | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/kotlin/com/sexysisters/tojserverv2/domain/school/domain/Code.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,19 @@ | ||
package com.sexysisters.tojserverv2.domain.school.domain | ||
|
||
import com.sexysisters.tojserverv2.domain.school.exception.SchoolException | ||
import javax.persistence.Column | ||
import javax.persistence.Embeddable | ||
import javax.validation.constraints.NotNull | ||
|
||
@Embeddable | ||
class Code( | ||
@field:NotNull | ||
@Column(name = "code", unique = true) | ||
val value: String | ||
) { | ||
init { | ||
val CODE_LENGTH = 7 | ||
if (value.isBlank()) throw SchoolException.SchoolNotValid() | ||
if (value.length != CODE_LENGTH) throw SchoolException.SchoolNotValid() | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...ojserverv2/domain/school/type/Division.kt β ...serverv2/domain/school/domain/Division.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
17 changes: 17 additions & 0 deletions
17
src/main/kotlin/com/sexysisters/tojserverv2/domain/school/domain/HomePageAddress.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,17 @@ | ||
package com.sexysisters.tojserverv2.domain.school.domain | ||
|
||
import com.sexysisters.tojserverv2.domain.school.exception.SchoolException | ||
import javax.persistence.Column | ||
import javax.persistence.Embeddable | ||
import javax.validation.constraints.NotNull | ||
|
||
@Embeddable | ||
class HomePageAddress( | ||
@field:NotNull | ||
@Column(name = "home_page_address", unique = true) | ||
val value: String | ||
) { | ||
init { | ||
if (value.isBlank()) throw SchoolException.SchoolNotValid() | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...rs/tojserverv2/domain/school/type/Kind.kt β .../tojserverv2/domain/school/domain/Kind.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
20 changes: 20 additions & 0 deletions
20
src/main/kotlin/com/sexysisters/tojserverv2/domain/school/domain/Name.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,20 @@ | ||
package com.sexysisters.tojserverv2.domain.school.domain | ||
|
||
import com.sexysisters.tojserverv2.domain.school.exception.SchoolException | ||
import javax.persistence.Column | ||
import javax.persistence.Embeddable | ||
import javax.validation.constraints.NotNull | ||
|
||
@Embeddable | ||
class Name( | ||
@field:NotNull | ||
@Column(name = "name") | ||
val value: String | ||
) { | ||
init { | ||
val MAX_LENGTH = 21 | ||
if (value.isBlank()) throw SchoolException.SchoolNotValid() | ||
if (value.endsWith("νκ΅")) throw SchoolException.SchoolNotValid() | ||
if (value.length > MAX_LENGTH) throw SchoolException.SchoolNotValid() | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/kotlin/com/sexysisters/tojserverv2/domain/school/domain/Phone.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,20 @@ | ||
package com.sexysisters.tojserverv2.domain.school.domain | ||
|
||
import com.sexysisters.tojserverv2.domain.school.exception.SchoolException | ||
import javax.persistence.Column | ||
import javax.persistence.Embeddable | ||
import javax.validation.constraints.NotNull | ||
|
||
@Embeddable | ||
class Phone( | ||
@field:NotNull | ||
@Column(name = "phone", unique = true) | ||
val value: String | ||
) { | ||
init { | ||
val MIN_LENGTH = 11 | ||
val MAX_LENTH = 12 | ||
if (value.isBlank()) throw SchoolException.SchoolNotValid() | ||
if (value.length !in MIN_LENGTH..MAX_LENTH) throw SchoolException.SchoolNotValid() | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/main/kotlin/com/sexysisters/tojserverv2/domain/school/domain/School.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,49 @@ | ||
package com.sexysisters.tojserverv2.domain.school.domain | ||
|
||
import com.sexysisters.tojserverv2.domain.BaseTimeEntity | ||
import com.sexysisters.tojserverv2.domain.student.domain.Student | ||
import com.sexysisters.tojserverv2.domain.teacher.domain.Teacher | ||
import com.sexysisters.tojserverv2.domain.wiki.domain.Wiki | ||
import javax.persistence.* | ||
|
||
@Entity | ||
@Table(name = "tbl_school") | ||
class School( | ||
@Embedded val code: Code, | ||
@Embedded val belong: Belong, | ||
@Embedded val name: Name, | ||
@Embedded val address: Address, | ||
@Embedded val birthday: Birthday, | ||
@Embedded val homePageAddress: HomePageAddress, | ||
@Embedded val phone: Phone, | ||
// TODO :: νμ | ||
) : BaseTimeEntity() { | ||
|
||
@Enumerated(EnumType.STRING) | ||
var division: Division? = null | ||
|
||
@Enumerated(EnumType.STRING) | ||
var kind: Kind? = null | ||
|
||
@OneToMany(mappedBy = "school", cascade = [CascadeType.ALL]) | ||
val students = mutableSetOf<Student>() | ||
|
||
@OneToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "wiki_id") | ||
var wiki: Wiki? = null | ||
|
||
@OneToMany(mappedBy = "school", cascade = [CascadeType.ALL]) | ||
val teachers = mutableSetOf<Teacher>() | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
val id: Long = 0L | ||
|
||
fun getCodeValue() = code.value | ||
fun getBelongValue() = belong.value | ||
fun getNameValue() = name.value | ||
fun getAddressValue() = address.value | ||
fun getBirthdayValue() = birthday.value | ||
fun getHomePageAddressValue() = homePageAddress.value | ||
fun getPhoneValue() = phone.value | ||
} |
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.