started to fill client part

This commit is contained in:
InsanusMokrassar 2019-10-16 23:46:15 +06:00
parent 71c7880582
commit 631cfe9c28
27 changed files with 251 additions and 67 deletions

41
ClientPart/build.gradle Normal file
View File

@ -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 ]
}
}

View File

@ -0,0 +1 @@
ktor_version=1.2.4

View File

@ -0,0 +1 @@
rootProject.name = 'postssystem.core.client'

View File

@ -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<Post> {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override suspend fun getPostsByDates(from: DateTime?, to: DateTime?): List<Post> {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override suspend fun getPostsByPagination(pagination: Pagination): PaginationResult<Post> {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
}

View File

@ -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<Post>
get() = TODO("not implemented") //To change initializer of created properties use File | Settings | File Templates.
override val postDeletedFlow: Flow<Post>
get() = TODO("not implemented") //To change initializer of created properties use File | Settings | File Templates.
override val postUpdatedFlow: Flow<Post>
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.
}
}

View File

@ -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 ]
}
}

View File

@ -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"

View File

@ -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
)

40
Core/build.gradle Normal file
View File

@ -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 ]
}
}

1
Core/settings.gradle Normal file
View File

@ -0,0 +1 @@
rootProject.name = 'postssystem.core'

View File

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

View File

@ -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<Post>
suspend fun getPostsByDates(from: DateTime? = null, to: DateTime? = null): List<Post>
suspend fun getPostsByPagination(pagination: Pagination): PaginationResult<Post>
}

View File

@ -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 {

View File

@ -1,4 +1,4 @@
package com.github.insanusmokrassar.postssystem.core.content
package com.insanusmokrassar.postssystem.core.content
import org.joda.time.DateTime

View File

@ -0,0 +1,5 @@
package com.insanusmokrassar.postssystem.core.content
interface TextContent : Content {
val text: String
}

View File

@ -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<Content>

View File

@ -1,4 +1,4 @@
package com.github.insanusmokrassar.postssystem.core.post
package com.insanusmokrassar.postssystem.core.post
import org.joda.time.DateTime

View File

@ -0,0 +1,6 @@
package com.insanusmokrassar.postssystem.core.utils.pagination
interface Pagination {
val page: Int
val size: Int
}

View File

@ -1,4 +1,4 @@
package com.github.insanusmokrassar.postssystem.core.utils.pagination
package com.insanusmokrassar.postssystem.core.utils.pagination
import kotlinx.serialization.Serializable

View File

@ -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

View File

@ -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 ]
}
}

View File

@ -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

View File

@ -15,4 +15,6 @@ include 'api'
include 'services:webservice'
*/
rootProject.name = 'PostsSystemCore'
include ':ClientPart'
include ':Core'
include ':ClientServerCommon'

View File

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

View File

@ -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<Post>
suspend fun getPostsByDates(from: DateTime? = null, to: DateTime? = null): List<Post>
suspend fun getPostsByPagination(pagination: Pagination): PaginationResult<Post>
}

View File

@ -1,5 +0,0 @@
package com.github.insanusmokrassar.postssystem.core.content
interface TextContent : Content {
val text: String
}

View File

@ -1,6 +0,0 @@
package com.github.insanusmokrassar.postssystem.core.utils.pagination
interface Pagination {
val page: Int
val size: Int
}