order and api and more

This commit is contained in:
2025-04-17 00:09:16 -04:00
parent 593e8960b7
commit 21408af48c
31 changed files with 1924 additions and 542 deletions

View File

@ -1,15 +1,12 @@
from typing import Type, TypeVar, Generic, List, Optional, Any
from sqlalchemy.orm import Session
from app.db.database import Base
from app.services.service_registry import ServiceRegistry
T = TypeVar('T')
class BaseService(Generic[T]):
def __init__(self, model: Type[T]):
self.model = model
# Register the service instance
ServiceRegistry.register(self.__class__.__name__, self)
def get(self, db: Session, id: int) -> Optional[T]:
return db.query(self.model).filter(self.model.id == id).first()
@ -39,7 +36,4 @@ class BaseService(Generic[T]):
db.delete(obj)
db.commit()
return True
return False
def get_service(self, service_name: str) -> Any:
return ServiceRegistry.get(service_name)
return False