temporary remove @Serializable annotation from PaginationResult
This commit is contained in:
parent
f2d66b2fe9
commit
5017e66dad
@ -1,17 +1,30 @@
|
|||||||
package com.insanusmokrassar.postssystem.core.content
|
package com.insanusmokrassar.postssystem.core.content
|
||||||
|
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
typealias ContentId = String
|
typealias ContentId = String
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Content which is planned to be registered in database
|
* Content which is planned to be registered in database
|
||||||
*/
|
*/
|
||||||
interface Content
|
sealed class Content
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class SimpleSpecialContent(
|
||||||
|
val internalId: ContentId
|
||||||
|
) : Content()
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class SimpleTextContent(
|
||||||
|
val text: String
|
||||||
|
) : Content()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Content which is already registered in database. Using its [id] you can retrieve all known
|
* Content which is already registered in database. Using its [id] you can retrieve all known
|
||||||
* [com.insanusmokrassar.postssystem.core.post.RegisteredPost]s by using
|
* [com.insanusmokrassar.postssystem.core.post.RegisteredPost]s by using
|
||||||
* [com.insanusmokrassar.postssystem.core.post.api.ReadPostsAPI.getPostsByContent]
|
* [com.insanusmokrassar.postssystem.core.post.api.ReadPostsAPI.getPostsByContent]
|
||||||
*/
|
*/
|
||||||
interface RegisteredContent : Content {
|
data class RegisteredContent(
|
||||||
val id: ContentId
|
val id: ContentId,
|
||||||
}
|
val content: Content
|
||||||
|
)
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
package com.insanusmokrassar.postssystem.core.content
|
|
||||||
|
|
||||||
import kotlinx.serialization.Serializable
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Special content, which usually better known in some plugin or system, but is not representable in others. For
|
|
||||||
* example, it could be issue in some git system, which is unknown for all other systems.
|
|
||||||
*
|
|
||||||
* @property internalId Represent Id of this content in system which knows exact type and can correctly handle this
|
|
||||||
* content
|
|
||||||
*/
|
|
||||||
interface SpecialContent : Content {
|
|
||||||
val internalId: ContentId
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* As [SpecialContent], but already registered in posts system
|
|
||||||
*/
|
|
||||||
interface SpecialRegisteredContent : RegisteredContent, SpecialContent
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class SimpleSpecialContent(
|
|
||||||
override val internalId: ContentId
|
|
||||||
) : SpecialContent
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class SimpleSpecialRegisteredContent(
|
|
||||||
override val id: ContentId,
|
|
||||||
override val internalId: ContentId
|
|
||||||
) : SpecialRegisteredContent
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
|||||||
package com.insanusmokrassar.postssystem.core.content
|
|
||||||
|
|
||||||
import kotlinx.serialization.Serializable
|
|
||||||
|
|
||||||
interface TextContent : Content {
|
|
||||||
val text: String
|
|
||||||
}
|
|
||||||
|
|
||||||
interface TextRegisteredContent : RegisteredContent, TextContent
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class SimpleTextContent(
|
|
||||||
override val text: String
|
|
||||||
) : TextContent
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class SimpleTextRegisteredContent(
|
|
||||||
override val id: ContentId,
|
|
||||||
override val text: String
|
|
||||||
) : TextRegisteredContent
|
|
@ -0,0 +1,2 @@
|
|||||||
|
package com.insanusmokrassar.postssystem.core.utils
|
||||||
|
|
@ -2,7 +2,6 @@ package com.insanusmokrassar.postssystem.core.utils.pagination
|
|||||||
|
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class PaginationResult<T>(
|
data class PaginationResult<T>(
|
||||||
override val page: Int,
|
override val page: Int,
|
||||||
val pagesNumber: Int,
|
val pagesNumber: Int,
|
||||||
|
@ -31,7 +31,10 @@ class InMemoryContentAPI(
|
|||||||
.toMutableMap()
|
.toMutableMap()
|
||||||
|
|
||||||
override suspend fun createContent(content: Content): RegisteredContent? {
|
override suspend fun createContent(content: Content): RegisteredContent? {
|
||||||
return content.createRegisteredEntity(generateId())?.also { registeredContent ->
|
return RegisteredContent(
|
||||||
|
generateId(),
|
||||||
|
content
|
||||||
|
).also { registeredContent ->
|
||||||
contents[registeredContent.id] = registeredContent
|
contents[registeredContent.id] = registeredContent
|
||||||
contentCreatedBroadcastChannel.send(registeredContent)
|
contentCreatedBroadcastChannel.send(registeredContent)
|
||||||
}
|
}
|
||||||
@ -51,12 +54,4 @@ class InMemoryContentAPI(
|
|||||||
contentDeletedBroadcastChannel.send(content)
|
contentDeletedBroadcastChannel.send(content)
|
||||||
} != null
|
} != null
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Content.createRegisteredEntity(id: ContentId): RegisteredContent? {
|
|
||||||
return when(this) {
|
|
||||||
is TextContent -> SimpleTextRegisteredContent(id, text)
|
|
||||||
is SpecialContent -> SimpleTextRegisteredContent(id, internalId)
|
|
||||||
else -> null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user