add post preview

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

View File

@ -14,6 +14,7 @@ kotlin {
api "dev.inmo:micro_utils.serialization.typed_serializer:$microutils_version" api "dev.inmo:micro_utils.serialization.typed_serializer:$microutils_version"
api "io.insert-koin:koin-core:$koin_version" api "io.insert-koin:koin-core:$koin_version"
api "com.benasher44:uuid:$uuid_version" api "com.benasher44:uuid:$uuid_version"
api "com.soywiz.korlibs.klock:klock:$klock_version"
} }
} }
jvmMain { jvmMain {

View File

@ -0,0 +1,23 @@
package dev.inmo.postssystem.features.common.common
import com.soywiz.klock.DateTime
import kotlinx.serialization.KSerializer
import kotlinx.serialization.Serializer
import kotlinx.serialization.builtins.serializer
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
@Serializer(DateTime::class)
object DateTimeSerializer : KSerializer<DateTime> {
override val descriptor: SerialDescriptor
get() = Double.serializer().descriptor
override fun deserialize(decoder: Decoder): DateTime {
return DateTime(decoder.decodeDouble())
}
override fun serialize(encoder: Encoder, value: DateTime) {
encoder.encodeDouble(value.unixMillis)
}
}

View File

@ -0,0 +1,18 @@
plugins {
id "org.jetbrains.kotlin.multiplatform"
id "org.jetbrains.kotlin.plugin.serialization"
id "com.android.library"
}
apply from: "$mppProjectWithSerializationPresetPath"
kotlin {
sourceSets {
commonMain {
dependencies {
api project(":postssystem.features.posts.common")
api project(":postssystem.features.common.client")
}
}
}
}

View File

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

View File

@ -0,0 +1,18 @@
plugins {
id "org.jetbrains.kotlin.multiplatform"
id "org.jetbrains.kotlin.plugin.serialization"
id "com.android.library"
}
apply from: "$mppProjectWithSerializationPresetPath"
kotlin {
sourceSets {
commonMain {
dependencies {
api project(":postssystem.features.common.common")
api project(":postssystem.features.content.common")
}
}
}
}

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"/>

View File

@ -0,0 +1,17 @@
plugins {
id "org.jetbrains.kotlin.multiplatform"
id "org.jetbrains.kotlin.plugin.serialization"
}
apply from: "$mppJavaProjectPresetPath"
kotlin {
sourceSets {
commonMain {
dependencies {
api project(":postssystem.features.posts.common")
api project(":postssystem.features.common.server")
}
}
}
}

View File

@ -4,12 +4,7 @@ project.group = "$group"
apply from: "$publishGradlePath" apply from: "$publishGradlePath"
kotlin { kotlin {
jvm().compilations.main { jvm()
kotlinOptions {
jvmTarget = "1.8"
targetCompatibility = "1.8"
}
}
sourceSets { sourceSets {
commonMain { commonMain {

View File

@ -4,12 +4,7 @@ project.group = "$group"
apply from: "$publishGradlePath" apply from: "$publishGradlePath"
kotlin { kotlin {
jvm().compilations.main { jvm()
kotlinOptions {
jvmTarget = "1.8"
targetCompatibility = "1.8"
}
}
js (IR) { js (IR) {
browser() browser()
nodejs() nodejs()

View File

@ -41,6 +41,10 @@ String[] includes = [
":features:content:binary:client", ":features:content:binary:client",
":features:content:binary:server", ":features:content:binary:server",
":features:posts:common",
":features:posts:client",
":features:posts:server",
":server", ":server",
":client", ":client",
] ]