- Added models, DTOs, services, and routes for ports, including CRUD operations. - Introduced unit conversions with corresponding models, DTOs, services, and routes. - Developed units of measure with detailed models, DTOs, services, and routes for various types. - Ensured all new features are integrated with FastAPI and SQLAlchemy for seamless database interactions.
31 lines
1.0 KiB
Python
31 lines
1.0 KiB
Python
from datetime import datetime
|
|
|
|
from sqlalchemy import DateTime, ForeignKey, Integer
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
from sqlalchemy.sql import func
|
|
|
|
|
|
class TimestampMixin:
|
|
"""Mixin for common timestamp fields"""
|
|
|
|
created_at: Mapped[datetime] = mapped_column(
|
|
DateTime, nullable=False, default=func.now()
|
|
)
|
|
updated_at: Mapped[datetime] = mapped_column(
|
|
DateTime, nullable=False, default=func.now(), onupdate=func.now()
|
|
)
|
|
deleted_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
|
|
|
|
|
|
class TenantScopedMixin:
|
|
"""Mixin for tenant and company scoped entities"""
|
|
|
|
tenant_id: Mapped[int] = mapped_column(Integer, ForeignKey("a76.tenants.id"), nullable=False, index=True)
|
|
company_id: Mapped[int] = mapped_column(Integer, ForeignKey("a76.company.id"), nullable=False, index=True)
|
|
|
|
|
|
class PedimentoRelatedMixin(TenantScopedMixin):
|
|
"""Mixin for entities related to pedimentos"""
|
|
|
|
pedimento_id: Mapped[int] = mapped_column(Integer, nullable=False)
|