浏览代码

add api doc

maguohua 8 年之前
父节点
当前提交
7d4edf95be
共有 2 个文件被更改,包括 73 次插入2 次删除
  1. 71 0
      API.md
  2. 2 2
      controller/shopping/food.js

+ 71 - 0
API.md

@@ -21,6 +21,8 @@
 [11、餐馆详情](#11餐馆详情)<br/>
 [12、上传图片](#12上传图片)<br/>
 [13、添加餐馆](#13添加餐馆)<br/>
+[14、添加食品种类](#14添加食品种类)<br/>
+[15、添加食品](#15添加食品)<br/>
 
 
 
@@ -851,3 +853,72 @@ POST
   sussess: '添加餐馆成功',
 }
 ```
+
+### 14、添加食品种类
+
+#### 请求URL:
+```
+http://cangdu.org:8001/shopping/addcategory
+```
+
+#### 示例:
+
+
+#### 请求方式:
+```
+POST
+```
+
+#### 参数类型:query
+
+|参数|是否必选|类型|说明|
+|:-----|:-------:|:-----|:-----|
+|name      |Y       |string   | 种类 |
+|description      |Y       |string   | 描述 |
+|restaurant_id      |Y       |int   | 餐馆id |
+
+#### 返回示例:
+
+```javascript
+{
+  status: 1,
+  sussess: '添加食品种类成功',
+}
+```
+
+### 15、添加食品
+
+#### 请求URL:
+```
+http://cangdu.org:8001/shopping/addfood
+```
+
+#### 示例:
+
+
+#### 请求方式:
+```
+POST
+```
+
+#### 参数类型:query
+
+|参数|是否必选|类型|说明|
+|:-----|:-------:|:-----|:-----|
+|restaurant_id      |Y       |int   | 餐馆ID |
+|category_id      |Y       |int   | 分类ID |
+|name      |Y       |string   | 食品名称 |
+|image_path      |Y       |string   | 图片地址 |
+|specs      |Y       |array   | 规格: [{specs: '默认',packing_fee: 0,price: 20,}]|
+|description      |N       |string   |描述 |
+|activity      |N      |string   |活动 |
+|attributes      |N       |array   |特点:[{value: '新',label: '新品'}] |
+
+#### 返回示例:
+
+```javascript
+{
+  status: 1,
+  sussess: '添加食品成功',
+}
+```

+ 2 - 2
controller/shopping/food.js

@@ -102,7 +102,7 @@ class Food extends BaseComponent{
 				await newFood.save();
 				res.send({
 					status: 1,
-					message: '添加食品种类成功',
+					success: '添加食品种类成功',
 				})
 			}catch(err){
 				console.log('保存数据失败');
@@ -281,7 +281,7 @@ class Food extends BaseComponent{
 				await category.save();
 				res.send({
 					status: 1,
-					foodDetail: category,
+					success: '添加食品成功',
 				});
 			}catch(err){
 				console.log('保存食品到数据库失败', err);