replace posts api and rewrite posts contents to be content ids

This commit is contained in:
InsanusMokrassar 2019-11-04 13:33:03 +06:00
parent 033acc818d
commit 3be34a94bc
7 changed files with 15 additions and 18 deletions

View File

@ -1,3 +0,0 @@
package com.insanusmokrassar.postssystem.core.api
interface PostsAPI : ReadPostsAPI, WritePostsAPI

View File

@ -10,7 +10,7 @@ interface 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.api.ReadPostsAPI.getPostsByContent] * [com.insanusmokrassar.postssystem.core.post.api.ReadPostsAPI.getPostsByContent]
*/ */
interface RegisteredContent : Content { interface RegisteredContent : Content {
val id: ContentId val id: ContentId

View File

@ -1,29 +1,26 @@
package com.insanusmokrassar.postssystem.core.post package com.insanusmokrassar.postssystem.core.post
import com.insanusmokrassar.postssystem.core.content.Content import com.insanusmokrassar.postssystem.core.content.*
import com.insanusmokrassar.postssystem.core.content.RegisteredContent
import kotlinx.serialization.Serializable
import org.joda.time.DateTime import org.joda.time.DateTime
typealias PostId = String typealias PostId = String
typealias PostContents = List<Content> typealias ContentIds = List<ContentId>
typealias RegisteredPostContents = List<RegisteredContent>
/** /**
* Base interface for creating of new post. Usually, it is just [SimplePost] instance * Base interface for creating of new post. Usually, it is just [SimplePost] instance
*/ */
interface Post { interface Post {
val content: PostContents val content: ContentIds
} }
/** /**
* Root entity of whole system. Can be retrieved from [com.insanusmokrassar.postssystem.core.api.ReadPostsAPI] by * Root entity of whole system. Can be retrieved from [com.insanusmokrassar.postssystem.core.post.api.ReadPostsAPI] by
* getting and created in [com.insanusmokrassar.postssystem.core.api.WritePostsAPI] by inserting of [Post] instance * getting and created in [com.insanusmokrassar.postssystem.core.post.api.WritePostsAPI] by inserting of [Post] instance
*/ */
interface RegisteredPost : Post { interface RegisteredPost : Post {
val id: PostId val id: PostId
override val content: RegisteredPostContents override val content: ContentIds
val creationDate: DateTime val creationDate: DateTime
val modificationDate: DateTime val modificationDate: DateTime
@ -34,7 +31,7 @@ interface RegisteredPost : Post {
* is [Post] too, but it is not direct [Post] realisation * is [Post] too, but it is not direct [Post] realisation
*/ */
data class SimplePost( data class SimplePost(
override val content: PostContents override val content: ContentIds
) : Post ) : Post
/** /**
@ -42,7 +39,7 @@ data class SimplePost(
*/ */
data class SimpleRegisteredPost( data class SimpleRegisteredPost(
override val id: PostId, override val id: PostId,
override val content: RegisteredPostContents, override val content: ContentIds,
override val creationDate: DateTime, override val creationDate: DateTime,
override val modificationDate: DateTime = creationDate override val modificationDate: DateTime = creationDate
) : RegisteredPost ) : RegisteredPost

View File

@ -0,0 +1,3 @@
package com.insanusmokrassar.postssystem.core.post.api
interface PostsAPI : ReadPostsAPI, WritePostsAPI

View File

@ -1,4 +1,4 @@
package com.insanusmokrassar.postssystem.core.api package com.insanusmokrassar.postssystem.core.post.api
import com.insanusmokrassar.postssystem.core.content.ContentId import com.insanusmokrassar.postssystem.core.content.ContentId
import com.insanusmokrassar.postssystem.core.post.* import com.insanusmokrassar.postssystem.core.post.*

View File

@ -1,4 +1,4 @@
package com.insanusmokrassar.postssystem.core.api package com.insanusmokrassar.postssystem.core.post.api
import com.insanusmokrassar.postssystem.core.post.* import com.insanusmokrassar.postssystem.core.post.*
import com.insanusmokrassar.postssystem.core.post.* import com.insanusmokrassar.postssystem.core.post.*

View File

@ -1,4 +1,4 @@
package com.insanusmokrassar.postssystem.core.api package com.insanusmokrassar.postssystem.core.post.api
import com.insanusmokrassar.postssystem.core.content.ContentId import com.insanusmokrassar.postssystem.core.content.ContentId
import com.insanusmokrassar.postssystem.core.content.RegisteredContent import com.insanusmokrassar.postssystem.core.content.RegisteredContent