chore: remove deprecated horses, clubs, officials, and persons services
- Deleted obsolete modules related to horses, clubs, officials, and persons services, including their configurations, build files, and database provisioning scripts. - Cleaned up associated references in the project structure (e.g., `settings.gradle.kts`). - Removed unused database tables and Spring beans related to these domains. Signed-off-by: Stefan Mogeritsch <stefan.mo.co@gmail.com>
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
plugins {
|
||||
alias(libs.plugins.kotlinJvm)
|
||||
alias(libs.plugins.kotlinSerialization)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(projects.platform.platformDependencies)
|
||||
implementation(projects.core.coreDomain)
|
||||
|
||||
testImplementation(projects.platform.platformTesting)
|
||||
testImplementation(libs.mockk)
|
||||
testImplementation(libs.kotlin.test)
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
@file:OptIn(kotlin.uuid.ExperimentalUuidApi::class)
|
||||
|
||||
package at.mocode.identity.domain.model
|
||||
|
||||
import at.mocode.core.domain.serialization.InstantSerializer
|
||||
import at.mocode.core.domain.serialization.UuidSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlin.time.Clock
|
||||
import kotlin.time.Instant
|
||||
import kotlin.uuid.Uuid
|
||||
|
||||
/**
|
||||
* Domain model representing an extended profile of a user.
|
||||
* This links a Keycloak User ID with an official ZNS Satznummer.
|
||||
*
|
||||
* @property profileId Unique internal identifier.
|
||||
* @property userId The Keycloak User ID (UUID string).
|
||||
* @property satznummer The official ZNS Satznummer (link to master-data-context).
|
||||
* @property logoUrl Optional URL to a logo or profile picture.
|
||||
* @property bio Optional short biography or description.
|
||||
* @property contactEmail Optional contact email (might differ from account email).
|
||||
* @property createdAt Timestamp of creation.
|
||||
* @property updatedAt Timestamp of the last update.
|
||||
*/
|
||||
@Serializable
|
||||
data class DomProfil(
|
||||
@Serializable(with = UuidSerializer::class)
|
||||
val profileId: Uuid = Uuid.random(),
|
||||
|
||||
val userId: String,
|
||||
val satznummer: String,
|
||||
|
||||
val logoUrl: String? = null,
|
||||
val bio: String? = null,
|
||||
val contactEmail: String? = null,
|
||||
|
||||
@Serializable(with = InstantSerializer::class)
|
||||
val createdAt: Instant = Clock.System.now(),
|
||||
@Serializable(with = InstantSerializer::class)
|
||||
var updatedAt: Instant = Clock.System.now()
|
||||
)
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
@file:OptIn(kotlin.uuid.ExperimentalUuidApi::class)
|
||||
|
||||
package at.mocode.identity.domain.repository
|
||||
|
||||
import at.mocode.identity.domain.model.DomProfil
|
||||
import kotlin.uuid.Uuid
|
||||
|
||||
interface ProfileRepository {
|
||||
suspend fun findById(id: Uuid): DomProfil?
|
||||
suspend fun findByUserId(userId: String): DomProfil?
|
||||
suspend fun findBySatznummer(satznummer: String): List<DomProfil>
|
||||
suspend fun save(profil: DomProfil): DomProfil
|
||||
suspend fun delete(id: Uuid): Boolean
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
@file:OptIn(kotlin.uuid.ExperimentalUuidApi::class)
|
||||
|
||||
package at.mocode.identity.domain.service
|
||||
|
||||
import at.mocode.identity.domain.model.DomProfil
|
||||
import at.mocode.identity.domain.repository.ProfileRepository
|
||||
import kotlin.uuid.Uuid
|
||||
|
||||
/**
|
||||
* Domain service for managing user profiles and ZNS links.
|
||||
*/
|
||||
class ProfileService(
|
||||
private val profileRepository: ProfileRepository
|
||||
) {
|
||||
suspend fun getProfileByUserId(userId: String): DomProfil? {
|
||||
return profileRepository.findByUserId(userId)
|
||||
}
|
||||
|
||||
suspend fun linkUserToZns(userId: String, satznummer: String): DomProfil {
|
||||
val existing = profileRepository.findByUserId(userId)
|
||||
val profil = if (existing != null) {
|
||||
existing.copy(satznummer = satznummer)
|
||||
} else {
|
||||
DomProfil(userId = userId, satznummer = satznummer)
|
||||
}
|
||||
return profileRepository.save(profil)
|
||||
}
|
||||
|
||||
suspend fun updateProfile(userId: String, logoUrl: String?, bio: String?, contactEmail: String?): DomProfil {
|
||||
val profil = profileRepository.findByUserId(userId)
|
||||
?: throw IllegalStateException("Profile for user $userId not found. Link to ZNS first.")
|
||||
|
||||
val updated = profil.copy(
|
||||
logoUrl = logoUrl ?: profil.logoUrl,
|
||||
bio = bio ?: profil.bio,
|
||||
contactEmail = contactEmail ?: profil.contactEmail
|
||||
)
|
||||
return profileRepository.save(updated)
|
||||
}
|
||||
|
||||
suspend fun deleteProfile(profileId: Uuid): Boolean {
|
||||
return profileRepository.delete(profileId)
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
@file:OptIn(kotlin.uuid.ExperimentalUuidApi::class)
|
||||
|
||||
package at.mocode.identity.domain.service
|
||||
|
||||
import at.mocode.identity.domain.model.DomProfil
|
||||
import at.mocode.identity.domain.repository.ProfileRepository
|
||||
import io.mockk.coEvery
|
||||
import io.mockk.coVerify
|
||||
import io.mockk.mockk
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertNotNull
|
||||
|
||||
class ProfileServiceTest {
|
||||
|
||||
private val profileRepository = mockk<ProfileRepository>()
|
||||
private val profileService = ProfileService(profileRepository)
|
||||
|
||||
@Test
|
||||
fun `linkUserToZns should create new profile if none exists`() = runBlocking {
|
||||
val userId = "user-123"
|
||||
val satznummer = "0000123456"
|
||||
|
||||
coEvery { profileRepository.findByUserId(userId) } returns null
|
||||
coEvery { profileRepository.save(any()) } answers { it.invocation.args[0] as DomProfil }
|
||||
|
||||
val result = profileService.linkUserToZns(userId, satznummer)
|
||||
|
||||
assertNotNull(result)
|
||||
assertEquals(userId, result.userId)
|
||||
assertEquals(satznummer, result.satznummer)
|
||||
coVerify { profileRepository.save(match { it.userId == userId && it.satznummer == satznummer }) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `linkUserToZns should update existing profile`() = runBlocking {
|
||||
val userId = "user-123"
|
||||
val oldSatz = "old-123"
|
||||
val newSatz = "new-456"
|
||||
val existing = DomProfil(userId = userId, satznummer = oldSatz)
|
||||
|
||||
coEvery { profileRepository.findByUserId(userId) } returns existing
|
||||
coEvery { profileRepository.save(any()) } answers { it.invocation.args[0] as DomProfil }
|
||||
|
||||
val result = profileService.linkUserToZns(userId, newSatz)
|
||||
|
||||
assertEquals(newSatz, result.satznummer)
|
||||
coVerify { profileRepository.save(match { it.userId == userId && it.satznummer == newSatz }) }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user