package com.tencent.liteav.demo.superplayer.database.entity

import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey

@Entity
data class CountDown(
    /**
     * 使用course id作为主键
     */
    @PrimaryKey
    val id: String,

    /**
     * 定时类型
     *
     * 1集数 2时长
     */
    @ColumnInfo(name = "type")
    val type: Int,

    /**
     * 定时的值
     *
     * 类型为集数时则表示多少集
     * 类型为时长是则表示多少秒
     */
    @ColumnInfo(name = "value")
    val value: Int,

    /**
     * 定时剩下的值
     *
     * 类型为集数时则表示多少集
     * 类型为时长是则表示多少秒
     */
    @ColumnInfo(name = "rest")
    val rest: Int,

    /**
     * 作为count down的唯一的特征
     */
    @ColumnInfo(name = "datetime")
    val datetime: String? = null,
) {
    fun copyWith(
        type: Int? = null,
        value: Int? = null,
        rest: Int? = null,
        datetime: String? = null,
    ): CountDown {
        return CountDown(
            id = this.id,
            type = type ?: this.type,
            value = value ?: this.value,
            rest = rest ?: this.rest,
            datetime = datetime ?: this.datetime,
        )
    }

    companion object {
        @JvmStatic
        public val TYPE_EPISODE = 1;

        @JvmStatic
        public val TYPE_DURATION = 2;
    }
}
