package gaf3.core.services.role.entity

import java.io.Serializable
import java.util.*
import javax.persistence.*


/**
 * The persistent class for the GAF_CODE_ITEM database table.
 *
 */
@Entity
@Table(name = "GAF_ROLE_ITEM")
class GafRoleItem @JvmOverloads constructor(id: String? = null, code: String? = null, name: String? = null) : Serializable {

    @Id
    @Column(name = "ID", length = 48)
    var id: String? = null

    @Column(name = "ITEM_TYPE", length = 48)
    var type: String? = null // 类型：group - 角色组(组合角色)； item - 角色项；

    @Column(name = "CODE", length = 48)
    var code: String? = null

    @Column(name = "NAME", length = 48)
    var name: String? = null

    @Column(name = "PRESET")
    var preset: Int? = null // 是否预设值： 0-否，1-是；系统预设值不可删除

    @Column(name = "REMARK")
    var remark: String? = null

    @Column(name = "RANKING")
    var ranking: Long? = null

    @PrePersist
    fun insertTime() {
        if(ranking == null) ranking = Calendar.getInstance().timeInMillis
    }

    init {
        this.id = id
        this.code = code
        this.name = name
    }

    companion object {
        private const val serialVersionUID = 1L
    }

}