feat(entities): actualized entities and added new
This commit is contained in:
+37
@@ -0,0 +1,37 @@
|
|||||||
|
package com.project.movienight.adapters.persistence.entity
|
||||||
|
|
||||||
|
import com.project.movienight.domain.model.FilmRating
|
||||||
|
import java.time.LocalDateTime
|
||||||
|
import java.util.UUID
|
||||||
|
|
||||||
|
data class FilmRatingEntity(
|
||||||
|
val id: UUID,
|
||||||
|
val userId: UUID,
|
||||||
|
val filmId: UUID,
|
||||||
|
val score: Int,
|
||||||
|
val note: String?,
|
||||||
|
val createdAt: LocalDateTime,
|
||||||
|
val updatedAt: LocalDateTime,
|
||||||
|
)
|
||||||
|
|
||||||
|
fun FilmRatingEntity.toDomain(): FilmRating =
|
||||||
|
FilmRating(
|
||||||
|
id = id,
|
||||||
|
userId = userId,
|
||||||
|
filmId = filmId,
|
||||||
|
score = score,
|
||||||
|
note = note,
|
||||||
|
createdAt = createdAt,
|
||||||
|
updatedAt = updatedAt,
|
||||||
|
)
|
||||||
|
|
||||||
|
fun FilmRating.toEntity(): FilmRatingEntity =
|
||||||
|
FilmRatingEntity(
|
||||||
|
id = id,
|
||||||
|
userId = userId,
|
||||||
|
filmId = filmId,
|
||||||
|
score = score,
|
||||||
|
note = note,
|
||||||
|
createdAt = createdAt,
|
||||||
|
updatedAt = updatedAt,
|
||||||
|
)
|
||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
package com.project.movienight.adapters.persistence.entity
|
||||||
|
|
||||||
|
import com.project.movienight.domain.model.JellyfinSyncState
|
||||||
|
import java.time.LocalDateTime
|
||||||
|
import java.util.UUID
|
||||||
|
|
||||||
|
data class JellyfinSyncStateEntity(
|
||||||
|
val userId: UUID,
|
||||||
|
val lastSyncedAt: LocalDateTime?,
|
||||||
|
val lastSuccessfulSyncAt: LocalDateTime?,
|
||||||
|
val lastError: String?,
|
||||||
|
val syncedItemCount: Int,
|
||||||
|
)
|
||||||
|
|
||||||
|
fun JellyfinSyncStateEntity.toDomain(): JellyfinSyncState =
|
||||||
|
JellyfinSyncState(
|
||||||
|
userId = userId,
|
||||||
|
lastSyncedAt = lastSyncedAt,
|
||||||
|
lastSuccessfulSyncAt = lastSuccessfulSyncAt,
|
||||||
|
lastError = lastError,
|
||||||
|
syncedItemCount = syncedItemCount,
|
||||||
|
)
|
||||||
|
|
||||||
|
fun JellyfinSyncState.toEntity(): JellyfinSyncStateEntity =
|
||||||
|
JellyfinSyncStateEntity(
|
||||||
|
userId = userId,
|
||||||
|
lastSyncedAt = lastSyncedAt,
|
||||||
|
lastSuccessfulSyncAt = lastSuccessfulSyncAt,
|
||||||
|
lastError = lastError,
|
||||||
|
syncedItemCount = syncedItemCount,
|
||||||
|
)
|
||||||
@@ -11,6 +11,7 @@ data class UserEntity(
|
|||||||
val email: String,
|
val email: String,
|
||||||
val provider: String?,
|
val provider: String?,
|
||||||
val providerId: String?,
|
val providerId: String?,
|
||||||
|
val jellyfinUserId: String?,
|
||||||
val createdAt: LocalDateTime,
|
val createdAt: LocalDateTime,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -20,6 +21,8 @@ fun UserEntity.toDomain(): User =
|
|||||||
name = name,
|
name = name,
|
||||||
email = email,
|
email = email,
|
||||||
library = null,
|
library = null,
|
||||||
|
preferences = null,
|
||||||
|
jellyfinUserId = jellyfinUserId,
|
||||||
)
|
)
|
||||||
|
|
||||||
fun User.toEntity(
|
fun User.toEntity(
|
||||||
@@ -33,5 +36,6 @@ fun User.toEntity(
|
|||||||
email = email,
|
email = email,
|
||||||
provider = provider?.name,
|
provider = provider?.name,
|
||||||
providerId = providerId,
|
providerId = providerId,
|
||||||
|
jellyfinUserId = jellyfinUserId,
|
||||||
createdAt = createdAt,
|
createdAt = createdAt,
|
||||||
)
|
)
|
||||||
|
|||||||
+41
@@ -0,0 +1,41 @@
|
|||||||
|
package com.project.movienight.adapters.persistence.entity
|
||||||
|
|
||||||
|
import com.project.movienight.adapters.persistence.jdbc.support.DelimitedValueCodec
|
||||||
|
import com.project.movienight.domain.model.ContentType
|
||||||
|
import com.project.movienight.domain.model.UserPreferences
|
||||||
|
import java.util.UUID
|
||||||
|
|
||||||
|
data class UserPreferencesEntity(
|
||||||
|
val userId: UUID,
|
||||||
|
val weightedGenres: String,
|
||||||
|
val plotTypes: String,
|
||||||
|
val eras: String,
|
||||||
|
val castAndDirectors: String,
|
||||||
|
val moods: String,
|
||||||
|
val contentTypes: String,
|
||||||
|
)
|
||||||
|
|
||||||
|
fun UserPreferencesEntity.toDomain(): UserPreferences =
|
||||||
|
UserPreferences(
|
||||||
|
userId = userId,
|
||||||
|
weightedGenres = DelimitedValueCodec.decodeWeightedMap(weightedGenres),
|
||||||
|
plotTypes = DelimitedValueCodec.decodeList(plotTypes),
|
||||||
|
eras = DelimitedValueCodec.decodeList(eras),
|
||||||
|
castAndDirectors = DelimitedValueCodec.decodeList(castAndDirectors),
|
||||||
|
moods = DelimitedValueCodec.decodeList(moods),
|
||||||
|
contentTypes =
|
||||||
|
DelimitedValueCodec.decodeList(contentTypes).mapNotNull { value ->
|
||||||
|
runCatching { ContentType.valueOf(value) }.getOrNull()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
fun UserPreferences.toEntity(): UserPreferencesEntity =
|
||||||
|
UserPreferencesEntity(
|
||||||
|
userId = userId,
|
||||||
|
weightedGenres = DelimitedValueCodec.encodeWeightedMap(weightedGenres),
|
||||||
|
plotTypes = DelimitedValueCodec.encodeList(plotTypes),
|
||||||
|
eras = DelimitedValueCodec.encodeList(eras),
|
||||||
|
castAndDirectors = DelimitedValueCodec.encodeList(castAndDirectors),
|
||||||
|
moods = DelimitedValueCodec.encodeList(moods),
|
||||||
|
contentTypes = DelimitedValueCodec.encodeList(contentTypes.map { it.name }),
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user