package com.gh.gamecenter.qa.entity

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

/**
 * Created by khy on 18/12/17.
 */

@Parcelize
class QuestionsDetailEntity(
    @SerializedName("_id")
    var id: String? = null,
    var tags: List<String> = ArrayList(),
    var title: String? = null,
    @SerializedName("description", alternate = ["content"])
    var description: String? = null,
    @SerializedName("related_question")
    var relatedQuestion: RelatedQuestion? = null,
    var images: List<String> = ArrayList(),
    @Deprecated("废弃")
    @SerializedName("answer_count")
    var answersCount: Int = 0,
    @SerializedName("answer_fold")
    var isAnswerFold: Boolean = false,
    @SerializedName("bbs")
    var community: CommunityEntity = CommunityEntity(),
    var isExistDrafts: Boolean = false,
    var videos: List<CommunityVideoEntity> = ArrayList(),
    var me: MeEntity = MeEntity(),
    @SerializedName("follow_count")
    private var followCount: Int = 0,
    var user: UserEntity = UserEntity(),
    @SerializedName("game_id")
    var gameId: String = "",
    @SerializedName("tag_activity_id")
    var tagActivityId: String = "",
    @SerializedName("tag_activity_name")
    var tagActivityName: String = "",
    var type: String = "",
    @SerializedName("game")
    var gameEntity: GameEntity? = null,
    var time: TimeEntity = TimeEntity(),
    var count: Count = Count(),
    var status: String = "pass",//pass通过，fail未通过，pending审核中
    var finish: Boolean = false,
    //提交问题用
    @SerializedName("draft_id")
    var draftId: String = "",
    @SerializedName("images_info")
    var imagesInfo: List<ImageInfo> = ArrayList(),
    val source: SourceEntity? = null,
    @SerializedName("activity_tag")
    val activityTag: ActivityTagEntity? = null,
    var sections: List<SectionEntity> = ArrayList()
) : Parcelable {

    fun getFollowCount(): Int {
        return if (followCount == 0) 1 else {
            followCount
        }
    }

    fun setFollowCount(count: Int) {
        this.followCount = count
    }

    @Parcelize
    class RelatedQuestion(
        @SerializedName("_id")
        var id: String? = "",
        var title: String? = "",
        @SerializedName("answer_count")
        var answerCount: Int? = 0
    ) : Parcelable

}