add integration with posts creating
This commit is contained in:
client
features/content
binary
common
src
commonMain
kotlin
dev
inmo
postssystem
features
content
server
src
jvmMain
kotlin
dev
inmo
postssystem
features
content
binary
common
src
commonMain
kotlin
dev
inmo
postssystem
features
content
common
server
services/posts
client
src
commonMain
kotlin
dev
inmo
postssystem
services
common
server
@ -2,7 +2,6 @@ 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.DefaultBinaryContent
|
||||
import dev.inmo.postssystem.features.content.common.*
|
||||
import dev.inmo.postssystem.features.content.server.storage.ServerContentStorage
|
||||
import dev.inmo.postssystem.features.files.common.*
|
||||
@ -12,7 +11,7 @@ import kotlinx.coroutines.flow.map
|
||||
|
||||
class BinaryServerContentStorage(
|
||||
private val filesStorage: FilesStorage
|
||||
) : ServerContentStorage<DefaultBinaryContent> {
|
||||
) : ServerContentStorage<BinaryContent> {
|
||||
private val FileId.asContentId
|
||||
get() = ContentId(string)
|
||||
private val ContentId.asFileId
|
||||
@ -20,13 +19,13 @@ class BinaryServerContentStorage(
|
||||
private val FullFileInfoStorageWrapper.asRegisteredContent
|
||||
get() = RegisteredContent(
|
||||
id.asContentId,
|
||||
DefaultBinaryContent(
|
||||
BinaryContent(
|
||||
fileInfo.name,
|
||||
fileInfo.mimeType,
|
||||
fileInfo.inputProvider
|
||||
)
|
||||
)
|
||||
private val DefaultBinaryContent.asFullFileInfo
|
||||
private val BinaryContent.asFullFileInfo
|
||||
get() = FullFileInfo(
|
||||
filename,
|
||||
mimeType,
|
||||
@ -36,7 +35,7 @@ class BinaryServerContentStorage(
|
||||
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<DefaultBinaryContent>): List<RegisteredContent> {
|
||||
override suspend fun create(values: List<BinaryContent>): List<RegisteredContent> {
|
||||
return filesStorage.create(
|
||||
values.map { it.asFullFileInfo }
|
||||
).map { it.asRegisteredContent }
|
||||
@ -46,14 +45,14 @@ class BinaryServerContentStorage(
|
||||
filesStorage.deleteById(ids.map { it.asFileId })
|
||||
}
|
||||
|
||||
override suspend fun update(id: ContentId, value: DefaultBinaryContent): RegisteredContent? {
|
||||
override suspend fun update(id: ContentId, value: BinaryContent): RegisteredContent? {
|
||||
return filesStorage.update(
|
||||
id.asFileId,
|
||||
value.asFullFileInfo
|
||||
) ?.asRegisteredContent
|
||||
}
|
||||
|
||||
override suspend fun update(values: List<UpdatedValuePair<ContentId, DefaultBinaryContent>>): List<RegisteredContent> {
|
||||
override suspend fun update(values: List<UpdatedValuePair<ContentId, BinaryContent>>): List<RegisteredContent> {
|
||||
return filesStorage.update(
|
||||
values.map { (id, content) ->
|
||||
id.asFileId to content.asFullFileInfo
|
||||
|
Reference in New Issue
Block a user