Authored by htoooth

add cache

... ... @@ -6,6 +6,7 @@
'use strict';
const api = global.yoho.API;
const serviceAPI = global.yoho.ServiceAPI;
const config = global.yoho.config;
/**
* 分开取数,品牌一览 顶部的轮翻广告及热门品牌数据-PC
... ... @@ -15,7 +16,7 @@ const serviceAPI = global.yoho.ServiceAPI;
const getBrandTopData = (contentCode) => {
return serviceAPI.get('operations/api/v5/resource/get', {
content_code: contentCode
}, {cache: 3600});
}, config.apiCache);
};
/**
... ... @@ -28,7 +29,7 @@ const getBrandListData = channel => {
if (!isNaN(channel)) {
params.yh_channel = channel;
}
return api.get('', params);
return api.get('', params, config.apiCache);
};
/**
... ... @@ -48,7 +49,7 @@ const getBrandIntro = (brandId, uid) => {
method: 'app.brand.getBrandIntro',
brand_id: brandId,
uid: uid
}, param);
}, param, config.apiCache);
};
/**
... ... @@ -61,7 +62,7 @@ const getProductByBrand = (brandId, limit) => {
method: 'web.search.search',
brand: brandId,
limit: limit
});
}, config.apiCache);
};
/**
... ... @@ -74,7 +75,7 @@ const getBrandInfoByIds = (ids) => {
return api.get('', {
method: 'web.brand.info',
ids: ids instanceof Array ? ids.join(',') : parseInt(ids, 10)
}, {cache: 3600});
}, config.apiCache);
};
/**
... ... @@ -89,7 +90,7 @@ const getPlusstarList = (brandType, gender) => {
return serviceAPI.get('guang/api/v3/plustar/getlist', {
gender: gender,
brand_type: brandType
}, {cache: 3600});
}, config.apiCache);
};
module.exports = {
... ...
... ... @@ -10,6 +10,7 @@ const _ = require('lodash');
const dataMap = require('../../../config/data-map');
const helpers = global.yoho.helpers;
const config = global.yoho.config;
const processProduct = require(`${global.utils}/product-process`).processProduct;
const searchApi = require('../../product/models/search-api');
... ... @@ -335,7 +336,7 @@ const _getGirlsSingleHot = (args, type) => {
page: 1,
gender: channelMap[type].gender,
limit: 60
});
}, config.apiCache);
};
... ... @@ -592,18 +593,18 @@ const _processFloorData = (rawData, type) => {
let queryParam = '';
if (data.template_name === 'recommend_content_three' ||
(data.template_intro === '焦点图' && index === 0)) { // 处理banner
(data.template_intro === '焦点图' && index === 0)) { // 处理banner
floorData = floorMap.slide.call(null, data.data);
} else if (data.template_intro === '热门品类') { // 处理热门品类
floorData = floorMap.hot.call(null, rawData.slice(index, index + hotCategoryLength), type);
} else if (data.data && data.data.text) { // 处理一般楼层
let text = _getText(data.data.text);
let lastIndex = index + bigFloorLength < rawData.length ?
index + bigFloorLength : index + (rawData.length - index - 1);
index + bigFloorLength : index + (rawData.length - index - 1);
floorData = floorMap[text] &&
floorMap[text].call(null, rawData.slice(index, lastIndex), type);
floorMap[text].call(null, rawData.slice(index, lastIndex), type);
if (needQuery[text]) {
queryParam = getQuery(rawData.slice(index, lastIndex));
... ... @@ -657,9 +658,7 @@ const _processFloorData = (rawData, type) => {
};
const _formatResourceParams = (channel, code) => {
return serviceApi.get('operations/api/v5/resource/get', {content_code: code}, {
cache: true
}).then(data => {
return serviceApi.get('operations/api/v5/resource/get', {content_code: code}, config.apiCache).then(data => {
let result = data && data.data[0] && data.data[0].data[0];
if (result) {
... ... @@ -834,8 +833,6 @@ const getNewArrival = channel => {
};
/**
* 获取频道页数据
* @param {String} type 传入频道页类型,值可以是: boys, girls, kids, lifestyle
... ... @@ -956,9 +953,7 @@ const getIndexGuideData = () => {
private_key: '0ed29744ed318fd28d2c07985d3ba633'
};
return serviceApi.get('operations/api/v6/category/getCategory', params, {
cache: true
});
return serviceApi.get('operations/api/v6/category/getCategory', params, config.apiCache);
};
module.exports = {
... ...
... ... @@ -5,12 +5,13 @@
'use strict';
const api = global.yoho.API;
const config = global.yoho.config;
const getBannerInfoAsync = bid => {
return api.get('', {
method: 'web.brand.banner',
brand_id: bid
});
}, config.apiCache);
};
... ... @@ -18,7 +19,7 @@ const getBrandLogoByDomainAsync = domain => {
return api.get('', {
domain: domain,
method: 'web.brand.byDomain'
});
}, config.apiCache);
};
module.exports = {
... ...
... ... @@ -5,6 +5,7 @@
'use strict';
const api = global.yoho.API;
const config = global.yoho.config;
/**
* 获取商品的热区
... ... @@ -13,7 +14,7 @@ const indexAsync = pid => {
return api.get('', {
method: 'web.productCollocation.list',
product_id: pid
});
}, config.apiCache);
};
module.exports = {
... ...
... ... @@ -10,6 +10,7 @@
const serviceApi = global.yoho.ServiceAPI;
const api = global.yoho.API;
const _ = require('lodash');
const config = global.yoho.config;
const yhChannel = {
boys: {
... ... @@ -49,7 +50,7 @@ exports.getOutletsActivityOrigin = (params) => {
size: params.size || 0,
yh_channel: yhChannel[tempChannel].channel,
type: params.type || 0
});
}, config.apiCache);
};
/**
... ... @@ -58,7 +59,7 @@ exports.getOutletsActivityOrigin = (params) => {
* @return {[type]}
*/
exports.getChannelResouceData = (params) => {
return serviceApi.get('operations/api/v5/resource/home', params);
return serviceApi.get('operations/api/v5/resource/home', params, config.apiCache);
};
/**
... ... @@ -77,7 +78,7 @@ exports.getOutletsTrendData = (params) => {
stocknumber: 1, // 过滤出库存 > 1的商品
limit: params.limit || 5,
outlets: params.outlets || 1 // 默认取奥莱商品
});
}, config.apiCache);
};
... ... @@ -110,5 +111,5 @@ exports.getOutletsGoodsList = (params) => {
tempParams[paramsName] = params[paramsName];
}
});
return api.get('', tempParams);
return api.get('', tempParams, config.apiCache);
};
... ...
... ... @@ -10,6 +10,7 @@
const serviceAPI = global.yoho.ServiceAPI;
const api = global.yoho.API;
const _ = require('lodash');
const config = global.yoho.config;
const yhChannel = {
boys: {
... ... @@ -42,7 +43,7 @@ exports.getSaleGoodsList = (params) => {
finalParams.yh_channel = yhChannel[params.channel].channel;
}
return api.get('', Object.assign(finalParams, params));
return api.get('', Object.assign(finalParams, params), config.apiCache);
};
/**
... ... @@ -55,7 +56,7 @@ exports.getSalebreakingYardsSortList = (params) => {
return api.get('', {
method: 'app.sale.getBreakingSort',
yh_channel: yhChannel[tempChannel].channel
});
}, config.apiCache);
};
/**
... ... @@ -71,7 +72,7 @@ exports.getSaleActivityList = (params, channel) => {
sort: '2',
plateform: '1',
yh_channel: tempChannel.channel
});
}, config.apiCache);
};
/**
... ... @@ -81,7 +82,7 @@ exports.getSaleActivityList = (params, channel) => {
exports.getSaleBannerList = (cCode) => {
return serviceAPI.get('operations/api/v5/resource/get', {
content_code: cCode
});
}, config.apiCache);
};
/**
... ... @@ -91,7 +92,7 @@ exports.getSaleBannerList = (cCode) => {
exports.getLeftContentList = () => {
return api.get('', {
method: 'app.sort.get'
});
}, config.apiCache);
};
/**
... ...
... ... @@ -7,6 +7,7 @@ const md5 = require('md5');
const api = global.yoho.API;
const serviceApi = global.yoho.ServiceAPI;
const config = global.yoho.config;
const helpers = global.yoho.helpers;
const cache = global.yoho.cache;
... ... @@ -17,7 +18,7 @@ const images = require('../../../utils/images.js');
const getSortByConditionAsync = (condition) => {
return api.get('', Object.assign({
method: 'web.regular.groupsort'
}, condition));
}, condition), config.apiCache);
};
// 判断用户是否收藏品牌
... ... @@ -97,7 +98,7 @@ const getProductList = (params) => {
}
};
const getSortListOrig = (finalParams) => api.get('', finalParams);
const getSortListOrig = (finalParams) => api.get('', finalParams, config.apiCache);
/**
* 获取分类列表
... ... @@ -153,7 +154,7 @@ const getSortIntro = (params) => {
};
Object.assign(finalParams, params);
return api.get('', finalParams);
return api.get('', finalParams, config.apiCache);
};
/**
... ... @@ -166,7 +167,7 @@ const getSortAds = (params) => {
};
Object.assign(finalParams, params);
return api.get('', finalParams);
return api.get('', finalParams, config.apiCache);
};
/**
... ... @@ -181,7 +182,7 @@ const getBrandSeries = (params) => {
status: params.status || 1
};
return api.get('', finalParams);
return api.get('', finalParams, config.apiCache);
};
/**
... ... @@ -196,7 +197,7 @@ const getBrandFolder = (params) => {
status: params.status || 1
};
return api.get('', finalParams);
return api.get('', finalParams, config.apiCache);
};
/**
... ... @@ -210,7 +211,7 @@ const getNodeContent = (params) => {
node: params.node || ''
};
return api.get('', finalParams);
return api.get('', finalParams, config.apiCache);
};
/**
... ... @@ -224,7 +225,7 @@ const getWeekNew = (params) => {
};
Object.assign(finalParams, params);
return api.get('', finalParams);
return api.get('', finalParams, config.apiCache);
};
/**
... ... @@ -427,7 +428,7 @@ const getSuggest = (params) => {
keyword: params.keyword || ''
};
return api.get('', finalParams);
return api.get('', finalParams, config.apiCache);
};
... ... @@ -441,7 +442,7 @@ const getBrandData = (params) => {
domain: params.domain || ''
};
return api.get('', finalParams);
return api.get('', finalParams, config.apiCache);
};
/**
... ... @@ -452,7 +453,7 @@ const isFavoriteBrand = (uid, brandId) => {
return serviceApi.get(isFavoriteBrandUrl, {
uid: uid,
brandId: brandId
});
}, config.apiCache);
};
/**
... ...
... ... @@ -4,6 +4,7 @@
'use strict';
const api = global.yoho.API;
const config = global.yoho.config;
/**
* 获取店铺装修的所有资源接口
... ... @@ -12,5 +13,5 @@ exports.shopsDecoratorListAsync = shopId => {
return api.get('', {
method: 'app.shopsdecorator.getList',
shop_id: shopId
});
}, config.apiCache);
};
... ...
... ... @@ -6,7 +6,7 @@
'use strict';
const api = global.yoho.API;
const config = require('../../../config/common');
const config = global.yoho.config;
const searchApi = require('./search-api');
const cache = global.yoho.cache;
const logger = global.yoho.logger;
... ... @@ -17,7 +17,7 @@ const logger = global.yoho.logger;
*/
exports.getVerifiedTotal = () => {
return api.get('', {method: 'app.student.verifiedStudentTotal'});
return api.get('', {method: 'app.student.verifiedStudentTotal'}, config.apiCache);
};
/**
... ... @@ -26,7 +26,7 @@ exports.getVerifiedTotal = () => {
*/
exports.getEduLevelList = () => {
return api.get('', {method: 'app.studentMarket.getEducationLevelList'});
return api.get('', {method: 'app.studentMarket.getEducationLevelList'}, config.apiCache);
};
/**
... ... @@ -38,7 +38,7 @@ exports.getArea = () => {
method: 'app.studentMarket.getAddressList'
};
return api.get('', finalParams);
return api.get('', finalParams, config.apiCache);
};
/**
... ... @@ -51,7 +51,7 @@ exports.getSchool = (areaCode) => {
areaCode: areaCode
};
return api.get('', finalParams);
return api.get('', finalParams, config.apiCache);
};
/**
... ... @@ -66,7 +66,7 @@ exports.getStuProducts = (params) => {
};
Object.assign(finalParams, params);
return api.get('', finalParams);
return api.get('', finalParams, config.apiCache);
};
/**
... ... @@ -82,7 +82,7 @@ exports.verifyIdentity = (uid, certNo, name, pageUrl) => {
page_url: pageUrl
};
return api.get('', finalParams);
return api.get('', finalParams, config.apiCache);
};
/**
... ... @@ -99,7 +99,7 @@ exports.verifyStudent = (uid, collegeName, educationDegree, enrollmentYear) => {
enrollment_year: enrollmentYear
};
return api.get('', finalParams);
return api.get('', finalParams, config.apiCache);
};
/**
... ... @@ -117,7 +117,7 @@ exports.userAcquireStatus = (uid, couponIds) => {
finalParams.uid = uid;
}
return api.get('', finalParams);
return api.get('', finalParams, config.apiCache);
};
... ...