temporal result
This commit is contained in:
client/src/jsMain/kotlin/dev/inmo/postssystem/client/utils
features
common
common
content
binary
common
src
commonMain
kotlin
dev
inmo
postssystem
features
server
src
jvmMain
kotlin
dev
inmo
postssystem
features
content
binary
common
files
common
src
commonMain
kotlin
dev
inmo
postssystem
features
files
common
jvmMain
kotlin
dev
inmo
postssystem
features
gradle/wrapper
targets/telegram/publication/server/src/jvmMain/kotlin/dev/inmo/postssystem/targets/telegram/publication/server
@ -2,7 +2,7 @@ package dev.inmo.postssystem.features.content.binary.server
|
||||
|
||||
import dev.inmo.micro_utils.pagination.*
|
||||
import dev.inmo.micro_utils.repos.UpdatedValuePair
|
||||
import dev.inmo.postssystem.features.content.binary.common.BinaryContent
|
||||
import dev.inmo.postssystem.features.content.binary.common.DefaultBinaryContent
|
||||
import dev.inmo.postssystem.features.content.common.*
|
||||
import dev.inmo.postssystem.features.content.server.ServerContentStorage
|
||||
import dev.inmo.postssystem.features.files.common.*
|
||||
@ -12,7 +12,7 @@ import kotlinx.coroutines.flow.map
|
||||
|
||||
class BinaryServerContentStorage(
|
||||
private val filesStorage: FilesStorage
|
||||
) : ServerContentStorage<BinaryContent> {
|
||||
) : ServerContentStorage<DefaultBinaryContent> {
|
||||
private val FileId.asContentId
|
||||
get() = ContentId(string)
|
||||
private val ContentId.asFileId
|
||||
@ -20,23 +20,23 @@ class BinaryServerContentStorage(
|
||||
private val FullFileInfoStorageWrapper.asRegisteredContent
|
||||
get() = RegisteredContent(
|
||||
id.asContentId,
|
||||
BinaryContent(
|
||||
DefaultBinaryContent(
|
||||
fileInfo.name,
|
||||
fileInfo.mimeType,
|
||||
fileInfo.byteArrayAllocator
|
||||
fileInfo.inputProvider
|
||||
)
|
||||
)
|
||||
private val BinaryContent.asFullFileInfo
|
||||
private val DefaultBinaryContent.asFullFileInfo
|
||||
get() = FullFileInfo(
|
||||
filename,
|
||||
mimeType,
|
||||
bytesAllocator
|
||||
inputProvider
|
||||
)
|
||||
override val deletedObjectsIdsFlow: Flow<ContentId> = filesStorage.deletedObjectsIdsFlow.map { it.asContentId }
|
||||
override val newObjectsFlow: Flow<RegisteredContent> = filesStorage.newObjectsFlow.map { it.asRegisteredContent }
|
||||
override val updatedObjectsFlow: Flow<RegisteredContent> = filesStorage.updatedObjectsFlow.map { it.asRegisteredContent }
|
||||
|
||||
override suspend fun create(values: List<BinaryContent>): List<RegisteredContent> {
|
||||
override suspend fun create(values: List<DefaultBinaryContent>): List<RegisteredContent> {
|
||||
return filesStorage.create(
|
||||
values.map { it.asFullFileInfo }
|
||||
).map { it.asRegisteredContent }
|
||||
@ -46,14 +46,14 @@ class BinaryServerContentStorage(
|
||||
filesStorage.deleteById(ids.map { it.asFileId })
|
||||
}
|
||||
|
||||
override suspend fun update(id: ContentId, value: BinaryContent): RegisteredContent? {
|
||||
override suspend fun update(id: ContentId, value: DefaultBinaryContent): RegisteredContent? {
|
||||
return filesStorage.update(
|
||||
id.asFileId,
|
||||
value.asFullFileInfo
|
||||
) ?.asRegisteredContent
|
||||
}
|
||||
|
||||
override suspend fun update(values: List<UpdatedValuePair<ContentId, BinaryContent>>): List<RegisteredContent> {
|
||||
override suspend fun update(values: List<UpdatedValuePair<ContentId, DefaultBinaryContent>>): List<RegisteredContent> {
|
||||
return filesStorage.update(
|
||||
values.map { (id, content) ->
|
||||
id.asFileId to content.asFullFileInfo
|
||||
|
Reference in New Issue
Block a user