Commit 40e15017 authored by Ghitha Dinan's avatar Ghitha Dinan

add role user

parent 65c9aade
Pipeline #399 canceled with stages
package id.go.kemenag.madrasah.pmrms.auth.pojo
import com.fasterxml.jackson.annotation.JsonFormat
import com.fasterxml.jackson.annotation.JsonIgnore
import id.go.kemenag.madrasah.pmrms.auth.constant.VALIDATOR_MSG_REQUIRED
import java.util.*
import javax.persistence.Column
import javax.persistence.Entity
import javax.persistence.Id
import javax.persistence.Table
import javax.validation.constraints.NotEmpty
@Entity
@Table(name = "role", schema = "auth")
data class Role(
@Id
@Column(name = "id")
var id: String? = UUID.randomUUID().toString(),
@Column(name = "name")
@field:NotEmpty(message = "Nama $VALIDATOR_MSG_REQUIRED")
var name: String? = null,
@Column(name = "created_at")
@get:JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy HH:mm:ss", timezone = "GMT+7")
var createdAt: Date? = Date(),
@Column(name = "updated_at")
@get:JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy HH:mm:ss", timezone = "GMT+7")
var updatedAt: Date? = Date(),
@Column(name = "active")
@JsonIgnore
var active: Boolean? = true
)
......@@ -2,11 +2,9 @@ package id.go.kemenag.madrasah.pmrms.auth.pojo
import com.fasterxml.jackson.annotation.JsonFormat
import com.fasterxml.jackson.annotation.JsonIgnore
import org.hibernate.annotations.Where
import java.util.*
import javax.persistence.Column
import javax.persistence.Entity
import javax.persistence.Id
import javax.persistence.Table
import javax.persistence.*
@Entity
@Table(name = "users", schema = "auth")
......@@ -28,6 +26,10 @@ data class Users(
@Column(name = "last_name")
var lastName: String? = null,
@OneToMany(mappedBy = "userId")
@Where(clause = "active = true")
var roles: MutableSet<UsersRole>? = null,
@Column(name = "created_at")
@get:JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy HH:mm:ss", timezone = "GMT+7")
var createdAt: Date? = Date(),
......
package id.go.kemenag.madrasah.pmrms.auth.pojo
import com.fasterxml.jackson.annotation.JsonFormat
import com.fasterxml.jackson.annotation.JsonIgnore
import java.util.*
import javax.persistence.*
@Entity
@Table(name = "users_role", schema = "auth")
data class UsersRole(
@Id
@Column(name = "id")
var id: String? = UUID.randomUUID().toString(),
@Column(name = "user_id")
var userId: String? = null,
@Column(name = "role_id")
var roleId: String? = null,
@ManyToOne
@JoinColumn(name = "role_id", insertable = false, updatable = false, nullable = true)
var role: Role? = null,
@Column(name = "created_at")
@get:JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy HH:mm:ss", timezone = "GMT+7")
var createdAt: Date? = Date(),
@Column(name = "updated_at")
@get:JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy HH:mm:ss", timezone = "GMT+7")
var updatedAt: Date? = Date(),
@Column(name = "active")
@JsonIgnore
var active: Boolean? = true
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment