Some checks failed
Build and Deploy Backend / build-and-deploy (push) Failing after 1m36s
48 lines
1.5 KiB
Python
48 lines
1.5 KiB
Python
"""
|
|
音乐模块模型
|
|
"""
|
|
from django.db import models
|
|
from apps.users.models import User
|
|
|
|
|
|
class Track(models.Model):
|
|
"""音乐曲目"""
|
|
|
|
MOOD_CHOICES = [
|
|
('happy', '开心'),
|
|
('sad', '悲伤'),
|
|
('calm', '平静'),
|
|
('energetic', '活力'),
|
|
('romantic', '浪漫'),
|
|
]
|
|
|
|
user = models.ForeignKey(
|
|
User, on_delete=models.CASCADE,
|
|
related_name='tracks', verbose_name='用户'
|
|
)
|
|
title = models.CharField('标题', max_length=200)
|
|
lyrics = models.TextField('歌词', blank=True, default='')
|
|
audio_url = models.URLField('音频URL', max_length=500, blank=True, default='')
|
|
cover_url = models.URLField('封面URL', max_length=500, blank=True, default='')
|
|
mood = models.CharField(
|
|
'情绪标签', max_length=20,
|
|
choices=MOOD_CHOICES, null=True, blank=True
|
|
)
|
|
duration = models.IntegerField('时长(秒)', default=0)
|
|
prompt = models.TextField('生成提示词', blank=True, default='')
|
|
is_favorite = models.BooleanField('是否收藏', default=False)
|
|
created_at = models.DateTimeField('创建时间', auto_now_add=True)
|
|
updated_at = models.DateTimeField('更新时间', auto_now=True)
|
|
|
|
class Meta:
|
|
db_table = 'track'
|
|
verbose_name = '音乐曲目'
|
|
verbose_name_plural = verbose_name
|
|
ordering = ['-created_at']
|
|
indexes = [
|
|
models.Index(fields=['user', 'is_favorite']),
|
|
]
|
|
|
|
def __str__(self):
|
|
return self.title
|