guochao.js
1.97 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
/**
* 优惠券管理controller
* @author: leo <y.huang@yoho.cn>
* @date: 08/08/2018
*/
const GuochaoModel = require('../models/guochao');
const _ = require('lodash');
const guochaoController = {
async addFav(req, res, next) {
let param = req.body;
let sessionKey = param.sessionKey;
let appVersion = param.appVersion;
let appSessionType = param.sessionType;
// 调用接口传参时切勿使用toString获得字符串
let uid = {
toString: () => {
return _.parseInt(req.body.uid);
},
sessionKey,
appVersion,
appSessionType
};
try {
let r = await req.ctx(GuochaoModel).addFavAsync(uid, param.id, 'shop');
res.json(r);
} catch (e) {
next;
}
},
checkFav: async function(req, res, next) {
let param = req.body;
let sessionKey = param.sessionKey;
let appVersion = param.appVersion;
let appSessionType = param.sessionType;
let uid = {
toString: () => {
return _.parseInt(req.body.uid);
},
sessionKey,
appVersion,
appSessionType
};
let ids = [1292, 282, 3082, 3372, 3548, 25, 3350, 1898, 1330, 1306, 1482, 992, 1474, 1472, 97, 1298, 1248, 3520, 2642, 964, 990, 1262, 1494, 292, 3146, 369, 720, 1282, 2312, 1878, 3210, 3576, 468, 3196, 1938, 3012];
try {
let result = await req.ctx(GuochaoModel).checkFavs(uid, ids, 'shop');
res.json(result);
} catch (e) {
next;
}
},
list: async function(req, res, next) {
try {
let result = await req.ctx(GuochaoModel).list();
res.json({
data: result,
code: 200,
result: true
});
} catch (e) {
next;
}
}
};
module.exports = guochaoController;