菜品 API
菜品 API 允许您为餐厅创建、读取、更新和删除菜品。所有端点都需要身份验证,并且只操作已验证用户所属餐厅的菜品。
GET /api/menu-items
获取您餐厅的所有菜品。
身份验证:必需(Bearer 令牌)
响应(200 OK)
{
"success": true,
"data": [
{
"id": "uuid",
"name": "Margherita Pizza",
"description": "Classic pizza with fresh mozzarella and basil",
"price": 14.99,
"priceCents": 1499,
"category": "Mains",
"photoUrl": "https://...",
"isActive": true,
"position": 1,
"createdAt": "2026-02-01T12:00:00Z",
"updatedAt": "2026-02-01T12:00:00Z"
}
]
}
POST /api/menu-items
创建新菜品。照片应通过上传端点单独上传,然后通过 URL 引用。
身份验证:必需(Bearer 令牌)
请求体
{
"name": "Chicken Tikka Masala",
"description": "Tender chicken in a rich, creamy tomato sauce",
"price": 16.99,
"category": "Mains",
"photoUrl": "https://..."
}
响应(201 Created)
{
"success": true,
"data": {
"id": "uuid",
"name": "Chicken Tikka Masala",
...
}
}
PATCH /api/menu-items/[id]
更新现有菜品。只需包含您要更改的字段。
身份验证:必需(Bearer 令牌)
请求体
{
"price": 17.99,
"description": "Updated description"
}
响应(200 OK)
{
"success": true,
"data": {
"id": "uuid",
"price": 17.99,
...
}
}
DELETE /api/menu-items/[id]
永久删除菜品及其关联的照片和 3D 模型。
身份验证:必需(Bearer 令牌)
响应(200 OK)
{
"success": true,
"data": { "deleted": true }
}