|
1
|
|
|
const Response = require('../../util/response') |
|
2
|
|
|
const ServiceViewer = require('../../services/catering/viewer') |
|
3
|
|
|
const ServiceCategories = require('../../services/catering/category') |
|
4
|
|
|
const ServiceProducts = require('../../services/catering/product') |
|
5
|
|
|
const Validate = require('request-validate') |
|
6
|
|
|
|
|
7
|
|
|
module.exports = { |
|
8
|
|
|
/** |
|
9
|
|
|
* @api {get} /api/catering/v1/viewers viewer列表 |
|
10
|
|
|
* @apiGroup viewer |
|
11
|
|
|
* @apiPermission todo |
|
12
|
|
|
* @apiVersion 1.0.0 |
|
13
|
|
|
* @apiParam {String} param 参数 |
|
14
|
|
|
* @apiSuccess {String} data 返回数据 |
|
15
|
|
|
* @apiSuccessExample {json} Visual Preview: |
|
16
|
|
|
* { |
|
17
|
|
|
"success": true, |
|
18
|
|
|
"code": 200, |
|
19
|
|
|
"message": "请求成功", |
|
20
|
|
|
"data": [ |
|
21
|
|
|
{ |
|
22
|
|
|
"id": 1, |
|
23
|
|
|
}, |
|
24
|
|
|
.... |
|
25
|
|
|
] |
|
26
|
|
|
} |
|
27
|
|
|
*/ |
|
28
|
|
|
index: async function (ctx) { |
|
29
|
|
|
let data = await ServiceViewer.list() |
|
30
|
|
|
|
|
31
|
|
|
return Response.output(ctx, data) |
|
32
|
|
|
}, |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @api {get} /api/catering/v1/viewers/:viewerId/categories 访问店铺的分类 |
|
36
|
|
|
* @apiGroup viewer |
|
37
|
|
|
* @apiPermission guest |
|
38
|
|
|
* @apiVersion 1.0.0 |
|
39
|
|
|
* @apiParam {String} param 参数 |
|
40
|
|
|
* @apiSuccess {String} data 返回数据 |
|
41
|
|
|
* @apiSuccessExample {json} Visual Preview: |
|
42
|
|
|
* { |
|
43
|
|
|
"success": true, |
|
44
|
|
|
"code": 200, |
|
45
|
|
|
"message": "请求成功", |
|
46
|
|
|
"data": [ |
|
47
|
|
|
{ |
|
48
|
|
|
"id": 1, |
|
49
|
|
|
}, |
|
50
|
|
|
.... |
|
51
|
|
|
] |
|
52
|
|
|
} |
|
53
|
|
|
*/ |
|
54
|
|
|
categories: async function (ctx) { |
|
55
|
|
|
let data = await ServiceCategories.list(ctx.params.viewerId, { status: 1 }) |
|
56
|
|
|
|
|
57
|
|
|
return Response.output(ctx, data) |
|
58
|
|
|
}, |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @api {get} /api/catering/v1/viewers/:viewerId/products 访问店铺的商品 |
|
62
|
|
|
* @apiGroup viewer |
|
63
|
|
|
* @apiPermission guest |
|
64
|
|
|
* @apiVersion 1.0.0 |
|
65
|
|
|
* @apiParam {String} param 参数 |
|
66
|
|
|
* @apiSuccess {String} data 返回数据 |
|
67
|
|
|
* @apiSuccessExample {json} Visual Preview: |
|
68
|
|
|
* { |
|
69
|
|
|
"success": true, |
|
70
|
|
|
"code": 200, |
|
71
|
|
|
"message": "请求成功", |
|
72
|
|
|
"data": [ |
|
73
|
|
|
{ |
|
74
|
|
|
"id": 1, |
|
75
|
|
|
}, |
|
76
|
|
|
.... |
|
77
|
|
|
] |
|
78
|
|
|
} |
|
79
|
|
|
*/ |
|
80
|
|
|
products: async function (ctx) { |
|
81
|
|
|
Validate(ctx.input, { |
|
82
|
|
|
'category_id': 'required|nunumericm' |
|
83
|
|
|
}) |
|
84
|
|
|
let data = await ServiceProducts.list(ctx.params.viewerId, { status: 1, categroy_id: ctx.input.category_id }) |
|
85
|
|
|
|
|
86
|
|
|
return Response.output(ctx, data) |
|
87
|
|
|
}, |
|
88
|
|
|
|
|
89
|
|
|
} |
|
90
|
|
|
|