...
|
...
|
@@ -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,7 +59,6 @@ const collectProduct = (req, res, next) => { |
|
|
if (uid && pid) {
|
|
|
switch (type) {
|
|
|
case 'add':
|
|
|
{
|
|
|
productService.createAsync(uid, pid)
|
|
|
.then(result => {
|
|
|
if (result.code === 413) {
|
...
|
...
|
@@ -54,22 +69,17 @@ const collectProduct = (req, res, next) => { |
|
|
})
|
|
|
.catch(next);
|
|
|
break;
|
|
|
}
|
|
|
case 'cancel':
|
|
|
{
|
|
|
productService.deleteAsync(uid, pid)
|
|
|
.then(result => res.json(result))
|
|
|
.catch(next);
|
|
|
break;
|
|
|
}
|
|
|
default:
|
|
|
{
|
|
|
res.json({
|
|
|
code: 400,
|
|
|
message: '错误类型'
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
} else if (!uid) {
|
|
|
res.json({
|
|
|
code: 403,
|
...
|
...
|
@@ -117,5 +127,6 @@ const collectShop = (req, res, next) => { |
|
|
module.exports = {
|
|
|
changeFavoriteBrand,
|
|
|
collectProduct,
|
|
|
collectShop
|
|
|
collectShop,
|
|
|
isFavoriteBrand
|
|
|
}; |
...
|
...
|
|