-
Notifications
You must be signed in to change notification settings - Fork 1
/
User.kt
48 lines (39 loc) · 1.25 KB
/
User.kt
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
package com.restaurant.be.user.domain.entity
import com.restaurant.be.common.converter.SeparatorConverter
import com.restaurant.be.common.password.PasswordService
import com.restaurant.be.user.presentation.dto.UpdateUserRequest
import javax.persistence.Column
import javax.persistence.Convert
import javax.persistence.Entity
import javax.persistence.GeneratedValue
import javax.persistence.GenerationType
import javax.persistence.Id
import javax.persistence.Table
@Entity
@Table(name = "users")
class User(
@Id
@Column
@GeneratedValue(strategy = GenerationType.IDENTITY)
var id: Long? = null,
@Column(unique = true)
var email: String = "",
@Column(unique = true)
var nickname: String = "",
@Column
var password: String = "",
@Column(columnDefinition = "boolean default false")
var withdrawal: Boolean = false,
@Convert(converter = SeparatorConverter::class)
var roles: List<String> = listOf(),
@Column
var profileImageUrl: String
) {
fun updatePassword(password: String) {
this.password = password.run(PasswordService::hashPassword)
}
fun updateUser(request: UpdateUserRequest) {
this.nickname = request.nickname
this.profileImageUrl = request.profileImageUrl
}
}