Fernando Sanchez (Perraco Labs)
@CreationTimestamp
@UpdateTimestamp
Berkay Özkan
EntityHook.subscribe { action -> val now = Instant.now().toEpochMilli() if (action.changeType == EntityChangeType.Updated) { action.toEntity(this)?.lastModifiedBy = Headers.USER_MAIL.getOrDefault() action.toEntity(this)?.lastModifiedDate = now } if (action.changeType == EntityChangeType.Created) { action.toEntity(this)?.lastModifiedBy = Headers.USER_MAIL.getOrDefault() action.toEntity(this)?.lastModifiedDate = now action.toEntity(this)?.createdBy = Headers.USER_MAIL.getOrDefault() action.toEntity(this)?.createdDate = now action.toEntity(this)?.deleted = false }
fun <T : BaseTable> T.update( where: (SqlExpressionBuilder.() -> Op<Boolean>)? = null, body: T.(UpdateStatement) -> Unit, ): Int { return this.update(where) { val now = Instant.now().toEpochMilli() val executorUser = Headers.USER_MAIL.getOrDefault() it[lastModifiedBy] = executorUser it[lastModifiedDate] = now body(it) } }
A modern programming language that makes developers happier.