Files
plantillas-proyectos/backend/api/v1/common/base_models.py
acazares 44eef08445 feat: Implement license and tenant management APIs
- Added endpoints for license management including creation, retrieval, update, validation, and usage tracking.
- Developed service layer for business logic related to licenses.
- Introduced tenant management APIs for creating, updating, listing, and deleting tenants.
- Implemented user-tenant relationship management with endpoints for adding, removing, and updating user roles in tenants.
- Created DTOs for data transfer between layers and models for ORM mapping.
- Enhanced logging and error handling across services.
2025-12-09 11:51:18 -06:00

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("core.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)