package com.gh.gamecenter.feature.entity

import android.os.Parcelable
import com.gh.gamecenter.common.annotation.SyncPage
import com.gh.gamecenter.common.syncpage.SyncFieldConstants
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.Parcelize

@Parcelize
data class CommentEntity(
    @SerializedName("_id")
    var id: String? = null,
    var user: UserEntity = UserEntity(),
    var parent: ArticleCommentParent? = null,
    @SerializedName("parent_user")
    var parentUser: CommentParentEntity? = null,
    var content: String? = null,
    @SyncPage(syncNames = [SyncFieldConstants.ARTICLE_COMMENT_VOTE_COUNT])
    var vote: Int = 0,
    @SyncPage(syncNames = [SyncFieldConstants.ARTICLE_COMMENT_REPLY_COUNT])
    var reply: Int = 0,
    var time: Long = 0,
    var priority: Int = 0,
    @SerializedName("me")
    var me: MeEntity? = null,
    @SerializedName("is_top")
    var isTop: Boolean = false,//是否置顶
    var type: String = "comment",//comment/answer，区分问题评论旧数据，answer表示旧数据(回答)
    var accept: Boolean = false,//是否采纳，问题评论用
    var choiceness: Boolean = false,//是否已加精，问题评论用
    var images: ArrayList<String>? = arrayListOf(),
    val source: SourceEntity? = null,

    // 楼层
    var floor: Int = 0,
    var isExpand: Boolean = false,
    @SerializedName("attached") // 楼中楼
    var subCommentList: ArrayList<CommentEntity>? = null,
    var isHighlight: Boolean = false, // 是否高亮处理
    var isForceExpand: Boolean = false // 是否强制展开，即显示时就是展开状态
) : Parcelable {

    fun clone(): CommentEntity {
        return CommentEntity(
            id,
            user,
            parent,
            parentUser,
            content,
            vote,
            reply,
            time,
            priority,
            me,
            isTop,
            type,
            accept,
            choiceness,
            images,
            source,
            floor,
            isExpand,
            subCommentList
        )
    }

    companion object {
        const val TAG = "CommentEntity"
    }
}
