from django.db import models
from utils.model import BaseModel
from apps.system.models import User, CommonAModel, Dict
# Create your models here.

class Video(CommonAModel):

    name = models.CharField(verbose_name='视频名称', max_length=100)
    category = models.ForeignKey(Dict, verbose_name='视频分类', on_delete=models.DO_NOTHING)
    description = models.TextField(verbose_name='视频描述', default='')
    fileid = models.CharField(verbose_name='云点播视频id', unique=True, max_length=200)
    mediaurl = models.CharField(verbose_name='视频地址', max_length=200)
    coverurl = models.CharField(verbose_name='封面地址', max_length=200)
    duration = models.IntegerField(verbose_name='时长(秒)', default=0)
    views = models.IntegerField(verbose_name='观看次数', default=0)
    viewsp = models.IntegerField(verbose_name='观看人数', default=0)

    class Meta:
        verbose_name = '点播视频'
        verbose_name_plural = verbose_name


    

class ViewRecord(BaseModel):

    # 观看记录
    user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name='观看人', related_name='viewrecord_user')
    views = models.IntegerField(verbose_name='观看次数', default=0)
    current = models.IntegerField(verbose_name='当前观看进度(秒)', default=0)
    video = models.ForeignKey(Video, verbose_name='点播视频', on_delete=models.CASCADE)


    class Meta:
        verbose_name = '点播观看记录'
        verbose_name_plural = verbose_name

