-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschemas.py
57 lines (44 loc) · 1.06 KB
/
schemas.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from pydantic import BaseModel
from typing import List, Optional
import enum
class LanguageTypeEnum(str, enum.Enum):
Korean = "Korean"
Foreign = "Foreign"
Both = "Both"
class LyricBase(BaseModel):
timestamp: str
lyrics: str
class LyricCreate(LyricBase):
pass
class Lyric(LyricBase):
id: int
song_id: int
translated: Optional[str] = None
class Config:
from_attributes = True
class TranslatedLyricBase(BaseModel):
timestamp: str
original: str
translated: str
class TranslatedLyricCreate(TranslatedLyricBase):
pass
class TranslatedLyric(TranslatedLyricBase):
id: int
song_id: int
class Config:
from_attributes = True
class SongBase(BaseModel):
title: str
artist: Optional[str] = None
nickname: str
language_type: LanguageTypeEnum
album: Optional[str] = None
likes: int = 0
dislikes: int = 0
class SongCreate(SongBase):
lyrics: List[LyricCreate]
class Song(SongBase):
song_id: int
lyrics: List[Lyric] = []
class Config:
from_attributes = True