package com.gh.gamecenter.common.entity

import android.os.Parcelable
import androidx.annotation.Keep
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.Parcelize

@Keep
@Parcelize
data class ExposureEntity(
    @SerializedName("ad_id")
    var adId: String? = null, // 广告 id
    @SerializedName("game_id")
    val gameId: String? = "",
    @SerializedName("subject_id")
    val subjectId: String? = null, // 专题 id
    @SerializedName("carousel_id")
    val carouselId: String? = "", // 轮播图 id
    val gameName: String? = "",
    val gameVersion: String? = "",
    var sequence: Int? = 0,
    var outerSequence: Int? = 0,
    val platform: String? = null,
    var isMirrorData: Boolean = false,
    @SerializedName("is_mirror2_data")
    var isMirrorData2: Boolean = false,
    @SerializedName("is_web_download")
    var isWebDownload: Boolean = false,
    val downloadType: String? = null,
    val downloadCompleteType: String? = null,
    @SerializedName("display_type")
    val displayType: String? = "",
    @SerializedName("is_platform_recommend")
    val isPlatformRecommend: Boolean? = false,
    @SerializedName("mini_game_uid")
    val miniGameUid: String? = "",
    @SerializedName("mini_game_id")
    val miniGameId: String? = "",// 小游戏ID
    @SerializedName("mini_game_type")
    val miniGameType: String? = "",// 小游戏类型：QQ小游戏：qq 微信小游戏：wechat dsp 游戏：dsp_game
    @SerializedName("mini_game_recommend_id")
    var miniGameRecommendId: String? = null,
    var speed: Long = 0,
    var certification: Int? = null, // 0表示未实名，1表示未成年，2表示成年

    // 外层内容 id (包括)
    // 1.  "test_server_id" : "", // 开测表 ID
    // 2.  "block_id" : "", // 板块 ID
    // 3.  "category_id" : "", // 新分类1.0 ID
    // 4.  "category_v2_id" : "", // 新分类2.0 ID
    var containerId: String? = null,
    var containerType: String? = null,

    @SerializedName("test_server_id")
    var testServerId: String? = null,
    @SerializedName("block_id")
    var blockId: String? = null,
    @SerializedName("category_id")
    var categoryId: String? = null,
    @SerializedName("category_v2_id")
    var categoryV2Id: String? = null,
    @SerializedName("navigation_id")
    var navigationId: String? = null,

    // 专题详情的来源页面和来源 id
    @SerializedName("source_page")
    var sourcePage: String? = null,
    @SerializedName("source_page_id")
    var sourcePageId: String? = null,
    @SerializedName("source_page_name")
    var sourcePageName: String? = null,

    // 下载地址的 host 和 path
    var host: String? = null,
    var path: String? = null,

    // 统计启动弹窗相关数据用的 (ugly)
    @SerializedName("dialog_id")
    var welcomeDialogId: String? = null,
    @SerializedName("link_title")
    var welcomeDialogLinkTitle: String? = null,

    //v5.10 补充
    @SerializedName("control_type")
    var controlType: String? = null,
    @SerializedName("control_name")
    var controlName: String? = null,
    //跳转链接类型 如：游戏专题
    @SerializedName("control_link_type")
    var controlLinkType: String? = null,
    //跳转链接标题 如：热门好游
    @SerializedName("control_link_name")
    var controlLinkName: String? = null,
    //跳转链接ID
    @SerializedName("control_link_desc")
    var controlLinkDesc: String? = null,
    @SerializedName("is_ad_data")
    var isAdData: Boolean = false,
    var country: String = "",
    var province: String = "",
    var city: String = "",
    @SerializedName("ad_space_id")
    var adSpaceId: String = "", // 广告位ID
    @SerializedName("game_ad_source_id")
    var gameAdSourceId: String = "", // 广告源计划ID

    @SerializedName("url_list")
    var redirectedUrlList: String? = null,

    @SerializedName("show_url")
    var showUrl: String? = null, // DSP 广告的展示回调地址

    @SerializedName("download_url")
    var downloadUrl: String? = null, // DSP 广告的下载回调地址

    // 由于有一些埋点数据来源于上层，上层定义的实体这里无法引用，这里将上层额外的字段存在 additional 数组中
    var additional: Array<String>? = null,

    // 广告计划曝光字段补充 https://jira.shanqu.cc/browse/GHZSCY-7041

    // 页面层级
    @SerializedName("page_level")
    var pageLevel: String? = null,
    // 当前页面代码名称
    @SerializedName("current_page_code")
    val currentPageCode: String? = null,
    // 当前页面ID
    @SerializedName("current_page_id")
    val currentPageId: String? = null,
    // 组件类型
    @SerializedName("module_type")
    val moduleType: String? = null,
    // 组件样式
    @SerializedName("module_style")
    val moduleStyle: String? = null,
    // 组件名称
    @SerializedName("module_name")
    val moduleName: String? = null,
    // 组件ID
    @SerializedName("module_id")
    val moduleId: String? = null,
    // 搜索内容
    @SerializedName("search_content")
    var searchContent: String? = null,
    // 是否广告推荐位
    @SerializedName("is_ad")
    val isAd: Boolean = false,
    // 广告组ID
    @SerializedName("ad_group_id")
    val adGroupId: String? = null,
    // 后台设置的位置序号
    @SerializedName("backend_sequence")
    val backendSequence: Int = -1,

) : Parcelable {

    fun setContainerInfo(id: String?, type: String?) {
        when (type) {
            TEST_SERVER_ID -> testServerId = id
            BLOCK_ID -> blockId = id
            CATEGORY_ID -> categoryId = id
            CATEGORY_V2_ID -> categoryV2Id = id
            NAVIGATION_ID -> navigationId = id
        }

        containerId = null
        containerType = null
    }

    companion object {
        const val TEST_SERVER_ID = "test_server_id"
        const val BLOCK_ID = "block_id"
        const val CATEGORY_ID = "category_id"
        const val CATEGORY_V2_ID = "category_v2_id"
        const val NAVIGATION_ID = "navigation_id"
    }
}