Commit 5fb56b38 authored by Vladislav's avatar Vladislav

prove isRead flag for article

parent b22a6d40
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings"> <component name="GradleSettings">
<option name="linkedExternalProjectsSettings"> <option name="linkedExternalProjectsSettings">
<GradleProjectSettings> <GradleProjectSettings>
<option name="delegatedBuild" value="false" />
<option name="testRunner" value="PLATFORM" /> <option name="testRunner" value="PLATFORM" />
<option name="distributionType" value="DEFAULT_WRAPPED" /> <option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" /> <option name="externalProjectPath" value="$PROJECT_DIR$" />
......
...@@ -10,6 +10,7 @@ import com.biganto.visual.roompark.domain.model.ArticleModel ...@@ -10,6 +10,7 @@ import com.biganto.visual.roompark.domain.model.ArticleModel
import com.biganto.visual.roompark.domain.model.ArticlesPreviewModel import com.biganto.visual.roompark.domain.model.ArticlesPreviewModel
import com.biganto.visual.roompark.domain.model.FeedModel import com.biganto.visual.roompark.domain.model.FeedModel
import com.biganto.visual.roompark.domain.model.fromEntity import com.biganto.visual.roompark.domain.model.fromEntity
import io.reactivex.Completable
import io.reactivex.Observable import io.reactivex.Observable
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers
import timber.log.Timber import timber.log.Timber
...@@ -33,6 +34,7 @@ class FeedsContractModule @Inject constructor( ...@@ -33,6 +34,7 @@ class FeedsContractModule @Inject constructor(
override fun fetchFeedObservable(feedAlias: String): Observable<ArticlesPreviewModel> = override fun fetchFeedObservable(feedAlias: String): Observable<ArticlesPreviewModel> =
fetchArticles(feedAlias) fetchArticles(feedAlias)
override fun fetchFeedObservable(feedAlias: String,pageSize:Int, startIndex:Int) override fun fetchFeedObservable(feedAlias: String,pageSize:Int, startIndex:Int)
: Observable<ArticlesPreviewModel> = fetchArticles(feedAlias,pageSize,startIndex) : Observable<ArticlesPreviewModel> = fetchArticles(feedAlias,pageSize,startIndex)
...@@ -123,5 +125,9 @@ class FeedsContractModule @Inject constructor( ...@@ -123,5 +125,9 @@ class FeedsContractModule @Inject constructor(
arrayListOf(fetchArticleDb(articleId),fetchArticleApi(articleId)) arrayListOf(fetchArticleDb(articleId),fetchArticleApi(articleId))
).map { fromEntity(it,true) } ).map { fromEntity(it,true) }
override fun articleRead(articleId: Int): Completable =
db.setArticleReadState(articleId,true)
} }
package com.biganto.visual.roompark.data.repository.db package com.biganto.visual.roompark.data.repository.db
import com.biganto.visual.roompark.data.repository.db.requrey.model.* import com.biganto.visual.roompark.data.repository.db.requrey.model.*
import io.reactivex.Completable
import io.reactivex.Observable import io.reactivex.Observable
import io.reactivex.Single import io.reactivex.Single
import io.requery.Persistable import io.requery.Persistable
...@@ -31,4 +32,5 @@ interface IDb { ...@@ -31,4 +32,5 @@ interface IDb {
fun getEstate(estateId: Int): Observable<EstateEntity> fun getEstate(estateId: Int): Observable<EstateEntity>
fun upsertEstate(entity: EstateEntity) fun upsertEstate(entity: EstateEntity)
fun fetchEstateByNumber(building: Int, number: String): ReactiveResult<EstateEntity> fun fetchEstateByNumber(building: Int, number: String): ReactiveResult<EstateEntity>
fun setArticleReadState(id: Int, state: Boolean): Completable
} }
\ No newline at end of file
...@@ -157,4 +157,12 @@ class RequeryRepository @Inject constructor( ...@@ -157,4 +157,12 @@ class RequeryRepository @Inject constructor(
.where(EstateEntity.USER_ID.eq(uuid)) .where(EstateEntity.USER_ID.eq(uuid))
.and(EstateEntity.FAVORITE.eq(true)) .and(EstateEntity.FAVORITE.eq(true))
.get().observable() .get().observable()
override fun setArticleReadState(id:Int,state:Boolean) =
store.update(ArticleEntity::class)
.set(ArticleEntity.ANNOUNCE,"")
.where(ArticleEntity.ID.eq(id))
.get()
.single()
.ignoreElement()
} }
...@@ -27,4 +27,7 @@ interface Article : Persistable { ...@@ -27,4 +27,7 @@ interface Article : Persistable {
val feed : Feed? val feed : Feed?
@get:Convert(TitledPhotoListConverter::class) @get:Convert(TitledPhotoListConverter::class)
var photo : List<TitledPhoto>? var photo : List<TitledPhoto>?
val read : Boolean
} }
\ No newline at end of file
...@@ -25,4 +25,6 @@ interface Deal : Persistable { ...@@ -25,4 +25,6 @@ interface Deal : Persistable {
@get:ForeignKey(references = User::class ) @get:ForeignKey(references = User::class )
@get:ManyToOne(cascade = [CascadeAction.NONE]) @get:ManyToOne(cascade = [CascadeAction.NONE])
var user:User? var user:User?
val read : Boolean
} }
\ No newline at end of file
...@@ -3,6 +3,7 @@ package com.biganto.visual.roompark.domain.contract ...@@ -3,6 +3,7 @@ package com.biganto.visual.roompark.domain.contract
import com.biganto.visual.roompark.domain.model.ArticleModel import com.biganto.visual.roompark.domain.model.ArticleModel
import com.biganto.visual.roompark.domain.model.ArticlesPreviewModel import com.biganto.visual.roompark.domain.model.ArticlesPreviewModel
import com.biganto.visual.roompark.domain.model.FeedModel import com.biganto.visual.roompark.domain.model.FeedModel
import io.reactivex.Completable
import io.reactivex.Observable import io.reactivex.Observable
/** /**
...@@ -20,4 +21,5 @@ interface FeedsContract{ ...@@ -20,4 +21,5 @@ interface FeedsContract{
): Observable<ArticlesPreviewModel> ): Observable<ArticlesPreviewModel>
fun fetchFeedObservable(feedAlias: String): Observable<ArticlesPreviewModel> fun fetchFeedObservable(feedAlias: String): Observable<ArticlesPreviewModel>
fun articleRead(articleId:Int):Completable
} }
\ No newline at end of file
...@@ -21,4 +21,6 @@ class FeedUseCase @Inject constructor( ...@@ -21,4 +21,6 @@ class FeedUseCase @Inject constructor(
fun getArticle(articleId:Int) = fun getArticle(articleId:Int) =
contract.getArticle(articleId) contract.getArticle(articleId)
fun setRead(articleId: Int) = contract.articleRead(articleId)
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment