31 lines
966 B
Python
31 lines
966 B
Python
import uuid
|
|
|
|
from datetime import datetime
|
|
from typing import TYPE_CHECKING
|
|
|
|
from sqlalchemy import DateTime, ForeignKey, Uuid
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
|
|
from ..db.base_class import reg
|
|
|
|
|
|
if TYPE_CHECKING:
|
|
from .employee import Employee
|
|
|
|
|
|
@reg.mapped_as_dataclass(unsafe_hash=True)
|
|
class Fingerprint:
|
|
__tablename__ = "fingerprints"
|
|
|
|
id: Mapped[uuid.UUID] = mapped_column(Uuid, primary_key=True, insert_default=uuid.uuid4)
|
|
employee_id: Mapped[uuid.UUID] = mapped_column(Uuid, ForeignKey("employees.id"), nullable=False)
|
|
date_: Mapped[datetime] = mapped_column("date", DateTime, nullable=False)
|
|
|
|
employee: Mapped["Employee"] = relationship("Employee", back_populates="fingerprints")
|
|
|
|
def __init__(self, employee_id: uuid.UUID, date_: datetime, id_: uuid.UUID | None = None) -> None:
|
|
self.employee_id = employee_id
|
|
self.date_ = date_
|
|
if id_ is not None:
|
|
self.id = id_
|