from django.db import models
from ec_user.models import EcUser
# Create your models here.

class Papers(models.Model):
    STATUS_CHOICES = (
        ('C', '任务创建'),
        ('P', '生成中'),
        ('D', '已完成')
    )
    uuid = models.CharField(max_length=100)  # 试卷的唯一标识符
    # 定义一个与EcUser一对多关联的外键
    user = models.ForeignKey(EcUser, on_delete=models.CASCADE)  # 当EcUser被删除时，关联的Papers也会被删除
    status = models.CharField(max_length=1, choices=STATUS_CHOICES, default='C')  # 默认值设置为'C'
    created_at = models.DateTimeField(auto_now_add=True,null=True, blank=True)  # 创建时间
    updated_at = models.DateTimeField(auto_now=True,null=True, blank=True)  # 更新时间
    
    def __str__(self):
        return self.user.name + '的试卷'

class OpenAIDiagnose(models.Model):
    STATUS_CHOICES = (
        ('C', '任务创建'),
        ('P', '生成中'),
        ('D', '已完成')
    )
    DIAGNOSE_TYPE = (
        ('M', '大模型试卷诊断'), # big model
        ('S', '学校试卷诊断'),   # school
        ('H', '作业诊断'),       # homework
        ('N', '课堂笔记诊断')    # notebook
    )
    uuid = models.CharField(max_length=100)  # 一次分析唯一标识符
    # 定义一个与EcUser一对多关联的外键
    user = models.ForeignKey(EcUser, on_delete=models.CASCADE)  # 当EcUser被删除时，关联的Papers也会被删除
    status = models.CharField(max_length=1, choices=STATUS_CHOICES, default='C')  # 默认值设置为'C'
    created_at = models.DateTimeField(auto_now_add=True,null=True, blank=True)  # 创建时间
    updated_at = models.DateTimeField(auto_now=True,null=True, blank=True)  # 更新时间
    diagnose_type = models.CharField(max_length=1, choices=DIAGNOSE_TYPE, default='M')  # 默认值设置为'M'

    def __str__(self):
        return self.user.name + '的诊断'