55 lines
1.4 KiB
Kotlin
55 lines
1.4 KiB
Kotlin
package dev.inmo.postssystem.features.content.common
|
|
|
|
import dev.inmo.micro_utils.common.*
|
|
import dev.inmo.micro_utils.mime_types.MimeType
|
|
import dev.inmo.postssystem.features.common.common.SimpleInputProvider
|
|
import kotlinx.serialization.PolymorphicSerializer
|
|
import kotlinx.serialization.Serializable
|
|
import kotlin.jvm.JvmInline
|
|
|
|
@Serializable
|
|
@JvmInline
|
|
value class ContentId(val string: String)
|
|
|
|
/**
|
|
* Content which is planned to be registered in database
|
|
*
|
|
* @see ContentSerializersModuleConfigurator.Element
|
|
* @see ContentSerializersModuleConfigurator
|
|
*/
|
|
interface Content
|
|
|
|
/**
|
|
* This type represents some binary data which can be sent with multipart and deserialized from it
|
|
*/
|
|
data class BinaryContent(
|
|
val filename: FileName,
|
|
val mimeType: MimeType,
|
|
val inputProvider: SimpleInputProvider
|
|
) : Content
|
|
|
|
val ContentSerializer = PolymorphicSerializer(Content::class)
|
|
@Serializable
|
|
data class ContentWrapper(
|
|
val content: Content
|
|
)
|
|
@Serializable
|
|
data class ContentsWrapper(
|
|
val content: List<Content>
|
|
)
|
|
@Serializable
|
|
data class ContentsEithersWrapper(
|
|
val content: List<Either<ContentId, Content>>
|
|
)
|
|
|
|
/**
|
|
* Content which is already registered in database. Using its [id] you can retrieve all known
|
|
* [dev.inmo.postssystem.core.post.RegisteredPost]s by using
|
|
* [dev.inmo.postssystem.core.post.repo.ReadPostsRepo.getPostsByContent]
|
|
*/
|
|
@Serializable
|
|
data class RegisteredContent(
|
|
val id: ContentId,
|
|
val content: Content
|
|
)
|