Update to version 2.2.0-alpha-2 and add database query provider

Bumped project version to `2.2.0-alpha-2` in `build.gradle.kts`. Introduced `SampleEntity`, `SamplePartEntity`, and `SampleEntityQueryProvider` for database handling. Added `SampleDao` with a sample query function. Updated SVG utilities with a `viewbox` extension and enhanced `RequestHandler` to set content type for HTML responses.
This commit is contained in:
2025-06-09 14:06:17 +02:00
parent c1f756eb79
commit 2871697329
6 changed files with 116 additions and 1 deletions

View File

@@ -0,0 +1,50 @@
package nl.astraeus.vst.chip.db
import kotlinx.datetime.Clock
import kotlinx.datetime.Instant
import nl.astraeus.vst.base.db.Entity
data class SampleEntity(
var sha1Hash: String,
var filename: String,
var length: Int,
var created: Instant = Clock.System.now(),
var updated: Instant = Clock.System.now(),
) : Entity {
override fun getPK(): Array<Any> = arrayOf(sha1Hash)
override fun setPK(pks: Array<Any>) {
sha1Hash = pks[0] as String
}
}
data class SamplePartEntity(
var sha1Hash: String,
var part: Int,
var from: Int,
var to: Int,
var data: ByteArray,
) : Entity {
override fun getPK(): Array<Any> = arrayOf(sha1Hash, part)
override fun setPK(pks: Array<Any>) {
sha1Hash = pks[0] as String
part = pks[1] as Int
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is SamplePartEntity) return false
if (sha1Hash != other.sha1Hash) return false
if (part != other.part) return false
return true
}
override fun hashCode(): Int {
var result = sha1Hash.hashCode()
result = 31 * result + part
return result
}
}