/
aazenchenko
/
clone
Обзор
Документация
Войти
/
aazenchenko
/
clone
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
core/domain/entity.py
34 строки
623 B
GeorgeSt5
Changes in modules, entities, value objects, session in repo init
09 окт 2024, 14:10
09 окт 2024, 14:10
02edf15
Код
Авторство
О чём код?
from typing import Any, TypeVar import uuid EntityType = TypeVar('EntityType', bound='Entity') class GenericUUID(uuid.UUID): @classmethod def generate_id(cls): return cls(int=uuid.uuid4().int) EntityId = TypeVar("EntityId", bound=GenericUUID) class Entity: """ Base Entity class """ def __init__(self): self.id: EntityId = GenericUUID.generate_id() def __eq__(self, other: Any) -> bool: if isinstance(other, type(self)): return self.id == other.id return False class AggregateRoot: """ An entry point of aggregate. """ pass