-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapiary.apib
More file actions
514 lines (373 loc) · 10.2 KB
/
apiary.apib
File metadata and controls
514 lines (373 loc) · 10.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
FORMAT: 1A
HOST: https://bobwu.cn/api/
# ChickenDinner8
Eat点点扫码点餐系统
## 商家账户信息管理 [/boss/user]
商家账号有关的一些操作
### 注册新用户 [POST]
+ Request (application/json)
{
"username": "username",
"password": "password"
}
+ Response 200 (application/json)
注册成功
+ Body
{
"msg": "注册成功"
}
+ Response 409 (application/json)
注册失败,可能是用户名已存在
+ Body
{
"msg": "注册失败"
}
### 获取用户信息 [GET]
获取当前登陆用户的个人信息,若未登陆则会提示
+ Response 200 (application/json)
获取成功
+ Body
{
"username":"username"
}
+ Response 401 (application/json)
未登录
+ Body
{
"msg": "未登录"
}
### 修改用户信息 [PUT]
更新传入的用户属性(不能修改密码),返回某一用户的全部属性
+ Request (application/json)
{
"username": "username",
"password": "password"
}
+ Response 200 (application/json)
{
"username": "username"
}
## 商家账户登陆态管理 [/boss/session]
所有商家端操作都要以登录成功为前提,否则操作会失败且返回未登录信息
### 登录 [POST]
新建一个登录态
+ Request (application/json)
{
"username": "username",
"password": "password"
}
+ Response 200 (application/json)
+ Body
{
"msg": "登陆成功"
}
+ Response 401 (application/json)
+ Body
{
"msg": "账号或者密码错误"
}
{
"msg": "当前用户不存在"
}
### 登出 [DELETE]
结束登录态
+ Response 200 (application/json)
+ Body
{
"msg": "登出成功"
}
## 所有餐厅 [/restaurants]
### 查看旗下所有餐厅的信息 [GET]
+ Response 200 (application/json)
+ Body
{
"restaurants":[
{
"id":"id",
"name":"name",
"location":"location",
"description":"xxxx"
},
{
"id":"id",
"name":"name",
"location":"location",
"description":"xxxx"
}
]
}
## 某一餐厅 [/restaurant/:{restaurantId}]
### 查看某一餐厅的信息 [GET]
+ Response 200 (application/json)
+ Body
{
"id":"id",
"name":"name",
"location":"location",
"description":"xxxx"
}
### 创建一个餐厅 [POST]
+ Request (application/json)
+ Body
{
"name": "kfc",
"description": "fastfood",
"location":"location"
}
+ Response 201 (application/json)
创建成功
+ Body
{
"id":"id",
"name":"name",
"location":"location",
"description":"xxxx"
}
### 修改餐厅信息 [PUT]
+ Request (application/json)
{
"name": "kfc",
"description": "fastfood"
}
+ Response 200 (application/json)
修改成功,返回餐厅的所有属性
+ Body
{
"id":"id",
"name": "kfc",
"description": "fastfood"
}
## 餐厅菜单 [/menu/:{restaurantId}]
### 查看菜单 [GET]
+ Response 200 (application/json)
+ Body
{
foods:[
{},
{},
{}
]
}
## 菜单上的菜品 [/food/:restaurantId/:foodId/]
### 获取某一菜品的信息 [GET]
某一餐厅的某一菜品的信息
+ Response 200 (application/json)
返回一个food 对象
+ Body
{
"food_id": "888",
"food_name": "chicken",
"description": "nice, nice",
"price": "888",
"sales": "50"
}
### 添加菜品 [POST]
为某一餐厅添加新菜品(无需指定foodId)
+ Request (application/json)
发送一个food 对象
+ Body
{
"food_name": "chicken",
"description": "nice, nice",
"price": "888",
"image":"baidu.com",
"priority":"1"
}
+ Response 200 (application/json)
创建成功,返回完整的food对象
+ Body
{
"food_id": 3,
"food_name": "chicken",
"description": "nice, nice",
"price": "888",
"priority": "1"
}
### 编辑菜品 [PUT]
编辑某一餐厅的某一菜品
+ Request (application/json)
发送一个完整的food对象
+ Body
{
"food_name": "chicken",
"description": "nice, nice",
"price": "888"
}
+ Response 200 (application/json)
修改成功,返回修改后的food对象,包括id
+ Body
{
"food_id": "888",
"food_name": "chicken",
"description": "nice, nice",
"price": "888",
"sales": "0"
}
### 删除菜品 [DELETE]
+ Response 200 (application/json)
删除成功
+ Body
{
"msg":"删除成功"
}
## 订单 [/restaurant/orders?restaurant_id=?&table_id=?]
### 查看订单 [GET]
查看某一桌子的全部订单,若不指定tableId,则为当前餐厅的全部订单
+ Response 200 (application/json)
[
{
"order_id": 1,
"restaurant_id": 3,
"table_id": 2,
"customer_id": 1,
"order_time": "2018-06-13 03:22:32.757513+00:00",
"total_price": 2664,
"detail": []
},
{
"order_id": 2,
"restaurant_id": 3,
"table_id": 2,
"customer_id": 1,
"order_time": "2018-06-13 03:23:49.830117+00:00",
"total_price": 2664,
"detail": []
},
{
"order_id": 3,
"restaurant_id": 3,
"table_id": 2,
"customer_id": 1,
"order_time": "2018-06-13 03:24:33.263945+00:00",
"total_price": 2664,
"detail": [
{
"food": {
"food_id": 1,
"food_name": "chicken",
"description": "nice, nice",
"price": 888,
"priority": 1
},
"num": 1
},
{
"food": {
"food_id": 2,
"food_name": "chicken",
"description": "nice, nice",
"price": 888,
"priority": 1
},
"num": 2
},
{
"food": {
"food_id": 4,
"food_name": "chicken",
"description": "nice, nice",
"price": 888,
"priority": 1
},
"num": 2
}
]
}
]
### 提交订单 [POST]
需完整提供restaurant_id和table_id,提交一个订单,返回订单提交成功后的订单详情
+ Request (application/json)
{
foods: [
{
"food_id": "111",
"num": "1"
},
{
"food_id":"222",
"num":"2"
}
]
customer_id: "111"
}
+ Response 201 (text/html)
+ Body
{
order_id: "666",
foods: [
{
"food_id": "111",
"num": "1"
},
{
"food_id":"222",
"num":"2"
}
],
restaurant_id: "666",
table_id: "111",
customer_id: "111",
order_time: "2018-01-01 11:11:11"
}
## 评论 [/restaurant/comment?restaurant_id=?]
这部分处理对某一餐厅的评论,在之后需要加入资源的分页等
### 查看评论 [GET]
+ Response 200 (application/json)
[
{
"comment_id": "111",
"comment_content": "shit"
},
]
### 撰写评论 [POST]
+ Request (application/json)
{
"user_id": "666",
"comment_content": "shit"
}
+ Response 201 (application/json)
+ Body
{
"comment_id": "111",
"comment_content": "shit"
}
## 库存 [/restaurant/stock?restaurantId=?]
### 获取库存 [GET]
+ Response 200 (application/json)
[
{
"foodName": "chicken",
"howMany" : "666"
}
]
## 小程序端登陆 [/buyer/session]
### 新建登录态 [POST]
发送通过wx接口获取的login code和user info,session key将会保存在cookie中
+ Request (application/json)
+ Body
{
"code":"code",
"nickname":"nickname",
"avatar": "avator_url"
}
+ Response 200 (application/json)
+ Body
{
"msg":"登陆成功"
}
### 验证登陆态 [GET]
验证是否登陆
+ Response 200 (application/json)
+ Body
{
"login": true
}
## 上传图片 [/api/upload_image]
### 上传图片 [POST]
+ Request (form/data)
image : 图片
+ Response 200 (application/json)
+ Body
{
"url": "/static/upload_image/3-layer_yiDIy0m.png"
}