package com.gh.gamecenter.common.entity

import com.google.gson.annotations.SerializedName

class ErrorEntity(
    var code: Int? = 0,
    var detail: String? = "",
    var toast: String? = "",
    var data: Data? = null
) {
    class Data(
        @SerializedName("always_block")
        var alwaysBlock: Boolean? = false,
        @SerializedName("game_id")
        var gameId: String = "",
        @SerializedName("game_name")
        var gameName: String = "",
        var nickname: String = "",

        // post question
        @SerializedName("question_id")
        var questionId: String = "",
        @SerializedName("question_title")
        var questionTitle: String = "",
        @SerializedName("answer_count")
        var answerCount: Int = 0,
        @SerializedName("follow_count")
        private var followCount: Int = 0,
        val content: String = "",
        val title: String = "",
        val type: String = "",
        val link: String = "",
        val text: String = "",
        @SerializedName("link_community", alternate = ["community"])
        var community: CommunityEntity? = CommunityEntity()
    ) {
        // 问题关注数默认是1
        fun getFollowCount(): Int {
            if (followCount > 0) return followCount
            return 1
        }

        fun toLinkEntity(): LinkEntity {
            return LinkEntity(
                title = title,
                link = link,
                type = type,
                text = text,
                community = community
            )
        }
    }
}