add content
This commit is contained in:
18
features/content/client/build.gradle
Normal file
18
features/content/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.content.common")
|
||||
api project(":postssystem.features.common.client")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
1
features/content/client/src/main/AndroidManifest.xml
Normal file
1
features/content/client/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1 @@
|
||||
<manifest package="dev.inmo.postssystem.features.content.client"/>
|
17
features/content/common/build.gradle
Normal file
17
features/content/common/build.gradle
Normal file
@@ -0,0 +1,17 @@
|
||||
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")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
package dev.inmo.postssystem.features.content.common
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
typealias ContentId = String
|
||||
|
||||
/**
|
||||
* Content which is planned to be registered in database
|
||||
*
|
||||
* @see ContentSerializersModuleConfigurator.Element
|
||||
* @see ContentSerializersModuleConfigurator
|
||||
*/
|
||||
interface 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
|
||||
)
|
@@ -0,0 +1,18 @@
|
||||
package dev.inmo.postssystem.features.content.common
|
||||
|
||||
import dev.inmo.postssystem.features.common.common.SerializersModuleConfigurator
|
||||
import kotlinx.serialization.modules.*
|
||||
|
||||
class ContentSerializersModuleConfigurator(
|
||||
private val subconfigurators: List<Element>
|
||||
) : SerializersModuleConfigurator.Element {
|
||||
fun interface Element {
|
||||
operator fun PolymorphicModuleBuilder<Content>.invoke()
|
||||
}
|
||||
|
||||
override fun SerializersModuleBuilder.invoke() {
|
||||
polymorphic(Content::class) {
|
||||
subconfigurators.forEach { it.apply { invoke() } }
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
package dev.inmo.postssystem.features.content.common
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.modules.PolymorphicModuleBuilder
|
||||
|
||||
/**
|
||||
* That is a content which in fact just a link to another content. It would be useful in case when user wish to reuse
|
||||
* some content
|
||||
*/
|
||||
@Serializable
|
||||
data class OtherContentLinkContent(
|
||||
val otherId: ContentId
|
||||
) : Content
|
||||
|
||||
object OtherContentSerializerModuleConfigurator : ContentSerializersModuleConfigurator.Element {
|
||||
override fun PolymorphicModuleBuilder<Content>.invoke() {
|
||||
subclass(OtherContentLinkContent::class, OtherContentLinkContent.serializer())
|
||||
}
|
||||
}
|
1
features/content/common/src/main/AndroidManifest.xml
Normal file
1
features/content/common/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1 @@
|
||||
<manifest package="dev.inmo.postssystem.features.content.common"/>
|
17
features/content/server/build.gradle
Normal file
17
features/content/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.content.common")
|
||||
api project(":postssystem.features.common.server")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user