Commit 241cf0ba authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

actualize raw models

parent 7fcc5468
...@@ -74,7 +74,6 @@ data class EstateRoomRaw( ...@@ -74,7 +74,6 @@ data class EstateRoomRaw(
) )
data class FeedRaw( data class FeedRaw(
val id:Int,
val alias:String, val alias:String,
val title:String val title:String
) )
...@@ -99,6 +98,8 @@ data class ArticleRaw( ...@@ -99,6 +98,8 @@ data class ArticleRaw(
val id : Int, val id : Int,
val published : Date, val published : Date,
val title : String, val title : String,
val announce: String,
val preview: String?,
val body : String, val body : String,
val feed_alias : String, val feed_alias : String,
val photo : List<NewsPhotoRaw>? val photo : List<NewsPhotoRaw>?
...@@ -156,4 +157,16 @@ data class AppVersionRaw( ...@@ -156,4 +157,16 @@ data class AppVersionRaw(
val message : String?, val message : String?,
val critical : Boolean, val critical : Boolean,
val errors : List<ErrorRaw>? val errors : List<ErrorRaw>?
)
data class WebCamRaw(
val id:Int,
val title:String,
val Streams:List<StreamRaw>
)
data class StreamRaw(
val res_name:String,
val hls:String,
val rtmp:String
) )
\ No newline at end of file
...@@ -22,7 +22,7 @@ interface Article : Persistable { ...@@ -22,7 +22,7 @@ interface Article : Persistable {
val preview : String? val preview : String?
@get:Nullable @get:Nullable
val body : String? val body : String?
@get:ForeignKey(references = Feed::class, referencedColumn = "id") @get:ForeignKey(references = Feed::class, referencedColumn = "alias")
@get:ManyToOne(cascade = [CascadeAction.NONE]) @get:ManyToOne(cascade = [CascadeAction.NONE])
val feed : Feed? val feed : Feed?
@get:Convert(TitledPhotoListConverter::class) @get:Convert(TitledPhotoListConverter::class)
......
...@@ -9,11 +9,9 @@ import io.requery.* ...@@ -9,11 +9,9 @@ import io.requery.*
@Entity @Entity
interface Feed : Persistable { interface Feed : Persistable {
@get:Key @get:Key
val id: Int
val title:String
val alias: String val alias: String
val title:String
@get:JunctionTable(name= "FeedArticlesRule") @get:JunctionTable(name= "FeedArticlesRule")
@get:OneToMany( cascade = [CascadeAction.DELETE]) @get:OneToMany( cascade = [CascadeAction.DELETE])
val articles:Set<Article>? val articles:Set<Article>?
......
...@@ -27,7 +27,6 @@ fun fromRaw(raw: AuthRaw) : UserEntity { ...@@ -27,7 +27,6 @@ fun fromRaw(raw: AuthRaw) : UserEntity {
fun fromRaw(raw:FeedRaw) : FeedEntity { fun fromRaw(raw:FeedRaw) : FeedEntity {
val entity = FeedEntity() val entity = FeedEntity()
entity.setId(raw.id)
entity.setTitle(raw.title) entity.setTitle(raw.title)
entity.setAlias(raw.alias) entity.setAlias(raw.alias)
return entity return entity
...@@ -36,9 +35,12 @@ fun fromRaw(raw:FeedRaw) : FeedEntity { ...@@ -36,9 +35,12 @@ fun fromRaw(raw:FeedRaw) : FeedEntity {
fun fromRaw(raw:ArticleRaw) : ArticleEntity { fun fromRaw(raw:ArticleRaw) : ArticleEntity {
val entity = ArticleEntity() val entity = ArticleEntity()
entity.setId(raw.id) entity.setId(raw.id)
entity.setPublished(raw.published)
entity.setTitle(raw.title) entity.setTitle(raw.title)
entity.setBody(raw.body) entity.setBody(raw.body)
entity.setPreview(raw.feed_alias) entity.setAnnounce(raw.announce)
entity.setPreview(raw.preview)
raw.photo?.let {entity.photo = fromRawList(it, ::fromRaw)}
val feed = FeedEntity() val feed = FeedEntity()
feed.setAlias(raw.feed_alias) feed.setAlias(raw.feed_alias)
entity.setFeed(feed) entity.setFeed(feed)
...@@ -47,7 +49,7 @@ fun fromRaw(raw:ArticleRaw) : ArticleEntity { ...@@ -47,7 +49,7 @@ fun fromRaw(raw:ArticleRaw) : ArticleEntity {
} }
fun fromRaw(raw:NewsArticleRaw,feedId:Int):ArticleEntity{ fun fromRaw(raw:NewsArticleRaw,feedAlias:String):ArticleEntity{
val entity = ArticleEntity() val entity = ArticleEntity()
entity.setId(raw.id) entity.setId(raw.id)
entity.setPreview(raw.preview) entity.setPreview(raw.preview)
...@@ -55,31 +57,12 @@ fun fromRaw(raw:NewsArticleRaw,feedId:Int):ArticleEntity{ ...@@ -55,31 +57,12 @@ fun fromRaw(raw:NewsArticleRaw,feedId:Int):ArticleEntity{
entity.setPublished(raw.published) entity.setPublished(raw.published)
entity.setTitle(raw.title) entity.setTitle(raw.title)
val feed = FeedEntity() val feed = FeedEntity()
feed.setId(feedId) feed.setAlias(feedAlias)
// feed.setAlias(feedAlias)
entity.setFeed(feed) entity.setFeed(feed)
return entity return entity
} }
fun fromRaw(raw:ArticleRaw,feedId: Int):ArticleEntity{
val entity = ArticleEntity()
entity.setId(raw.id)
entity.setPublished(raw.published)
entity.setTitle(raw.title)
entity.setBody(raw.body)
raw.photo?.let {
entity.photo = fromRawList(it,::fromRaw)
}
val feed = FeedEntity()
feed.setId(feedId)
// feed.setAlias(raw.feed_alias)
entity.setFeed(feed)
return entity
}
fun fromRaw(raw:NewsPhotoRaw):TitledPhoto{ fun fromRaw(raw:NewsPhotoRaw):TitledPhoto{
return TitledPhoto(raw.title,raw.url) return TitledPhoto(raw.title,raw.url)
} }
...@@ -99,7 +82,7 @@ fun fromRaw(raw:ImageAlbumRaw) : ImageAlbumEntity { ...@@ -99,7 +82,7 @@ fun fromRaw(raw:ImageAlbumRaw) : ImageAlbumEntity {
fun <E,M> fromRawList(raw: List<E>,block:(E)->M):List<M> = List(raw.size) { index-> block(raw[index]) } fun <E,M> fromRawList(raw: List<E>,block:(E)->M):List<M> = List(raw.size) { index-> block(raw[index]) }
fun fromRaw(raw: List<NewsArticleRaw>,feedId:Int):List<ArticleEntity> = fun fromRaw(raw: List<NewsArticleRaw>,feedAlias:String):List<ArticleEntity> =
List(raw.size) { index-> fromRaw(raw[index],feedId) } List(raw.size) { index-> fromRaw(raw[index],feedAlias) }
val calcTargetResolution = max(display.widthPixels,display.heightPixels) val calcTargetResolution = max(display.widthPixels,display.heightPixels)
...@@ -21,7 +21,7 @@ const val ESTATES_CACHE_LIMIT_SECONDS_INACTIVE = 200L ...@@ -21,7 +21,7 @@ const val ESTATES_CACHE_LIMIT_SECONDS_INACTIVE = 200L
const val FILES_CACHE_LIMIT_SIZE = 10000 const val FILES_CACHE_LIMIT_SIZE = 10000
const val FILES_CACHE_LIMIT_SECONDS_INACTIVE = 60L const val FILES_CACHE_LIMIT_SECONDS_INACTIVE = 60L
const val DATABASE_VERSION = 7 const val DATABASE_VERSION = 8
@Module @Module
abstract class AppModule{ abstract class AppModule{
......
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