Skip to content

User 엔티티 설계 #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/main/kotlin/andreas311/miso/domain/user/entity/User.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package andreas311.miso.domain.user.entity

import andreas311.miso.domain.user.enums.Role
import org.hibernate.annotations.DynamicUpdate
import org.hibernate.annotations.GenericGenerator
import java.util.*
import javax.persistence.*

@Entity
@DynamicUpdate
class User(

@Id
@GeneratedValue(generator = "uuid2")
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(columnDefinition = "BINARY(16)")
var id: UUID,

val email: String,

val password: String,

@Enumerated(EnumType.STRING)
@ElementCollection(fetch = FetchType.EAGER)
@CollectionTable(name = "Role", joinColumns = [JoinColumn(name = "user_id")])
val role: MutableList<Role>
) {
}
9 changes: 9 additions & 0 deletions src/main/kotlin/andreas311/miso/domain/user/enums/Role.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package andreas311.miso.domain.user.enums

import org.springframework.security.core.GrantedAuthority

enum class Role(description: String) : GrantedAuthority {
ROLE_USER("사용자"), ROLE_ADMIN("관리자");

override fun getAuthority(): String = name
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package andreas311.miso.domain.user.repository

import andreas311.miso.domain.user.entity.User
import org.springframework.data.repository.CrudRepository
import java.util.UUID

interface UserRepository : CrudRepository<User, UUID> {
}