Skip to content

Commit

Permalink
Сreate base classes (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
PavelErsh authored Mar 18, 2024
1 parent eb990b0 commit 589ed8a
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 6 deletions.
23 changes: 22 additions & 1 deletion async_api/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions async_api/src/models/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from pydantic import BaseModel


class UUIDBase(BaseModel):
"""Модель для базового класса."""

id: str
41 changes: 36 additions & 5 deletions async_api/src/models/film.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,41 @@
from pydantic import BaseModel
from dataclasses import dataclass

from models.base import UUIDBase
from models.genre import Genre
from models.person import Person


@dataclass
class FilmWork(UUIDBase):
"""Модель для хранения информации о фильме."""

title: str
imdb_rating: float
description: str
genre: list[Genre]
actors: list[Person]
writers: list[Person]
directors: list[Person]


class FilmMinimal(UUIDBase):
"""Модель для хранения краткой информации о фильме."""

class Film(BaseModel):
id: str
title: str
imdb_rating: float
description: str
writers: list[Person]
directors: list[Person]


class FilmShort(UUIDBase):
"""Модель для хранения краткой информации о фильме на главной странице."""

title: str
imdb_rating: float


class FilmWorkMinimal(UUIDBase):
"""Модель для хранения краткой информации о кинопроизведении."""

class Config:
pass
roles: list[str]
14 changes: 14 additions & 0 deletions async_api/src/models/genre.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from models.base import UUIDBase


class Genre(UUIDBase):
"""Модель для хранения информации жанре в кинопроизведении."""

name: str
description: str


class GenreMinimal(UUIDBase):
"""Модель для хранения краткой информации о жанре."""

name: str
10 changes: 10 additions & 0 deletions async_api/src/models/person.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from models.base import UUIDBase
from models.film import FilmWorkMinimal
from pydantic import Field


class Person(UUIDBase):
"""Модель для хранения актёра."""

full_name: str = Field(alias="name")
films: list[FilmWorkMinimal]

0 comments on commit 589ed8a

Please sign in to comment.