from django.urls import path, include
from rest_framework.routers import DefaultRouter
from . import views

# 创建路由器
router = DefaultRouter()
router.register(r'foods', views.FoodViewSet, basename='food')
router.register(r'user-foods', views.UserFoodViewSet, basename='userfood')
router.register(r'usage-logs', views.FoodUsageLogViewSet, basename='foodusagelog')

app_name = 'food_app'

urlpatterns = [
    # API路由 (直接包含router，不需要再加api/前缀)
    path('', include(router.urls)),
    
    # 额外的功能性URL
    path('use-food/', views.UseFoodView.as_view(), name='use-food'),
    path('my-foods/', views.MyFoodsView.as_view(), name='my-foods'),
    path('food-stats/', views.FoodStatsView.as_view(), name='food-stats'),
]