data model whew

This commit is contained in:
2025-04-19 13:56:58 -04:00
parent 03b43ce3ab
commit 6178fdd15d
19 changed files with 789 additions and 2099 deletions

View File

@ -1,13 +1,13 @@
from typing import List, Optional, Dict
from sqlalchemy.orm import Session
from app.models.inventory import Inventory
from app.models.tcgplayer_inventory import TCGPlayerInventory
from app.services.base_service import BaseService
class InventoryService(BaseService[Inventory]):
class InventoryService(BaseService[TCGPlayerInventory]):
def __init__(self):
super().__init__(Inventory)
super().__init__(TCGPlayerInventory)
def create(self, db: Session, obj_in: Dict) -> Inventory:
def create(self, db: Session, obj_in: Dict) -> TCGPlayerInventory:
"""
Create a new inventory item in the database.
@ -20,7 +20,7 @@ class InventoryService(BaseService[Inventory]):
"""
return super().create(db, obj_in)
def update(self, db: Session, db_obj: Inventory, obj_in: Dict) -> Inventory:
def update(self, db: Session, db_obj: TCGPlayerInventory, obj_in: Dict) -> TCGPlayerInventory:
"""
Update an existing inventory item in the database.
@ -34,7 +34,7 @@ class InventoryService(BaseService[Inventory]):
"""
return super().update(db, db_obj, obj_in)
def get_by_tcgplayer_id(self, db: Session, tcgplayer_id: str) -> Optional[Inventory]:
def get_by_tcgplayer_id(self, db: Session, tcgplayer_id: str) -> Optional[TCGPlayerInventory]:
"""
Get an inventory item by its TCGPlayer ID.
@ -43,11 +43,11 @@ class InventoryService(BaseService[Inventory]):
tcgplayer_id: The TCGPlayer ID to find
Returns:
Optional[Inventory]: The inventory item if found, None otherwise
Optional[TCGPlayerInventory]: The inventory item if found, None otherwise
"""
return db.query(self.model).filter(self.model.tcgplayer_id == tcgplayer_id).first()
def get_by_set(self, db: Session, set_name: str, skip: int = 0, limit: int = 100) -> List[Inventory]:
def get_by_set(self, db: Session, set_name: str, skip: int = 0, limit: int = 100) -> List[TCGPlayerInventory]:
"""
Get all inventory items from a specific set.
@ -58,6 +58,6 @@ class InventoryService(BaseService[Inventory]):
limit: Maximum number of records to return
Returns:
List[Inventory]: List of inventory items from the specified set
List[TCGPlayerInventory]: List of inventory items from the specified set
"""
return db.query(self.model).filter(self.model.set_name == set_name).offset(skip).limit(limit).all()