chore: 将后端移动到 api/ 目录,准备合并为单仓库

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
xuyueandClaude Opus 5.5 committed 2026-10-26 16:01:25 +08:00
1 parent e172ffc0b3
commit 0591eda56f
244 files changed

No files matched your search

+47
View File
@@ -0,0 +1,47 @@
import uuid
from django.db import models
from django_extensions.db.models import TimeStampedModel
from account.models import User
from task.models import Task
class Conversation(TimeStampedModel):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name="conversations")
task = models.ForeignKey(Task, on_delete=models.CASCADE, related_name="conversations")
is_active = models.BooleanField(default=True, verbose_name="是否活跃")
class Meta:
ordering = ("-created",)
def __str__(self):
return f"{self.user.username} - {self.task.title}"
class Message(models.Model):
conversation = models.ForeignKey(
Conversation, on_delete=models.CASCADE, related_name="messages"
)
role = models.CharField(max_length=10) # "user" or "assistant"
source = models.CharField(max_length=12, default="conversation") # "conversation" or "manual"
content = models.TextField()
code_html = models.TextField(null=True, blank=True)
code_css = models.TextField(null=True, blank=True)
code_js = models.TextField(null=True, blank=True)
created = models.DateTimeField(auto_now_add=True)
prompt_level = models.IntegerField(
null=True, blank=True, default=None, db_index=True, verbose_name="提示词层级"
)
submission = models.OneToOneField(
"submission.Submission",
null=True,
blank=True,
on_delete=models.CASCADE,
related_name="source_message",
)
class Meta:
ordering = ("created",)
def __str__(self):
return f"[{self.role}] {self.content[:50]}"