Authored by htoooth

refactor favorite product

@@ -21,7 +21,10 @@ const commentAPI = require('./detail-comment-api'); @@ -21,7 +21,10 @@ const commentAPI = require('./detail-comment-api');
21 const consultAPI = require('./detail-consult-api'); 21 const consultAPI = require('./detail-consult-api');
22 const hotAreaAPI = require('./detail-hotarea-api'); 22 const hotAreaAPI = require('./detail-hotarea-api');
23 const brandAPI = require('./brand-api'); 23 const brandAPI = require('./brand-api');
24 -const favoriteBrandService = require('./favorite-service'); 24 +
  25 +const favoriteBrandService = require('./favorite-brand-service');
  26 +const favoriteProductService = require('./favorite-product-service');
  27 +
25 const shopAPI = require('./shop-api'); 28 const shopAPI = require('./shop-api');
26 const searchAPI = require('./search-api'); 29 const searchAPI = require('./search-api');
27 const homeHandle = require('./home-handle'); 30 const homeHandle = require('./home-handle');
@@ -65,7 +68,7 @@ const setMultiResourceByProductBaseInfo = (data) => { @@ -65,7 +68,7 @@ const setMultiResourceByProductBaseInfo = (data) => {
65 68
66 if (uid) { 69 if (uid) {
67 multiResourcesUrl['FavoriteData::getUidProductFav'] = 70 multiResourcesUrl['FavoriteData::getUidProductFav'] =
68 - yield favoriteBrandService.getUidProductFavAsync(uid, productId, isOnlyUrl); 71 + yield favoriteProductService.getUidProductFavAsync(uid, productId, isOnlyUrl);
69 } 72 }
70 })(); 73 })();
71 }; 74 };
@@ -91,7 +94,7 @@ const getProductFavoriteData = (uid, pid, bid) => { @@ -91,7 +94,7 @@ const getProductFavoriteData = (uid, pid, bid) => {
91 let productData = getMultiDataByResourceName('FavoriteData::getUidProductFav'); 94 let productData = getMultiDataByResourceName('FavoriteData::getUidProductFav');
92 95
93 if (!productData) { 96 if (!productData) {
94 - productData = yield favoriteBrandService.getUidProductFavAsync(uid, pid); 97 + productData = yield favoriteProductService.getUidProductFavAsync(uid, pid);
95 } 98 }
96 result.product = productData.code === 200 && productData.data ? true : false; 99 result.product = productData.code === 200 && productData.data ? true : false;
97 } 100 }
@@ -8,15 +8,6 @@ const sign = require(`${library}/sign`); @@ -8,15 +8,6 @@ const sign = require(`${library}/sign`);
8 const api = new API(); 8 const api = new API();
9 const serviceAPI = new ServiceAPI(); 9 const serviceAPI = new ServiceAPI();
10 10
11 -module.exports.getUidProductFavAsync = function (uid, pid) {  
12 - return api.get('', sign.apiSign({  
13 - method: 'app.favorite.isFavorite',  
14 - id: pid,  
15 - uid: uid,  
16 - type: 'product'  
17 - }));  
18 -};  
19 -  
20 module.exports.isFavoriteBrandAsync = function (uid, bid) { 11 module.exports.isFavoriteBrandAsync = function (uid, bid) {
21 return serviceAPI.get('shops/service/v1/favorite/getUidBrandFav', sign.apiSign({ 12 return serviceAPI.get('shops/service/v1/favorite/getUidBrandFav', sign.apiSign({
22 uid: uid, 13 uid: uid,
@@ -10,4 +10,3 @@ module.exports.changeFavoriteBrandAsync = favoriteBrandAPI.changeFavoriteBrandAs @@ -10,4 +10,3 @@ module.exports.changeFavoriteBrandAsync = favoriteBrandAPI.changeFavoriteBrandAs
10 10
11 module.exports.isFavoriteBrandAsync = favoriteBrandAPI.isFavoriteBrandAsync; 11 module.exports.isFavoriteBrandAsync = favoriteBrandAPI.isFavoriteBrandAsync;
12 12
13 -module.exports.getUidProductFavAsync = favoriteBrandAPI.getUidProductFavAsync;  
  1 +/**
  2 + * Created by TaoHuang on 2016/6/13.
  3 + */
  4 +
  5 +const library = '../../../library';
  6 +const API = require(`${library}/api`).API;
  7 +const ServiceAPI = require(`${library}/api`).ServiceAPI;
  8 +const sign = require(`${library}/sign`);
  9 +
  10 +const api = new API();
  11 +
  12 +module.exports.getUidProductFavAsync = function (uid, pid) {
  13 + return api.get('', sign.apiSign({
  14 + method: 'app.favorite.isFavorite',
  15 + id: pid,
  16 + uid: uid,
  17 + type: 'product'
  18 + }));
  19 +};
  1 +/**
  2 + * Created by TaoHuang on 2016/6/13.
  3 + */
  4 +
  5 +'use strict';
  6 +
  7 +const favoriteProductAPI = require('./favorite-product-api');
  8 +
  9 +module.exports.getUidProductFavAsync = favoriteProductAPI.getUidProductFavAsync;