more optional validations
This commit is contained in:
@@ -47,6 +47,7 @@ object Session {
|
||||
|
||||
fun currentUser() = currentUser.get().userName
|
||||
fun currentTenant() = currentUser.get().tenant
|
||||
fun currentRoles() = currentUser.get().roles
|
||||
|
||||
fun Database.findByEntityAndId(entity: String, id: String): DataModel {
|
||||
return find(DataModel::class.java)
|
||||
|
||||
@@ -20,6 +20,10 @@ import javax.persistence.*
|
||||
|
||||
data class Comments(val text: String = "", val by: String = "", val at: LocalDateTime = LocalDateTime.now())
|
||||
|
||||
enum class ApprovalStatus {
|
||||
PENDING, APPROVED, REJECTED
|
||||
}
|
||||
|
||||
@MappedSuperclass
|
||||
abstract class BaseModel : Model() {
|
||||
@Id
|
||||
@@ -51,6 +55,13 @@ abstract class BaseModel : Model() {
|
||||
|
||||
var deletedBy: String? = null
|
||||
|
||||
var currentApprovalLevel: Int = 0
|
||||
|
||||
var requiredApprovalLevels: Int = 0
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
var approvalStatus: ApprovalStatus = ApprovalStatus.PENDING
|
||||
|
||||
@DbArray
|
||||
var tags: MutableList<String> = arrayListOf()
|
||||
|
||||
@@ -70,11 +81,15 @@ open class TenantModel : BaseModel() {
|
||||
}
|
||||
|
||||
enum class AuditType {
|
||||
CREATE, UPDATE, DELETE, VIEW
|
||||
CREATE, UPDATE, DELETE, VIEW, APPROVE, REJECT
|
||||
}
|
||||
|
||||
@Entity
|
||||
@Index(columnNames = ["audit_type", "entity", "unique_identifier", "tenant_id", "created_by"])
|
||||
open class AuditLog : BaseModel() {
|
||||
@Enumerated(EnumType.STRING)
|
||||
var auditType: AuditType = AuditType.CREATE
|
||||
|
||||
var entity: String = ""
|
||||
var uniqueIdentifier: String = ""
|
||||
|
||||
@@ -108,6 +123,10 @@ open class EntityModel : BaseModel() {
|
||||
@DbArray
|
||||
var allowedFields: List<String> = emptyList()
|
||||
|
||||
//enforce field types, if this is present, only fields that are present is validated
|
||||
@DbJsonB
|
||||
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
|
||||
var auditLogFields: List<String> = emptyList()
|
||||
@@ -116,7 +135,7 @@ open class EntityModel : BaseModel() {
|
||||
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
|
||||
//a user needs to have ROLE_ENTITY_APPROVE_LEVEL1, ROLE_ENTITY_APPROVE_LEVEL2 roles for further approvals
|
||||
var approvalLevels: Int = 0
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user