add post preview

This commit is contained in:
2021-12-05 19:00:38 +06:00
parent 61496069b7
commit 571f5781d2
11 changed files with 132 additions and 12 deletions

View File

@@ -0,0 +1,47 @@
package dev.inmo.postssystem.features.posts.common
import com.soywiz.klock.DateTime
import dev.inmo.postssystem.features.common.common.DateTimeSerializer
import dev.inmo.postssystem.features.content.common.ContentId
import kotlinx.serialization.Serializable
import kotlin.jvm.JvmInline
/**
* Identifier of [RegisteredPost] in system
*/
@Serializable
@JvmInline
value class PostId(val long: Long) {
override fun toString(): String = long.toString()
}
typealias ContentIds = List<ContentId>
/**
* Base interface for creating of new post
*
* @see NewPost
* @see RegisteredPost
*/
@Serializable
sealed class Post {
abstract val content: ContentIds
}
/**
* This type of [Post] should be used in case you wish to register new post in system
*/
@Serializable
data class NewPost(
override val content: ContentIds
) : Post()
/**
* Registered [Post]
*/
@Serializable
data class RegisteredPost(
val id: PostId,
override val content: ContentIds,
@Serializable(DateTimeSerializer::class)
val creationDate: DateTime
) : Post()

View File

@@ -0,0 +1 @@
<manifest package="dev.inmo.postssystem.features.posts.common"/>