Automated Action d340d37ac9 Create Small Business Inventory Management System API
- 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
2025-05-23 11:56:20 +00:00

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)