diff --git a/ClientPart/build.gradle b/ClientPart/build.gradle new file mode 100644 index 00000000..1eccead8 --- /dev/null +++ b/ClientPart/build.gradle @@ -0,0 +1,41 @@ +project.version = "0.1.0" +project.group = "com.insanusmokrassar" + +buildscript { + repositories { + mavenLocal() + jcenter() + mavenCentral() + } + + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" + classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version" + } +} + +apply plugin: 'java-library' +apply plugin: 'kotlin' +apply plugin: 'kotlinx-serialization' + +repositories { + mavenLocal() + jcenter() + mavenCentral() + maven { url "https://kotlin.bintray.com/kotlinx" } +} + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + api project(":Core") + api project(":ClientServerCommon") + + api "io.ktor:ktor-client:$ktor_version" +} + +compileKotlin { + kotlinOptions { + freeCompilerArgs = [ disableImplicitReflectionSerializerAnnotation ] + } +} diff --git a/ClientPart/gradle.properties b/ClientPart/gradle.properties new file mode 100644 index 00000000..35649e7e --- /dev/null +++ b/ClientPart/gradle.properties @@ -0,0 +1 @@ +ktor_version=1.2.4 diff --git a/ClientPart/settings.gradle b/ClientPart/settings.gradle new file mode 100644 index 00000000..11dc58a5 --- /dev/null +++ b/ClientPart/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'postssystem.core.client' diff --git a/ClientPart/src/main/kotlin/com/insanusmokrassar/postssystem/core/client/ReadableHttpPostsAPI.kt b/ClientPart/src/main/kotlin/com/insanusmokrassar/postssystem/core/client/ReadableHttpPostsAPI.kt new file mode 100644 index 00000000..e3998358 --- /dev/null +++ b/ClientPart/src/main/kotlin/com/insanusmokrassar/postssystem/core/client/ReadableHttpPostsAPI.kt @@ -0,0 +1,38 @@ +package com.insanusmokrassar.postssystem.core.client + +import com.insanusmokrassar.postssystem.core.api.ReadPostsAPI +import com.insanusmokrassar.postssystem.core.clientserver.common.* +import com.insanusmokrassar.postssystem.core.content.ContentId +import com.insanusmokrassar.postssystem.core.post.Post +import com.insanusmokrassar.postssystem.core.post.PostId +import com.insanusmokrassar.postssystem.core.utils.pagination.Pagination +import com.insanusmokrassar.postssystem.core.utils.pagination.PaginationResult +import io.ktor.client.HttpClient +import io.ktor.client.request.post +import org.joda.time.DateTime + +class ReadableHttpPostsAPI( + private val client: HttpClient = HttpClient(), + private val baseAddress: String +) : ReadPostsAPI { + private val postByIdAddress = "$baseAddress/$getPostByIdAddress" + private val postsByContentIdAddress = "$baseAddress/$getPostsByContentIdAddress" + private val postsByDatesAddress = "$baseAddress/$getPostsByDatesAddress" + private val postsByPaginationAddress = "$baseAddress/$getPostsByPaginationAddress" + + override suspend fun getPostById(id: PostId): Post? { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override suspend fun getPostsByContent(id: ContentId): List { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override suspend fun getPostsByDates(from: DateTime?, to: DateTime?): List { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override suspend fun getPostsByPagination(pagination: Pagination): PaginationResult { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } +} \ No newline at end of file diff --git a/ClientPart/src/main/kotlin/com/insanusmokrassar/postssystem/core/client/WritableHttpPostsAPI.kt b/ClientPart/src/main/kotlin/com/insanusmokrassar/postssystem/core/client/WritableHttpPostsAPI.kt new file mode 100644 index 00000000..f83bead2 --- /dev/null +++ b/ClientPart/src/main/kotlin/com/insanusmokrassar/postssystem/core/client/WritableHttpPostsAPI.kt @@ -0,0 +1,26 @@ +package com.insanusmokrassar.postssystem.core.client + +import com.insanusmokrassar.postssystem.core.api.WritePostsAPI +import com.insanusmokrassar.postssystem.core.post.* +import kotlinx.coroutines.flow.Flow + +class WritableHttpPostsAPI : WritePostsAPI { + override val postCreatedFlow: Flow + get() = TODO("not implemented") //To change initializer of created properties use File | Settings | File Templates. + override val postDeletedFlow: Flow + get() = TODO("not implemented") //To change initializer of created properties use File | Settings | File Templates. + override val postUpdatedFlow: Flow + get() = TODO("not implemented") //To change initializer of created properties use File | Settings | File Templates. + + override suspend fun createPost(content: PostContents): Post? { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override suspend fun deletePost(id: PostId): Boolean { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override suspend fun updatePostContent(postId: PostId, content: PostContents): Boolean { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } +} \ No newline at end of file diff --git a/ClientServerCommon/build.gradle b/ClientServerCommon/build.gradle new file mode 100644 index 00000000..5db05bcc --- /dev/null +++ b/ClientServerCommon/build.gradle @@ -0,0 +1,38 @@ +project.version = "0.1.0" +project.group = "com.insanusmokrassar" + +buildscript { + repositories { + mavenLocal() + jcenter() + mavenCentral() + } + + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" + classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version" + } +} + +apply plugin: 'java-library' +apply plugin: 'kotlin' +apply plugin: 'kotlinx-serialization' + +repositories { + mavenLocal() + jcenter() + mavenCentral() + maven { url "https://kotlin.bintray.com/kotlinx" } +} + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + api project(":Core") +} + +compileKotlin { + kotlinOptions { + freeCompilerArgs = [ disableImplicitReflectionSerializerAnnotation ] + } +} diff --git a/ClientServerCommon/src/main/kotlin/com/insanusmokrassar/postssystem/core/clientserver/common/Paths.kt b/ClientServerCommon/src/main/kotlin/com/insanusmokrassar/postssystem/core/clientserver/common/Paths.kt new file mode 100644 index 00000000..4fd68fcb --- /dev/null +++ b/ClientServerCommon/src/main/kotlin/com/insanusmokrassar/postssystem/core/clientserver/common/Paths.kt @@ -0,0 +1,6 @@ +package com.insanusmokrassar.postssystem.core.clientserver.common + +const val getPostByIdAddress = "core/posts/get/id" +const val getPostsByContentIdAddress = "core/posts/get/content_id" +const val getPostsByDatesAddress = "core/posts/get/dates" +const val getPostsByPaginationAddress = "core/posts/get/pagination" diff --git a/ClientServerCommon/src/main/kotlin/com/insanusmokrassar/postssystem/core/clientserver/common/ReadModels.kt b/ClientServerCommon/src/main/kotlin/com/insanusmokrassar/postssystem/core/clientserver/common/ReadModels.kt new file mode 100644 index 00000000..41327865 --- /dev/null +++ b/ClientServerCommon/src/main/kotlin/com/insanusmokrassar/postssystem/core/clientserver/common/ReadModels.kt @@ -0,0 +1,11 @@ +package com.insanusmokrassar.postssystem.core.clientserver.common + +import com.insanusmokrassar.postssystem.core.post.PostId +import kotlinx.serialization.Serializable + +sealed class ReadModel + +@Serializable +class ReadPostsById( + val postId: PostId +) diff --git a/Core/build.gradle b/Core/build.gradle new file mode 100644 index 00000000..9d361ef1 --- /dev/null +++ b/Core/build.gradle @@ -0,0 +1,40 @@ +project.version = "0.1.0" +project.group = "com.insanusmokrassar" + +buildscript { + repositories { + mavenLocal() + jcenter() + mavenCentral() + } + + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" + classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version" + } +} + +apply plugin: 'java-library' +apply plugin: 'kotlin' +apply plugin: 'kotlinx-serialization' + +repositories { + mavenLocal() + jcenter() + mavenCentral() + maven { url "https://kotlin.bintray.com/kotlinx" } +} + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version" + api "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$kotlin_serialisation_runtime_version" + api "joda-time:joda-time:$joda_time_version" +} + +compileKotlin { + kotlinOptions { + freeCompilerArgs = [ disableImplicitReflectionSerializerAnnotation ] + } +} diff --git a/Core/settings.gradle b/Core/settings.gradle new file mode 100644 index 00000000..9ed4be64 --- /dev/null +++ b/Core/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'postssystem.core' diff --git a/Core/src/main/kotlin/com/insanusmokrassar/postssystem/core/api/PostsAPI.kt b/Core/src/main/kotlin/com/insanusmokrassar/postssystem/core/api/PostsAPI.kt new file mode 100644 index 00000000..bd5354b9 --- /dev/null +++ b/Core/src/main/kotlin/com/insanusmokrassar/postssystem/core/api/PostsAPI.kt @@ -0,0 +1,4 @@ +package com.insanusmokrassar.postssystem.core.api + +interface PostsAPI : ReadPostsAPI, + WritePostsAPI diff --git a/Core/src/main/kotlin/com/insanusmokrassar/postssystem/core/api/ReadPostsAPI.kt b/Core/src/main/kotlin/com/insanusmokrassar/postssystem/core/api/ReadPostsAPI.kt new file mode 100644 index 00000000..bf109326 --- /dev/null +++ b/Core/src/main/kotlin/com/insanusmokrassar/postssystem/core/api/ReadPostsAPI.kt @@ -0,0 +1,17 @@ +package com.insanusmokrassar.postssystem.core.api + +import com.insanusmokrassar.postssystem.core.post.Post +import com.insanusmokrassar.postssystem.core.post.PostId +import com.insanusmokrassar.postssystem.core.content.ContentId +import com.insanusmokrassar.postssystem.core.utils.pagination.* +import com.insanusmokrassar.postssystem.core.utils.pagination.Pagination +import com.insanusmokrassar.postssystem.core.utils.pagination.PaginationResult +import org.joda.time.DateTime + +interface ReadPostsAPI { + suspend fun getPostById(id: PostId): Post? + suspend fun getPostsByContent(id: ContentId): List + suspend fun getPostsByDates(from: DateTime? = null, to: DateTime? = null): List + + suspend fun getPostsByPagination(pagination: Pagination): PaginationResult +} \ No newline at end of file diff --git a/src/main/kotlin/com/github/insanusmokrassar/postssystem/core/api/WritePostsAPI.kt b/Core/src/main/kotlin/com/insanusmokrassar/postssystem/core/api/WritePostsAPI.kt similarity index 70% rename from src/main/kotlin/com/github/insanusmokrassar/postssystem/core/api/WritePostsAPI.kt rename to Core/src/main/kotlin/com/insanusmokrassar/postssystem/core/api/WritePostsAPI.kt index cde400d9..43b2897c 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/postssystem/core/api/WritePostsAPI.kt +++ b/Core/src/main/kotlin/com/insanusmokrassar/postssystem/core/api/WritePostsAPI.kt @@ -1,6 +1,7 @@ -package com.github.insanusmokrassar.postssystem.core.api +package com.insanusmokrassar.postssystem.core.api -import com.github.insanusmokrassar.postssystem.core.post.* +import com.insanusmokrassar.postssystem.core.post.* +import com.insanusmokrassar.postssystem.core.post.* import kotlinx.coroutines.flow.Flow interface WritePostsAPI { diff --git a/src/main/kotlin/com/github/insanusmokrassar/postssystem/core/content/Content.kt b/Core/src/main/kotlin/com/insanusmokrassar/postssystem/core/content/Content.kt similarity index 63% rename from src/main/kotlin/com/github/insanusmokrassar/postssystem/core/content/Content.kt rename to Core/src/main/kotlin/com/insanusmokrassar/postssystem/core/content/Content.kt index f4bd8786..3d0e5793 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/postssystem/core/content/Content.kt +++ b/Core/src/main/kotlin/com/insanusmokrassar/postssystem/core/content/Content.kt @@ -1,4 +1,4 @@ -package com.github.insanusmokrassar.postssystem.core.content +package com.insanusmokrassar.postssystem.core.content import org.joda.time.DateTime diff --git a/Core/src/main/kotlin/com/insanusmokrassar/postssystem/core/content/TextContent.kt b/Core/src/main/kotlin/com/insanusmokrassar/postssystem/core/content/TextContent.kt new file mode 100644 index 00000000..3dae566d --- /dev/null +++ b/Core/src/main/kotlin/com/insanusmokrassar/postssystem/core/content/TextContent.kt @@ -0,0 +1,5 @@ +package com.insanusmokrassar.postssystem.core.content + +interface TextContent : Content { + val text: String +} \ No newline at end of file diff --git a/src/main/kotlin/com/github/insanusmokrassar/postssystem/core/post/Post.kt b/Core/src/main/kotlin/com/insanusmokrassar/postssystem/core/post/Post.kt similarity index 56% rename from src/main/kotlin/com/github/insanusmokrassar/postssystem/core/post/Post.kt rename to Core/src/main/kotlin/com/insanusmokrassar/postssystem/core/post/Post.kt index 82588238..12cb975b 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/postssystem/core/post/Post.kt +++ b/Core/src/main/kotlin/com/insanusmokrassar/postssystem/core/post/Post.kt @@ -1,6 +1,6 @@ -package com.github.insanusmokrassar.postssystem.core.post +package com.insanusmokrassar.postssystem.core.post -import com.github.insanusmokrassar.postssystem.core.content.Content +import com.insanusmokrassar.postssystem.core.content.Content typealias PostId = String typealias PostContents = List diff --git a/src/main/kotlin/com/github/insanusmokrassar/postssystem/core/post/PostMetaInfo.kt b/Core/src/main/kotlin/com/insanusmokrassar/postssystem/core/post/PostMetaInfo.kt similarity index 71% rename from src/main/kotlin/com/github/insanusmokrassar/postssystem/core/post/PostMetaInfo.kt rename to Core/src/main/kotlin/com/insanusmokrassar/postssystem/core/post/PostMetaInfo.kt index 345951a9..f6133d6c 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/postssystem/core/post/PostMetaInfo.kt +++ b/Core/src/main/kotlin/com/insanusmokrassar/postssystem/core/post/PostMetaInfo.kt @@ -1,4 +1,4 @@ -package com.github.insanusmokrassar.postssystem.core.post +package com.insanusmokrassar.postssystem.core.post import org.joda.time.DateTime diff --git a/Core/src/main/kotlin/com/insanusmokrassar/postssystem/core/utils/pagination/Pagination.kt b/Core/src/main/kotlin/com/insanusmokrassar/postssystem/core/utils/pagination/Pagination.kt new file mode 100644 index 00000000..6f419c4d --- /dev/null +++ b/Core/src/main/kotlin/com/insanusmokrassar/postssystem/core/utils/pagination/Pagination.kt @@ -0,0 +1,6 @@ +package com.insanusmokrassar.postssystem.core.utils.pagination + +interface Pagination { + val page: Int + val size: Int +} \ No newline at end of file diff --git a/src/main/kotlin/com/github/insanusmokrassar/postssystem/core/utils/pagination/PaginationRequest.kt b/Core/src/main/kotlin/com/insanusmokrassar/postssystem/core/utils/pagination/PaginationRequest.kt similarity index 69% rename from src/main/kotlin/com/github/insanusmokrassar/postssystem/core/utils/pagination/PaginationRequest.kt rename to Core/src/main/kotlin/com/insanusmokrassar/postssystem/core/utils/pagination/PaginationRequest.kt index 18533721..53a6124e 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/postssystem/core/utils/pagination/PaginationRequest.kt +++ b/Core/src/main/kotlin/com/insanusmokrassar/postssystem/core/utils/pagination/PaginationRequest.kt @@ -1,4 +1,4 @@ -package com.github.insanusmokrassar.postssystem.core.utils.pagination +package com.insanusmokrassar.postssystem.core.utils.pagination import kotlinx.serialization.Serializable diff --git a/src/main/kotlin/com/github/insanusmokrassar/postssystem/core/utils/pagination/PaginationResult.kt b/Core/src/main/kotlin/com/insanusmokrassar/postssystem/core/utils/pagination/PaginationResult.kt similarity index 80% rename from src/main/kotlin/com/github/insanusmokrassar/postssystem/core/utils/pagination/PaginationResult.kt rename to Core/src/main/kotlin/com/insanusmokrassar/postssystem/core/utils/pagination/PaginationResult.kt index af8ed0a6..67f3e855 100644 --- a/src/main/kotlin/com/github/insanusmokrassar/postssystem/core/utils/pagination/PaginationResult.kt +++ b/Core/src/main/kotlin/com/insanusmokrassar/postssystem/core/utils/pagination/PaginationResult.kt @@ -1,4 +1,4 @@ -package com.github.insanusmokrassar.postssystem.core.utils.pagination +package com.insanusmokrassar.postssystem.core.utils.pagination import kotlinx.serialization.Serializable import kotlinx.serialization.Transient diff --git a/build.gradle b/build.gradle index b8f3c96a..e03c8e22 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,4 @@ -project.version = "0.1.0" -project.group = "com.github.insanusmokrassar" +project.group = "com.insanusmokrassar" buildscript { repositories { @@ -7,36 +6,11 @@ buildscript { jcenter() mavenCentral() } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" - classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$gradle_bintray_plugin_version" - } } -apply plugin: 'java-library' -apply plugin: 'kotlin' -apply plugin: 'kotlinx-serialization' - -apply from: "publish.gradle" - repositories { mavenLocal() jcenter() mavenCentral() maven { url "https://kotlin.bintray.com/kotlinx" } } - -dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version" - api "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$kotlin_serialisation_runtime_version" - api "joda-time:joda-time:$joda_time_version" -} - -compileKotlin { - kotlinOptions { - freeCompilerArgs = [ disableImplicitReflectionSerializerAnnotation ] - } -} diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 663c4485..5a855b1a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ +#Wed Oct 16 13:07:45 OMST 2019 +distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip +zipStoreBase=GRADLE_USER_HOME diff --git a/settings.gradle b/settings.gradle index d9165360..f24e9e2f 100644 --- a/settings.gradle +++ b/settings.gradle @@ -15,4 +15,6 @@ include 'api' include 'services:webservice' */ -rootProject.name = 'PostsSystemCore' +include ':ClientPart' +include ':Core' +include ':ClientServerCommon' diff --git a/src/main/kotlin/com/github/insanusmokrassar/postssystem/core/api/PostsAPI.kt b/src/main/kotlin/com/github/insanusmokrassar/postssystem/core/api/PostsAPI.kt deleted file mode 100644 index 229d791e..00000000 --- a/src/main/kotlin/com/github/insanusmokrassar/postssystem/core/api/PostsAPI.kt +++ /dev/null @@ -1,3 +0,0 @@ -package com.github.insanusmokrassar.postssystem.core.api - -interface PostsAPI : ReadPostsAPI, WritePostsAPI diff --git a/src/main/kotlin/com/github/insanusmokrassar/postssystem/core/api/ReadPostsAPI.kt b/src/main/kotlin/com/github/insanusmokrassar/postssystem/core/api/ReadPostsAPI.kt deleted file mode 100644 index 33da29af..00000000 --- a/src/main/kotlin/com/github/insanusmokrassar/postssystem/core/api/ReadPostsAPI.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.github.insanusmokrassar.postssystem.core.api - -import com.github.insanusmokrassar.postssystem.core.post.Post -import com.github.insanusmokrassar.postssystem.core.post.PostId -import com.github.insanusmokrassar.postssystem.core.content.ContentId -import com.github.insanusmokrassar.postssystem.core.utils.pagination.* -import org.joda.time.DateTime - -interface ReadPostsAPI { - suspend fun getPostById(id: PostId): Post? - suspend fun getPostsByContent(id: ContentId): List - suspend fun getPostsByDates(from: DateTime? = null, to: DateTime? = null): List - - suspend fun getPostsByPagination(pagination: Pagination): PaginationResult -} \ No newline at end of file diff --git a/src/main/kotlin/com/github/insanusmokrassar/postssystem/core/content/TextContent.kt b/src/main/kotlin/com/github/insanusmokrassar/postssystem/core/content/TextContent.kt deleted file mode 100644 index f3bc7bff..00000000 --- a/src/main/kotlin/com/github/insanusmokrassar/postssystem/core/content/TextContent.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.github.insanusmokrassar.postssystem.core.content - -interface TextContent : Content { - val text: String -} \ No newline at end of file diff --git a/src/main/kotlin/com/github/insanusmokrassar/postssystem/core/utils/pagination/Pagination.kt b/src/main/kotlin/com/github/insanusmokrassar/postssystem/core/utils/pagination/Pagination.kt deleted file mode 100644 index b5cea5d5..00000000 --- a/src/main/kotlin/com/github/insanusmokrassar/postssystem/core/utils/pagination/Pagination.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.github.insanusmokrassar.postssystem.core.utils.pagination - -interface Pagination { - val page: Int - val size: Int -} \ No newline at end of file