package com.gh.gamecenter.entity

import android.os.Parcelable
import com.gh.gamecenter.feature.entity.*
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.Parcelize

@Parcelize
data class FollowDynamicEntity(
    @SerializedName("type")
    private val _type: String? = null,
    @SerializedName("libao")
    val libao: LibaoEntity? = null,
    @SerializedName("libao_exchange")
    val libaoExchange: LibaoEntity? = null,
    @SerializedName("game")
    private val _game: GameEntity? = null,
    @SerializedName("me")
    private val _me: MeEntity? = null,
    @SerializedName("time")
    private val _time: Long? = null,
    @SerializedName("article")
    val article: Article? = null,
    @SerializedName("user_post")
    val userPost: ArticleEntity? = null
) : Parcelable {

    val type: String
        get() = _type ?: ""

    val game: GameEntity
        get() = _game ?: GameEntity()

    val me: MeEntity
        get() = _me ?: MeEntity()

    val time: Long
        get() = _time ?: 0L

    companion object {

        const val FOLLOW_UPDATE_TYPE_LIBAO = "libao"
        const val FOLLOW_UPDATE_TYPE_LIBAO_EXCHANGE = "libao_exchange"
        const val FOLLOW_UPDATE_TYPE_ARTICLE = "article"
        const val FOLLOW_UPDATE_TYPE_USER_POST = "user_post"
    }

    @Parcelize
    data class Article(
        @SerializedName("_id")
        private val _id: String? = null,
        @SerializedName("title")
        private val _title: String? = null,
        @SerializedName("content")
        private val _content: String? = null,
        @SerializedName("img")
        private val _img: List<String>? = null,
        @SerializedName("count")
        private val _count: Count? = null,
        @SerializedName("game")
        private val _game: GameEntity? = null,
        @SerializedName("time")
        private val _time: Long? = null,
        @SerializedName("_seq")
        private val _shortId: String? = null
    ) : Parcelable {

        val id: String
            get() = _id ?: ""

        val title: String
            get() = _title ?: ""

        val content: String
            get() = _content ?: ""

        val img: List<String>
            get() = _img ?: listOf()

        val count: Count
            get() = _count ?: Count()

        val game: GameEntity
            get() = _game ?: GameEntity()

        val time: Long
            get() = _time ?: 0L

        val shortId: String
            get() = _shortId ?: ""

        @Parcelize
        data class Count(
            @SerializedName("comment")
            private val _comment: Int? = null
        ) : Parcelable {

            val comment: Int
                get() = _comment ?: 0
        }
    }

    @Parcelize
    data class LibaoExchange(
        @SerializedName("_id")
        private val _id: String? = null,
        @SerializedName("libao_id")
        private val _libaoId: String? = null,
        @SerializedName("libao_code")
        private val _libaoCode: String? = null,
        @SerializedName("name")
        private val _name: String? = null,
        @SerializedName("content")
        private val _content: String? = null,
        @SerializedName("active")
        private val _active: Boolean? = null
    ) : Parcelable {

        val id: String
            get() = _id ?: ""

        val libaoId: String
            get() = _libaoId ?: ""

        val libaoCode: String
            get() = _libaoCode ?: ""

        val name: String
            get() = _name ?: ""

        val content: String
            get() = _content ?: ""

        val active: Boolean
            get() = _active ?: false
    }
}