...
|
...
|
@@ -17,10 +17,10 @@ const changeFavoriteBrand = (req, res, next) => { |
|
|
|
|
|
if (uid && brandId) {
|
|
|
brandService.changeAsync(uid, brandId).then(result => {
|
|
|
res.json(result);
|
|
|
return res.json(result);
|
|
|
}).catch(next);
|
|
|
} else if (!uid) {
|
|
|
res.json({
|
|
|
return res.json({
|
|
|
code: 403,
|
|
|
message: '用户ID不存在',
|
|
|
data: {
|
...
|
...
|
@@ -28,13 +28,29 @@ const changeFavoriteBrand = (req, res, next) => { |
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
res.json({
|
|
|
return res.json({
|
|
|
code: 400,
|
|
|
message: '操作失败'
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
const isFavoriteBrand = (req, res, next) => {
|
|
|
let uid = req.user.uid || '';
|
|
|
let brandId = req.query.brandId;
|
|
|
|
|
|
if (uid && brandId) {
|
|
|
brandService.isFavoriteAsync(uid, brandId).then(result => {
|
|
|
return res.json(result);
|
|
|
}).catch(next);
|
|
|
} else {
|
|
|
return res.json({
|
|
|
code: 400,
|
|
|
message: '状态失败'
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
const collectProduct = (req, res, next) => {
|
|
|
let uid = req.user.uid || '';
|
|
|
let pid = req.body.productId;
|
...
|
...
|
@@ -43,8 +59,7 @@ const collectProduct = (req, res, next) => { |
|
|
if (uid && pid) {
|
|
|
switch (type) {
|
|
|
case 'add':
|
|
|
{
|
|
|
productService.createAsync(uid, pid)
|
|
|
productService.createAsync(uid, pid)
|
|
|
.then(result => {
|
|
|
if (result.code === 413) {
|
|
|
result.message = '该商品已经收藏';
|
...
|
...
|
@@ -53,22 +68,17 @@ const collectProduct = (req, res, next) => { |
|
|
res.json(result);
|
|
|
})
|
|
|
.catch(next);
|
|
|
break;
|
|
|
}
|
|
|
break;
|
|
|
case 'cancel':
|
|
|
{
|
|
|
productService.deleteAsync(uid, pid)
|
|
|
productService.deleteAsync(uid, pid)
|
|
|
.then(result => res.json(result))
|
|
|
.catch(next);
|
|
|
break;
|
|
|
}
|
|
|
break;
|
|
|
default:
|
|
|
{
|
|
|
res.json({
|
|
|
code: 400,
|
|
|
message: '错误类型'
|
|
|
});
|
|
|
}
|
|
|
res.json({
|
|
|
code: 400,
|
|
|
message: '错误类型'
|
|
|
});
|
|
|
}
|
|
|
} else if (!uid) {
|
|
|
res.json({
|
...
|
...
|
@@ -117,5 +127,6 @@ const collectShop = (req, res, next) => { |
|
|
module.exports = {
|
|
|
changeFavoriteBrand,
|
|
|
collectProduct,
|
|
|
collectShop
|
|
|
collectShop,
|
|
|
isFavoriteBrand
|
|
|
}; |
...
|
...
|
|