
- Created complete RESTful API for inventory management - Set up database models for items, categories, suppliers, and transactions - Implemented user authentication with JWT tokens - Added transaction tracking for inventory movements - Created comprehensive API endpoints for all CRUD operations - Set up Alembic for database migrations - Added input validation and error handling - Created detailed documentation in README
25 lines
755 B
Python
25 lines
755 B
Python
import uuid
|
|
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 create(self, db: Session, *, obj_in: CategoryCreate) -> Category:
|
|
db_obj = Category(
|
|
id=str(uuid.uuid4()),
|
|
name=obj_in.name,
|
|
description=obj_in.description,
|
|
)
|
|
db.add(db_obj)
|
|
db.commit()
|
|
db.refresh(db_obj)
|
|
return db_obj
|
|
|
|
def get_by_name(self, db: Session, *, name: str) -> Category:
|
|
return db.query(Category).filter(Category.name == name).first()
|
|
|
|
|
|
category = CRUDCategory(Category) |