Refactor domain models and repositories: align imports, improve formatting consistency, remove unused imports, and harmonize implementation for better ZNS import compatibility.
This commit is contained in:
+9
-9
@@ -2,8 +2,8 @@
|
||||
|
||||
package at.mocode.masterdata.domain.model
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import at.mocode.core.domain.serialization.UuidSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlin.uuid.Uuid
|
||||
|
||||
/**
|
||||
@@ -11,12 +11,12 @@ import kotlin.uuid.Uuid
|
||||
*/
|
||||
@Serializable
|
||||
data class BewerbsKlasse(
|
||||
@Serializable(with = UuidSerializer::class)
|
||||
val bewerbsklasseId: Uuid = Uuid.random(),
|
||||
val sparte: String,
|
||||
val code: String,
|
||||
val bezeichnung: String,
|
||||
val maxHoehe: Int? = null,
|
||||
val aufgabenNiveau: String? = null,
|
||||
val istAktiv: Boolean = true
|
||||
@Serializable(with = UuidSerializer::class)
|
||||
val bewerbsklasseId: Uuid = Uuid.random(),
|
||||
val sparte: String,
|
||||
val code: String,
|
||||
val bezeichnung: String,
|
||||
val maxHoehe: Int? = null,
|
||||
val aufgabenNiveau: String? = null,
|
||||
val istAktiv: Boolean = true
|
||||
)
|
||||
|
||||
+7
-9
@@ -2,18 +2,16 @@
|
||||
|
||||
package at.mocode.masterdata.domain.model
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import at.mocode.core.domain.serialization.UuidSerializer
|
||||
import at.mocode.core.domain.serialization.LocalDateSerializer
|
||||
import kotlinx.datetime.LocalDate
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlin.uuid.Uuid
|
||||
|
||||
@Serializable
|
||||
data class ReitLizenz(
|
||||
@Serializable(with = UuidSerializer::class)
|
||||
val lizenzId: Uuid = Uuid.random(),
|
||||
val code: String,
|
||||
val bezeichnung: String,
|
||||
val sparte: String? = null,
|
||||
val istAktiv: Boolean = true
|
||||
@Serializable(with = UuidSerializer::class)
|
||||
val lizenzId: Uuid = Uuid.random(),
|
||||
val code: String,
|
||||
val bezeichnung: String,
|
||||
val sparte: String? = null,
|
||||
val istAktiv: Boolean = true
|
||||
)
|
||||
|
||||
+1
-1
@@ -221,7 +221,7 @@ data class Reiter(
|
||||
// Validation against bundeslandNummer if available
|
||||
// ZNS bundeslandNummer is 01-09, while membership first digit is 1-9
|
||||
if (bundeslandNummer != null && b != bundeslandNummer) {
|
||||
return false
|
||||
return false
|
||||
}
|
||||
|
||||
// Verein part (2nd-4th digit)
|
||||
|
||||
+7
-7
@@ -2,8 +2,8 @@
|
||||
|
||||
package at.mocode.masterdata.domain.model
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import at.mocode.core.domain.serialization.UuidSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlin.uuid.Uuid
|
||||
|
||||
/**
|
||||
@@ -11,10 +11,10 @@ import kotlin.uuid.Uuid
|
||||
*/
|
||||
@Serializable
|
||||
data class TurnierKategorie(
|
||||
@Serializable(with = UuidSerializer::class)
|
||||
val kategorieId: Uuid = Uuid.random(),
|
||||
val code: String,
|
||||
val bezeichnung: String,
|
||||
val sparte: String? = null,
|
||||
val istAktiv: Boolean = true
|
||||
@Serializable(with = UuidSerializer::class)
|
||||
val kategorieId: Uuid = Uuid.random(),
|
||||
val code: String,
|
||||
val bezeichnung: String,
|
||||
val sparte: String? = null,
|
||||
val istAktiv: Boolean = true
|
||||
)
|
||||
|
||||
+9
-9
@@ -2,8 +2,8 @@
|
||||
|
||||
package at.mocode.masterdata.domain.model
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import at.mocode.core.domain.serialization.UuidSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlin.uuid.Uuid
|
||||
|
||||
/**
|
||||
@@ -11,12 +11,12 @@ import kotlin.uuid.Uuid
|
||||
*/
|
||||
@Serializable
|
||||
data class TurnierKlasse(
|
||||
@Serializable(with = UuidSerializer::class)
|
||||
val turnierklasseId: Uuid = Uuid.random(),
|
||||
val sparte: String,
|
||||
val code: String,
|
||||
val bezeichnung: String,
|
||||
val maxHoehe: Int? = null,
|
||||
val aufgabenNiveau: String? = null,
|
||||
val istAktiv: Boolean = true
|
||||
@Serializable(with = UuidSerializer::class)
|
||||
val turnierklasseId: Uuid = Uuid.random(),
|
||||
val sparte: String,
|
||||
val code: String,
|
||||
val bezeichnung: String,
|
||||
val maxHoehe: Int? = null,
|
||||
val aufgabenNiveau: String? = null,
|
||||
val istAktiv: Boolean = true
|
||||
)
|
||||
|
||||
+6
-6
@@ -2,8 +2,8 @@
|
||||
|
||||
package at.mocode.masterdata.domain.model
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import at.mocode.core.domain.serialization.UuidSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlin.uuid.Uuid
|
||||
|
||||
/**
|
||||
@@ -11,9 +11,9 @@ import kotlin.uuid.Uuid
|
||||
*/
|
||||
@Serializable
|
||||
data class TurnierSparte(
|
||||
@Serializable(with = UuidSerializer::class)
|
||||
val sparteId: Uuid = Uuid.random(),
|
||||
val code: String,
|
||||
val bezeichnung: String,
|
||||
val istAktiv: Boolean = true
|
||||
@Serializable(with = UuidSerializer::class)
|
||||
val sparteId: Uuid = Uuid.random(),
|
||||
val code: String,
|
||||
val bezeichnung: String,
|
||||
val istAktiv: Boolean = true
|
||||
)
|
||||
|
||||
+3
-3
@@ -10,7 +10,7 @@ import at.mocode.masterdata.domain.model.Startkarte
|
||||
* Repository für alle Lizenz-Stammdaten (Reit, Fahr, Startkarten).
|
||||
*/
|
||||
interface MasterdataLicenseRepository {
|
||||
suspend fun findReitLizenzByCode(code: String): at.mocode.masterdata.domain.model.ReitLizenz?
|
||||
suspend fun findFahrLizenzByCode(code: String): at.mocode.masterdata.domain.model.FahrLizenz?
|
||||
suspend fun findStartkarteByCode(code: String): at.mocode.masterdata.domain.model.Startkarte?
|
||||
suspend fun findReitLizenzByCode(code: String): ReitLizenz?
|
||||
suspend fun findFahrLizenzByCode(code: String): FahrLizenz?
|
||||
suspend fun findStartkarteByCode(code: String): Startkarte?
|
||||
}
|
||||
|
||||
+39
-32
@@ -16,38 +16,45 @@ import kotlin.uuid.Uuid
|
||||
* Hinweis: Implementiert nur die für den ZNS-Import notwendigen Methoden.
|
||||
*/
|
||||
class BundeslandExposedRepository : BundeslandRepository {
|
||||
private fun rowToDom(row: ResultRow) = BundeslandDefinition(
|
||||
bundeslandId = row[BundeslaenderTable.id],
|
||||
landId = row[BundeslaenderTable.landId],
|
||||
bundeslandNr = row[BundeslaenderTable.bundeslandNr],
|
||||
oepsCode = row[BundeslaenderTable.oepsCode],
|
||||
iso3166_2_Code = row[BundeslaenderTable.iso3166_2_Code],
|
||||
name = row[BundeslaenderTable.name],
|
||||
kuerzel = row[BundeslaenderTable.kuerzel],
|
||||
wappenUrl = row[BundeslaenderTable.wappenUrl],
|
||||
istAktiv = row[BundeslaenderTable.istAktiv],
|
||||
sortierReihenfolge = row[BundeslaenderTable.sortierReihenfolge],
|
||||
createdAt = row[BundeslaenderTable.createdAt],
|
||||
updatedAt = row[BundeslaenderTable.updatedAt]
|
||||
)
|
||||
private fun rowToDom(row: ResultRow) = BundeslandDefinition(
|
||||
bundeslandId = row[BundeslaenderTable.id],
|
||||
landId = row[BundeslaenderTable.landId],
|
||||
bundeslandNr = row[BundeslaenderTable.bundeslandNr],
|
||||
oepsCode = row[BundeslaenderTable.oepsCode],
|
||||
iso3166_2_Code = row[BundeslaenderTable.iso3166_2_Code],
|
||||
name = row[BundeslaenderTable.name],
|
||||
kuerzel = row[BundeslaenderTable.kuerzel],
|
||||
wappenUrl = row[BundeslaenderTable.wappenUrl],
|
||||
istAktiv = row[BundeslaenderTable.istAktiv],
|
||||
sortierReihenfolge = row[BundeslaenderTable.sortierReihenfolge],
|
||||
createdAt = row[BundeslaenderTable.createdAt],
|
||||
updatedAt = row[BundeslaenderTable.updatedAt]
|
||||
)
|
||||
|
||||
override suspend fun findByNr(nr: Int): BundeslandDefinition? = DatabaseFactory.dbQuery {
|
||||
BundeslaenderTable.selectAll().where { BundeslaenderTable.bundeslandNr eq nr }
|
||||
.map(::rowToDom)
|
||||
.singleOrNull()
|
||||
}
|
||||
override suspend fun findByNr(nr: Int): BundeslandDefinition? = DatabaseFactory.dbQuery {
|
||||
BundeslaenderTable.selectAll().where { BundeslaenderTable.bundeslandNr eq nr }
|
||||
.map(::rowToDom)
|
||||
.singleOrNull()
|
||||
}
|
||||
|
||||
// Dummy-Implementierungen für das Interface, da derzeit nicht vom ZNS-Import benötigt
|
||||
override suspend fun findById(id: Uuid): BundeslandDefinition? = null
|
||||
override suspend fun findByOepsCode(oepsCode: String, landId: Uuid): BundeslandDefinition? = null
|
||||
override suspend fun findByIso3166_2_Code(iso3166_2_Code: String): BundeslandDefinition? = null
|
||||
override suspend fun findByCountry(landId: Uuid, activeOnly: Boolean, orderBySortierung: Boolean): List<BundeslandDefinition> = emptyList()
|
||||
override suspend fun findByName(searchTerm: String, landId: Uuid?, limit: Int): List<BundeslandDefinition> = emptyList()
|
||||
override suspend fun findAllActive(orderBySortierung: Boolean): List<BundeslandDefinition> = emptyList()
|
||||
override suspend fun save(bundesland: BundeslandDefinition): BundeslandDefinition = bundesland
|
||||
override suspend fun upsertByLandIdAndKuerzel(bundesland: BundeslandDefinition): BundeslandDefinition = bundesland
|
||||
override suspend fun delete(id: Uuid): Boolean = false
|
||||
override suspend fun existsByOepsCode(oepsCode: String, landId: Uuid): Boolean = false
|
||||
override suspend fun existsByIso3166_2_Code(iso3166_2_Code: String): Boolean = false
|
||||
override suspend fun countActiveByCountry(landId: Uuid): Long = 0L
|
||||
// Dummy-Implementierungen für das Interface, da derzeit nicht vom ZNS-Import benötigt
|
||||
override suspend fun findById(id: Uuid): BundeslandDefinition? = null
|
||||
override suspend fun findByOepsCode(oepsCode: String, landId: Uuid): BundeslandDefinition? = null
|
||||
override suspend fun findByIso3166_2_Code(iso3166_2_Code: String): BundeslandDefinition? = null
|
||||
override suspend fun findByCountry(
|
||||
landId: Uuid,
|
||||
activeOnly: Boolean,
|
||||
orderBySortierung: Boolean
|
||||
): List<BundeslandDefinition> = emptyList()
|
||||
|
||||
override suspend fun findByName(searchTerm: String, landId: Uuid?, limit: Int): List<BundeslandDefinition> =
|
||||
emptyList()
|
||||
|
||||
override suspend fun findAllActive(orderBySortierung: Boolean): List<BundeslandDefinition> = emptyList()
|
||||
override suspend fun save(bundesland: BundeslandDefinition): BundeslandDefinition = bundesland
|
||||
override suspend fun upsertByLandIdAndKuerzel(bundesland: BundeslandDefinition): BundeslandDefinition = bundesland
|
||||
override suspend fun delete(id: Uuid): Boolean = false
|
||||
override suspend fun existsByOepsCode(oepsCode: String, landId: Uuid): Boolean = false
|
||||
override suspend fun existsByIso3166_2_Code(iso3166_2_Code: String): Boolean = false
|
||||
override suspend fun countActiveByCountry(landId: Uuid): Long = 0L
|
||||
}
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ class ReiterExposedRepository : ReiterRepository {
|
||||
private fun loadLizenzen(reiterId: Uuid): List<ReiterLizenz> {
|
||||
return ReiterLizenzenZuordnungTable.selectAll().where { ReiterLizenzenZuordnungTable.reiterId eq reiterId }
|
||||
.map {
|
||||
at.mocode.masterdata.domain.model.ReiterLizenz(
|
||||
ReiterLizenz(
|
||||
lizenzId = it[ReiterLizenzenZuordnungTable.id],
|
||||
lizenzTyp = it[ReiterLizenzenZuordnungTable.lizenzTyp],
|
||||
kuerzel = it[ReiterLizenzenZuordnungTable.kuerzel],
|
||||
|
||||
-1
@@ -2,7 +2,6 @@
|
||||
|
||||
package at.mocode.masterdata.infrastructure.persistence.reiter
|
||||
|
||||
import at.mocode.masterdata.infrastructure.persistence.BundeslaenderTable
|
||||
import org.jetbrains.exposed.v1.core.Table
|
||||
import org.jetbrains.exposed.v1.datetime.CurrentTimestamp
|
||||
import org.jetbrains.exposed.v1.datetime.date
|
||||
|
||||
+31
-30
@@ -1,12 +1,13 @@
|
||||
@file:OptIn(kotlin.uuid.ExperimentalUuidApi::class)
|
||||
|
||||
package at.mocode.masterdata.service.config
|
||||
|
||||
import at.mocode.masterdata.infrastructure.persistence.AltersklasseTable
|
||||
import jakarta.annotation.PostConstruct
|
||||
import org.jetbrains.exposed.v1.jdbc.transactions.transaction
|
||||
import org.jetbrains.exposed.v1.core.eq
|
||||
import org.jetbrains.exposed.v1.jdbc.insert
|
||||
import org.jetbrains.exposed.v1.jdbc.selectAll
|
||||
import org.jetbrains.exposed.v1.core.*
|
||||
import org.jetbrains.exposed.v1.jdbc.transactions.transaction
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.context.annotation.Configuration
|
||||
import org.springframework.context.annotation.DependsOn
|
||||
@@ -20,38 +21,38 @@ import kotlin.uuid.Uuid
|
||||
@Profile("!test")
|
||||
@DependsOn("masterdataDatabaseConfiguration")
|
||||
class AltersklassenSeeder {
|
||||
private val log = LoggerFactory.getLogger(AltersklassenSeeder::class.java)
|
||||
private val log = LoggerFactory.getLogger(AltersklassenSeeder::class.java)
|
||||
|
||||
@PostConstruct
|
||||
fun seed() {
|
||||
log.info("Starte Seeding der Altersklassen...")
|
||||
transaction {
|
||||
val klassen = listOf(
|
||||
Triple("JG", "JUGENDLICHER", "Altersklasse Jugend"),
|
||||
Triple("JR", "JUNIOR", "Altersklasse Junior"),
|
||||
Triple("25", "U25", "Altersklasse U25"),
|
||||
Triple("Y", "JUNGER-REITER", "Altersklasse Junger Reiter")
|
||||
)
|
||||
@PostConstruct
|
||||
fun seed() {
|
||||
log.info("Starte Seeding der Altersklassen...")
|
||||
transaction {
|
||||
val klassen = listOf(
|
||||
Triple("JG", "JUGENDLICHER", "Altersklasse Jugend"),
|
||||
Triple("JR", "JUNIOR", "Altersklasse Junior"),
|
||||
Triple("25", "U25", "Altersklasse U25"),
|
||||
Triple("Y", "JUNGER-REITER", "Altersklasse Junger Reiter")
|
||||
)
|
||||
|
||||
klassen.forEach { (code, bez, desc) ->
|
||||
upsertAltersklasse(code, bez)
|
||||
}
|
||||
}
|
||||
klassen.forEach { (code, bez, desc) ->
|
||||
upsertAltersklasse(code, bez)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun upsertAltersklasse(code: String, bezeichnung: String) {
|
||||
val exists = AltersklasseTable.selectAll()
|
||||
.where { AltersklasseTable.altersklasseCode eq code }
|
||||
.any()
|
||||
private fun upsertAltersklasse(code: String, bezeichnung: String) {
|
||||
val exists = AltersklasseTable.selectAll()
|
||||
.where { AltersklasseTable.altersklasseCode eq code }
|
||||
.any()
|
||||
|
||||
if (!exists) {
|
||||
AltersklasseTable.insert {
|
||||
it[id] = Uuid.random()
|
||||
it[altersklasseCode] = code
|
||||
it[AltersklasseTable.bezeichnung] = bezeichnung
|
||||
it[istAktiv] = true
|
||||
}
|
||||
log.debug("Altersklasse '{}' angelegt.", code)
|
||||
}
|
||||
if (!exists) {
|
||||
AltersklasseTable.insert {
|
||||
it[id] = Uuid.random()
|
||||
it[altersklasseCode] = code
|
||||
it[AltersklasseTable.bezeichnung] = bezeichnung
|
||||
it[istAktiv] = true
|
||||
}
|
||||
log.debug("Altersklasse '{}' angelegt.", code)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user