tighten the api
This commit is contained in:
@@ -32,6 +32,9 @@ object Session {
|
||||
setProperty("datasource.db.password", appConfig.dbPass())
|
||||
setProperty("datasource.db.url", appConfig.dbUrl())
|
||||
setProperty("ebean.migration.run", appConfig.dbRunMigration().toString())
|
||||
if(appConfig.seedSqlFile().isPresent){
|
||||
setProperty("ebean.ddl.seedSql", appConfig.seedSqlFile().get())
|
||||
}
|
||||
})
|
||||
tenantMode = TenantMode.PARTITION
|
||||
currentTenantProvider = CurrentTenantProvider { currentUser.get().tenant }
|
||||
|
||||
@@ -6,6 +6,7 @@ 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.Index
|
||||
import io.ebean.annotation.Platform
|
||||
@@ -31,19 +32,22 @@ abstract class BaseModel : Model() {
|
||||
var sysPk: Long = 0
|
||||
|
||||
@SoftDelete
|
||||
@DbDefault("false")
|
||||
var deleted: Boolean = false
|
||||
|
||||
@Version
|
||||
@DbDefault("1")
|
||||
var version: Int = 0
|
||||
|
||||
@WhenCreated
|
||||
@DbDefault("now()")
|
||||
var createdAt: LocalDateTime = LocalDateTime.now()
|
||||
|
||||
@WhenModified
|
||||
@DbDefault("now()")
|
||||
var modifiedAt: LocalDateTime? = null
|
||||
|
||||
@TenantId
|
||||
var tenantId: String = ""
|
||||
|
||||
|
||||
@WhoCreated
|
||||
var createdBy: String = ""
|
||||
@@ -55,22 +59,34 @@ abstract class BaseModel : Model() {
|
||||
|
||||
var deletedBy: String? = null
|
||||
|
||||
@DbDefault("0")
|
||||
var currentApprovalLevel: Int = 0
|
||||
|
||||
@DbDefault("0")
|
||||
var requiredApprovalLevels: Int = 0
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
var approvalStatus: ApprovalStatus = ApprovalStatus.PENDING
|
||||
@DbDefault("APPROVED")
|
||||
var approvalStatus: ApprovalStatus = ApprovalStatus.APPROVED
|
||||
|
||||
@DbArray
|
||||
@DbDefault("{}")
|
||||
var tags: MutableList<String> = arrayListOf()
|
||||
|
||||
@DbJsonB
|
||||
@DbDefault("[]")
|
||||
var comments: MutableList<Comments> = arrayListOf()
|
||||
}
|
||||
|
||||
|
||||
@MappedSuperclass
|
||||
abstract class BaseTenantModel : BaseModel() {
|
||||
@TenantId
|
||||
var tenantId: String = ""
|
||||
}
|
||||
|
||||
@Entity
|
||||
open class TenantModel : BaseModel() {
|
||||
@Index(unique = true)
|
||||
var name: String = ""
|
||||
var domain: String = ""
|
||||
var mobile: List<String> = emptyList()
|
||||
@@ -86,7 +102,7 @@ enum class AuditType {
|
||||
|
||||
@Entity
|
||||
@Index(columnNames = ["audit_type", "entity", "unique_identifier", "tenant_id", "created_by"])
|
||||
open class AuditLog : BaseModel() {
|
||||
open class AuditLog : BaseTenantModel() {
|
||||
@Enumerated(EnumType.STRING)
|
||||
var auditType: AuditType = AuditType.CREATE
|
||||
|
||||
@@ -94,48 +110,54 @@ open class AuditLog : BaseModel() {
|
||||
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()
|
||||
}
|
||||
|
||||
@Entity
|
||||
open class EntityModel : BaseModel() {
|
||||
open class EntityModel : BaseTenantModel() {
|
||||
@Index(unique = true)
|
||||
@JsonDeserialize(using = SafeStringDeserializer::class)
|
||||
var name: String = ""
|
||||
|
||||
//a kts script that will return true/false along with errors before saving
|
||||
var preSaveScript: String = ""
|
||||
var preSaveScript: String? = ""
|
||||
|
||||
//a kts script that will do something ... returns void
|
||||
var postSaveScript: String = ""
|
||||
var postSaveScript: String? = ""
|
||||
|
||||
//this will create extra actions/roles in keycloak
|
||||
//the default actions are create, update, view, delete
|
||||
@DbArray
|
||||
@DbDefault("{}")
|
||||
var actions: List<String> = emptyList()
|
||||
|
||||
//allow only these fields, if this is empty, then all fields are allowed
|
||||
@DbArray
|
||||
@DbDefault("{}")
|
||||
var allowedFields: List<String> = emptyList()
|
||||
|
||||
//enforce field types, if this is present, only fields that are present is validated
|
||||
@DbJsonB
|
||||
@DbDefault("{}")
|
||||
var allowedFieldTypes: Map<String, String> = hashMapOf()
|
||||
|
||||
//when an entity is saved/updated audit logs will be populated, when this is empty, all fields are logged
|
||||
@DbArray
|
||||
@DbDefault("{}")
|
||||
var auditLogFields: List<String> = emptyList()
|
||||
|
||||
@DbJsonB
|
||||
@DbDefault("{}")
|
||||
var preferences: MutableMap<String, Any> = hashMapOf()
|
||||
|
||||
//if '0' then its auto saved, no approval steps are required, for further steps,
|
||||
//a user needs to have ROLE_ENTITY_APPROVE_LEVEL1, ROLE_ENTITY_APPROVE_LEVEL2 roles for further approvals
|
||||
@DbDefault("0")
|
||||
var approvalLevels: Int = 0
|
||||
}
|
||||
|
||||
@@ -148,7 +170,7 @@ enum class JobType {
|
||||
}
|
||||
|
||||
@Entity
|
||||
open class JobModel : BaseModel() {
|
||||
open class JobModel : BaseTenantModel() {
|
||||
@Index(unique = true)
|
||||
var jobName: String = ""
|
||||
|
||||
@@ -168,7 +190,7 @@ open class JobModel : BaseModel() {
|
||||
|
||||
@Entity
|
||||
@Index(unique = true, name = "entity_unique_id", columnNames = ["entity_name", "unique_identifier", "tenant_id"])
|
||||
open class DataModel : BaseModel() {
|
||||
open class DataModel : BaseTenantModel() {
|
||||
|
||||
@JsonDeserialize(using = SafeStringDeserializer::class)
|
||||
var uniqueIdentifier: String = ""
|
||||
|
||||
Reference in New Issue
Block a user