add more stuff

This commit is contained in:
gowthaman.b
2024-01-05 12:08:27 +05:30
parent 82fb57bd85
commit d506078804
7 changed files with 306 additions and 22 deletions

View File

@@ -5,17 +5,8 @@ import com.fasterxml.jackson.databind.DeserializationContext
import com.fasterxml.jackson.databind.JsonDeserializer
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import io.ebean.Model
import io.ebean.annotation.DbArray
import io.ebean.annotation.DbDefault
import io.ebean.annotation.DbJsonB
import io.ebean.annotation.*
import io.ebean.annotation.Index
import io.ebean.annotation.Platform
import io.ebean.annotation.SoftDelete
import io.ebean.annotation.TenantId
import io.ebean.annotation.WhenCreated
import io.ebean.annotation.WhenModified
import io.ebean.annotation.WhoCreated
import io.ebean.annotation.WhoModified
import java.time.LocalDateTime
import javax.persistence.*
@@ -48,7 +39,6 @@ abstract class BaseModel : Model() {
var modifiedAt: LocalDateTime? = null
@WhoCreated
var createdBy: String = ""
@@ -61,6 +51,7 @@ abstract class BaseModel : Model() {
@DbDefault("0")
var currentApprovalLevel: Int = 0
@DbDefault("0")
var requiredApprovalLevels: Int = 0
@@ -110,11 +101,17 @@ open class AuditLog : BaseTenantModel() {
var uniqueIdentifier: String = ""
@DbJsonB
@Index(definition = "create index audit_log_values_idx on audit_log using GIN (data)", platforms = [Platform.POSTGRES])
@Index(
definition = "create index audit_log_values_idx on audit_log using GIN (data)",
platforms = [Platform.POSTGRES]
)
var data: Map<String, Any> = hashMapOf()
@DbJsonB
@Index(definition = "create index audit_log_changes_idx on audit_log using GIN (changes)", platforms = [Platform.POSTGRES])
@Index(
definition = "create index audit_log_changes_idx on audit_log using GIN (changes)",
platforms = [Platform.POSTGRES]
)
var changes: Map<String, Any> = hashMapOf()
}
@@ -171,7 +168,7 @@ enum class JobType {
@Entity
@Index(unique = true, name = "sql_unique_id", columnNames = ["entity_name", "sql_id", "tenant_id"])
open class SqlModel : BaseTenantModel(){
open class SqlModel : BaseTenantModel() {
@JsonDeserialize(using = SafeStringDeserializer::class)
var sqlId: String = ""
@@ -181,6 +178,7 @@ open class SqlModel : BaseTenantModel(){
@Column(columnDefinition = "text")
var sql: String = ""
}
@Entity
open class JobModel : BaseTenantModel() {
@Index(unique = true)
@@ -216,6 +214,19 @@ open class DataModel : BaseTenantModel() {
}
@Entity
@Index(unique = true, name = "unique_session_id", columnNames = ["session_id"])
open class AnonSession : BaseTenantModel() {
var sessionId: String? = null
var ip: String? = null
var firstSeenAt: LocalDateTime? = null
var lastSeenAt: LocalDateTime? = null
@DbJsonB
var headerMap: Map<String, String> = hashMapOf()
}
class SafeStringDeserializer : JsonDeserializer<String>() {
private val regex = Regex("^[a-zA-Z0-9\\-_\\.]+$")