favorite.js 863 Bytes
/**
 * 收藏相关接口
 * @author: yyq<yanqing.yang@yoho.cn>
 * @date: 2016/7/17
 */

'use strict';

const FavAPI = require('./favorite-api');

const toggleFavProduct = (productId, uid, isadd) => {
    if (isadd) {
        return FavAPI.addFavAsync(uid, productId, 'product');
    } else {
        return FavAPI.cancelFavAsync(uid, productId, 'product');
    }
};

const toggleFavBrand = (brandId, uid, isadd) => {
    if (isadd) {
        return FavAPI.addFavAsync(uid, brandId, 'brand');
    } else {
        return FavAPI.cancelFavAsync(uid, brandId, 'brand');
    }
};

const toggleFavShop = (shopId, uid, isadd) => {
    if (isadd) {
        return FavAPI.addFavAsync(uid, shopId, 'shop');
    } else {
        return FavAPI.cancelFavAsync(uid, shopId, 'shop');
    }
};


module.exports = {
    toggleFavProduct,
    toggleFavBrand,
    toggleFavShop
};