guochao.js
1.02 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
/**
* 优惠券管理controller
* @author: leo <y.huang@yoho.cn>
* @date: 08/08/2018
*/
const guoChaoModel = require('../models/guochao');
const guochaoController = {
list: async function(req, res) {
let list = await req.ctx(guoChaoModel).list();
return res.json(list);
},
listPage(req, res) {
res.render('guochao/list', {
bodyClass: 'nav-md',
module: 'admin',
page: 'guochao'
});
},
async updatePage(req, res) {
let result = await req.ctx(guoChaoModel).findById(req.query.id);
if (result instanceof Array) {
result = result[0];
}
res.render('guochao/guochao-option', {
bodyClass: 'nav-md',
module: 'admin',
content: result,
page: 'guochao-option'
});
},
update: async function(req, res) {
let result = await req.ctx(guoChaoModel).update(req.body);
return res.json(result);
},
};
module.exports = guochaoController;