package cn.reghao.tnb.content.app.vod.model.po;

import cn.reghao.jutil.jdk.web.db.BaseObject;
import cn.reghao.tnb.message.api.dto.MediaProgress;
import lombok.*;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;

/**
 * 视频播放记录
 *
 * @author reghao
 * @date 2022-01-22 21:18:13
 */
@AllArgsConstructor
@NoArgsConstructor
@Setter
@Getter
public class PlayRecord extends BaseObject<Integer> {
    @NotNull
    private Long userId;
    @NotBlank
    private String videoId;
    @NotNull
    private Double currentTime;
    @NotNull
    // ms 时间戳
    private Long createAt;

    public PlayRecord(long userId, MediaProgress mediaProgress) {
        this.userId = userId;
        this.videoId = mediaProgress.getMediaId();
        this.currentTime = mediaProgress.getCurrentTime();
        this.createAt = System.currentTimeMillis();
    }
}
