add post preview
This commit is contained in:
parent
61496069b7
commit
571f5781d2
@ -14,6 +14,7 @@ kotlin {
|
||||
api "dev.inmo:micro_utils.serialization.typed_serializer:$microutils_version"
|
||||
api "io.insert-koin:koin-core:$koin_version"
|
||||
api "com.benasher44:uuid:$uuid_version"
|
||||
api "com.soywiz.korlibs.klock:klock:$klock_version"
|
||||
}
|
||||
}
|
||||
jvmMain {
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
18
features/posts/client/build.gradle
Normal file
18
features/posts/client/build.gradle
Normal 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")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
1
features/posts/client/src/main/AndroidManifest.xml
Normal file
1
features/posts/client/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1 @@
|
||||
<manifest package="dev.inmo.postssystem.features.posts.client"/>
|
18
features/posts/common/build.gradle
Normal file
18
features/posts/common/build.gradle
Normal 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")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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()
|
1
features/posts/common/src/main/AndroidManifest.xml
Normal file
1
features/posts/common/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1 @@
|
||||
<manifest package="dev.inmo.postssystem.features.posts.common"/>
|
17
features/posts/server/build.gradle
Normal file
17
features/posts/server/build.gradle
Normal 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")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -4,12 +4,7 @@ project.group = "$group"
|
||||
apply from: "$publishGradlePath"
|
||||
|
||||
kotlin {
|
||||
jvm().compilations.main {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
targetCompatibility = "1.8"
|
||||
}
|
||||
}
|
||||
jvm()
|
||||
|
||||
sourceSets {
|
||||
commonMain {
|
||||
|
@ -4,12 +4,7 @@ project.group = "$group"
|
||||
apply from: "$publishGradlePath"
|
||||
|
||||
kotlin {
|
||||
jvm().compilations.main {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
targetCompatibility = "1.8"
|
||||
}
|
||||
}
|
||||
jvm()
|
||||
js (IR) {
|
||||
browser()
|
||||
nodejs()
|
||||
|
@ -41,6 +41,10 @@ String[] includes = [
|
||||
":features:content:binary:client",
|
||||
":features:content:binary:server",
|
||||
|
||||
":features:posts:common",
|
||||
":features:posts:client",
|
||||
":features:posts:server",
|
||||
|
||||
":server",
|
||||
":client",
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user