
- Set up project structure with FastAPI and SQLite - Create database models for inventory management - Set up SQLAlchemy and Alembic for database migrations - Create initial database migrations - Implement CRUD operations for products, categories, suppliers - Implement stock movement tracking and inventory management - Add authentication and user management - Add API endpoints for all entities - Add health check endpoint - Update README with project information and usage instructions
20 lines
759 B
Python
20 lines
759 B
Python
from typing import List, Optional
|
|
from sqlalchemy.orm import Session
|
|
|
|
from app.crud.base import CRUDBase
|
|
from app.models.category import Category
|
|
from app.schemas.category import CategoryCreate, CategoryUpdate
|
|
|
|
|
|
class CRUDCategory(CRUDBase[Category, CategoryCreate, CategoryUpdate]):
|
|
def get_by_name(self, db: Session, *, name: str) -> Optional[Category]:
|
|
return db.query(Category).filter(Category.name == name).first()
|
|
|
|
def search(self, db: Session, *, query: str, skip: int = 0, limit: int = 100) -> List[Category]:
|
|
return db.query(Category).filter(
|
|
Category.name.ilike(f"%{query}%") |
|
|
Category.description.ilike(f"%{query}%")
|
|
).offset(skip).limit(limit).all()
|
|
|
|
|
|
category = CRUDCategory(Category) |