This repository was archived by the owner on Jul 7, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUser.kt
More file actions
60 lines (53 loc) · 1.71 KB
/
User.kt
File metadata and controls
60 lines (53 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package com.asap.domain.user.entity
import com.asap.application.user.event.UserEvent
import com.asap.domain.common.Aggregate
import com.asap.domain.common.DomainId
import com.asap.domain.user.vo.UserPermission
import java.time.LocalDate
import java.time.LocalDateTime
class User(
id: DomainId,
var username: String,
var profileImage: String,
var email: String,
val permission: UserPermission,
var birthday: LocalDate?,
var onboardingAt: LocalDateTime?,
createdAt: LocalDateTime,
updatedAt: LocalDateTime,
var unregisterReason: String? = null,
) : Aggregate<User>(id, createdAt, updatedAt) {
companion object {
fun create(
id: DomainId = DomainId.generate(),
username: String,
profileImage: String,
email: String,
permission: UserPermission,
birthday: LocalDate?,
createdAt: LocalDateTime = LocalDateTime.now(),
updatedAt: LocalDateTime = LocalDateTime.now(),
): User =
User(id, username, profileImage, email, permission, birthday, null, createdAt, updatedAt).also {
it.registerEvent(UserEvent.UserCreatedEvent(it))
}
}
fun delete(reason: String) {
this.profileImage = "UNKNOWN"
this.birthday = null
this.unregisterReason = reason
registerEvent(UserEvent.UserDeletedEvent(this))
updateTime()
}
fun updateBirthday(birthday: LocalDate) {
this.birthday = birthday
updateTime()
}
fun updateOnboarding() {
this.onboardingAt = LocalDateTime.now()
updateTime()
}
fun isProcessedOnboarding(): Boolean {
return this.onboardingAt != null
}
}