favorite.js
830 Bytes
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
/**
* Created by TaoHuang on 2016/6/13.
*/
'use strict';
const helpers = require(`${library}/helpers`);
const mRoot = '../models';
const service = require(`${mRoot}/favorite-service`);
/**
* 收藏品牌ajax请求
*/
module.exports.changeFavoriteBrand = (req, res, next) => {
// TODO: uid get
let uid = '';
let brandId = req.body.brandId;
if (uid && brandId) {
service.changeFavoriteBrandAsync(uid, brandId).then(result => {
res.json(result)
}).catch(next);
} else if (!uid) {
res.json({
code: 403,
message: '用户ID不存在',
data: {
url: helpers.urlFormat('/signin.html')
}
});
} else {
res.json({
code: 400,
message: '操作失败'
});
}
};