package gaf3.core.services.log.entity

import gaf3.core.jpa.GafTimestamp
import javax.persistence.*


/**
 * The persistent class for the GAF_LOG database table.
 *
 */
@Entity
@Table(name = "GAF_LOG")
class GafLog : GafTimestamp() {

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

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

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

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

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

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

    @Column(name = "TARGET")
    var target: String? = null

    @Column(name = "PARAM")
    var param: String? = null

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

    @Column(name = "DETAIL", length = 500)
    var detail: String? = null

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

    @Column(name = "TIMESTAMP")
    var timestamp: Long? = null

    @Column(name = "EXTRA", length = 500)
    var extra: String? = null

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

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

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

    @PrePersist
    fun logTimestamp() {
        timestamp = timestamp ?: System.currentTimeMillis()
    }
}