package com.gh.gamecenter.entity

import android.os.Parcelable
import com.gh.gamecenter.common.entity.LinkEntity
import com.gh.gamecenter.feature.entity.MeEntity
import com.gh.gamecenter.feature.entity.SimpleGame
import com.gh.gamecenter.feature.entity.UserEntity
import com.gh.gamecenter.feature.entity.ZoneEntity
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.Parcelize

class ForumDetailEntity(
    @SerializedName("_id")
    var id: String = "",
    var game: SimpleGame = SimpleGame(),
    var background: String = "",
    var name: String = "",
    var icon: String = "",
    var moderator: ArrayList<UserEntity> = arrayListOf(),
    @SerializedName("top")
    var topLink: ArrayList<TopLinkEntity> = arrayListOf(),
    @SerializedName("zone_tab")
    var zone: ZoneEntity? = null,
    var me: MeEntity = MeEntity(),
    var type: String = "", //game_bbs/official_bbs
    var hot: Int = 0, // 热度值
    @SerializedName("hot_rank")
    var hotRank: Int = 0, // 热度排名
    @SerializedName("background_layer_color")
    var backgroundLayerColor: String = "" // 背景图色值
) {

    class TopLinkEntity(
        var category: CategoryEntity? = null
    ) : LinkEntity()

    class CategoryEntity(
        @SerializedName("_id")
        var id: String = "",
        var title: String = "",
        var style: Style = Style()
    )

    class Style(
        var color: String = "",
        @SerializedName("font_color")
        var fontColor: String = ""
    )

    @Parcelize
    class Section(
        @SerializedName("_id")
        var id: String = "",
        var name: String = "",
        var permissions: String = "",
        var icon: String = "",
        @SerializedName("icon_type")
        var iconType: String = ""
    ) : Parcelable

    fun convertForumDetailEntityToForumEntity(): ForumEntity {
        val forumEntity = ForumEntity()
        forumEntity.id = id
        forumEntity.name = name
        forumEntity.icon = icon
        forumEntity.game = game
        forumEntity.orderTag = System.currentTimeMillis()
        forumEntity.unread = false
        forumEntity.type = type
        return forumEntity
    }
}