mirror of
https://github.com/StepanovPlaton/torrent_backend.git
synced 2026-04-03 20:30:38 +04:00
Update database architecture. Add genres and actors
This commit is contained in:
@@ -1,4 +1,11 @@
|
||||
from .games import *
|
||||
from .game_genres import *
|
||||
|
||||
from .movies import *
|
||||
from .movie_genres import *
|
||||
from .movie_actors import *
|
||||
|
||||
from .audiobooks import *
|
||||
from .audiobook_genres import *
|
||||
|
||||
from .users import *
|
||||
|
||||
15
database/schemas/audiobook_genres.py
Normal file
15
database/schemas/audiobook_genres.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
|
||||
class AudiobookGenreBase(BaseModel):
|
||||
genre: str = Field(default=None, examples=["Боевик"])
|
||||
|
||||
|
||||
class AudiobookGenreCreate(AudiobookGenreBase):
|
||||
pass
|
||||
|
||||
|
||||
class AudiobookGenre(AudiobookGenreBase):
|
||||
id: int = Field(examples=[1])
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
@@ -1,6 +1,9 @@
|
||||
from typing import Optional
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
from .users import UserOpenData as User
|
||||
from .audiobook_genres import AudiobookGenre
|
||||
|
||||
|
||||
class AudiobookCardBase(BaseModel):
|
||||
title: str = Field(examples=["Марсианин"])
|
||||
@@ -39,13 +42,15 @@ class AudiobookBase(AudiobookCardBase):
|
||||
|
||||
|
||||
class AudiobookCreate(AudiobookBase):
|
||||
pass
|
||||
genres: Optional[list[int]] = Field(default=None, examples=[[1, 2]])
|
||||
|
||||
|
||||
class Audiobook(AudiobookBase):
|
||||
id: int = Field(examples=[1])
|
||||
update_date: str = Field(examples=["2024-06-14 12:00:00"])
|
||||
upload_date: str = Field(examples=["2024-06-14 12:00:00"])
|
||||
owner_id: int = Field(examples=[1])
|
||||
|
||||
genres: list[AudiobookGenre] = Field()
|
||||
|
||||
owner: User = Field()
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
16
database/schemas/game_genres.py
Normal file
16
database/schemas/game_genres.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from typing import Optional
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
|
||||
class GameGenreBase(BaseModel):
|
||||
genre: str = Field(default=None, examples=["Стратегия"])
|
||||
|
||||
|
||||
class GameGenreCreate(GameGenreBase):
|
||||
pass
|
||||
|
||||
|
||||
class GameGenre(GameGenreBase):
|
||||
id: int = Field(examples=[1])
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
@@ -1,6 +1,9 @@
|
||||
from typing import Optional
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
from .users import UserOpenData as User
|
||||
from .game_genres import GameGenre
|
||||
|
||||
|
||||
class GameCardBase(BaseModel):
|
||||
title: str = Field(examples=["DwarfFortress"])
|
||||
@@ -40,13 +43,15 @@ class GameBase(GameCardBase):
|
||||
|
||||
|
||||
class GameCreate(GameBase):
|
||||
pass
|
||||
genres: Optional[list[int]] = Field(default=None, examples=[[1, 2]])
|
||||
|
||||
|
||||
class Game(GameBase):
|
||||
id: int = Field(examples=[1])
|
||||
update_date: str = Field(examples=["2024-05-13 12:00:00"])
|
||||
upload_date: str = Field(examples=["2024-05-13 12:00:00"])
|
||||
owner_id: int = Field(examples=[1])
|
||||
|
||||
genres: list[GameGenre] = Field()
|
||||
|
||||
owner: User = Field()
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
15
database/schemas/movie_actors.py
Normal file
15
database/schemas/movie_actors.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
|
||||
class MovieActorBase(BaseModel):
|
||||
actor: str = Field(default=None, examples=["Мэттью Макконахи"])
|
||||
|
||||
|
||||
class MovieActorCreate(MovieActorBase):
|
||||
pass
|
||||
|
||||
|
||||
class MovieActor(MovieActorBase):
|
||||
id: int = Field(examples=[1])
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
15
database/schemas/movie_genres.py
Normal file
15
database/schemas/movie_genres.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
|
||||
class MovieGenreBase(BaseModel):
|
||||
genre: str = Field(default=None, examples=["Фантастика"])
|
||||
|
||||
|
||||
class MovieGenreCreate(MovieGenreBase):
|
||||
pass
|
||||
|
||||
|
||||
class MovieGenre(MovieGenreBase):
|
||||
id: int = Field(examples=[1])
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
@@ -1,6 +1,10 @@
|
||||
from typing import Optional
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
from .users import UserOpenData as User
|
||||
from .movie_genres import MovieGenre
|
||||
from .movie_actors import MovieActor
|
||||
|
||||
|
||||
class MovieCardBase(BaseModel):
|
||||
title: str = Field(examples=["Интерстеллар"])
|
||||
@@ -43,13 +47,17 @@ class MovieBase(MovieCardBase):
|
||||
|
||||
|
||||
class MovieCreate(MovieBase):
|
||||
pass
|
||||
genres: Optional[list[int]] = Field(default=None, examples=[[1, 2]])
|
||||
actors: Optional[list[int]] = Field(default=None, examples=[[1, 2]])
|
||||
|
||||
|
||||
class Movie(MovieBase):
|
||||
id: int = Field(examples=[1])
|
||||
update_date: str = Field(examples=["2024-06-11 12:00:00"])
|
||||
upload_date: str = Field(examples=["2024-06-11 12:00:00"])
|
||||
owner_id: int = Field(examples=[1])
|
||||
|
||||
genres: list[MovieGenre] = Field()
|
||||
actors: list[MovieActor] = Field()
|
||||
|
||||
owner: User = Field()
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
Reference in New Issue
Block a user