package com.gh.gamecenter.entity

import com.gh.gamecenter.common.entity.CommunityEntity
import com.gh.gamecenter.common.entity.Display
import com.gh.gamecenter.common.entity.LinkEntity
import com.gh.gamecenter.feature.exposure.ExposureEvent
import com.google.gson.annotations.SerializedName

data class HomeRecommend(
    @SerializedName("link_type")
    val linkType: String = "",
    @SerializedName("link_id")
    val linkId: String = "",
    @SerializedName("link_text")
    val linkText: String = "",
    val icon: String = "",
    val name: String = "",
    val display: Display = Display(),
    @SerializedName("image")
    private val _image: String? = null,
    @SerializedName("link_community")
    private val community: CommunityEntity? = null,
    @SerializedName("guide")
    private val _guide: Guide? = null,
    // 绑定的曝光实体
    var exposureEvent: ExposureEvent? = null,
) {

    val image: String
        get() = _image ?: ""

    val isShowGuide: Boolean
        get() = _guide != null

    val guide: Guide
        get() = _guide ?: Guide()

    fun transformLinkEntity(): LinkEntity {
        return LinkEntity(
            name = name,
            type = linkType,
            display = display,
            link = linkId,
            text = linkText,
            community = community
        )
    }

    data class Guide(
        @SerializedName("text")
        private val _text: String? = null
    ) {
        val text: String
            get() = _text ?: ""
    }
}