37 lines
1.0 KiB
Python
37 lines
1.0 KiB
Python
from fastapi import APIRouter
|
|
|
|
from backend.app.schemas.common import success_payload
|
|
from backend.app.services.product_service import product_service
|
|
|
|
router = APIRouter(tags=["products"])
|
|
|
|
|
|
@router.get("/api/product-categories")
|
|
def list_categories() -> dict:
|
|
return success_payload(product_service.list_categories())
|
|
|
|
|
|
@router.post("/api/product-categories")
|
|
def create_category() -> dict:
|
|
return success_payload(product_service.create_category())
|
|
|
|
|
|
@router.put("/api/product-categories/{category_id}")
|
|
def update_category(category_id: int) -> dict:
|
|
return success_payload(product_service.update_category(category_id))
|
|
|
|
|
|
@router.get("/api/products")
|
|
def list_products() -> dict:
|
|
return success_payload(product_service.list_products())
|
|
|
|
|
|
@router.post("/api/products")
|
|
def create_product() -> dict:
|
|
return success_payload(product_service.create_product())
|
|
|
|
|
|
@router.get("/api/products/{product_id}")
|
|
def get_product(product_id: int) -> dict:
|
|
return success_payload(product_service.get_product(product_id))
|