Commit e25361fe by 兰国旗

Merge branch 'gsb-marketplat' of gitlab.gongsibao.com:jiangyong/zhichan into gsb-marketplat

parents e055926b c876941c
......@@ -6,7 +6,11 @@ class APIBase {
constructor() {
this.cacheManager = system.getObject("db.common.cacheManager");
this.logClient = system.getObject("util.logClient");
this.queryAction = ["getTemplateAndLinkInfo"];
this.redisClient = system.getObject("util.redisClient");
this.queryAction = ["getSourceChannelInfo","getAllProductType","productList","rotationChartList",
"tablePicList","needProductList","popularRecommendationList","productTypeFirst",
"productTypeSecend","productDetail","bottomMenuConfig","cycleProduct","secondLevelNeedConfig",
"clueMaintenance","cycleProductSecend"];
}
async setContextParams(pobj, qobj, req) {
let custtags = req.headers["x-consumetag"] ? req.headers["x-consumetag"].split("|") : null;
......@@ -43,8 +47,19 @@ class APIBase {
if (xarg && xarg[0] < 0) {
return system.getResultFail(...xarg);
}
if(pobj && pobj.actionType && this.queryAction.indexOf(pobj.actionType)>=0){
//查询缓存
var cacheRes = await this.redisClient.get(shaStr);
if (cacheRes) {
return JSON.parse(cacheRes);
}
}
var rtn = await this[methodname](pobj, query, req);
this.logClient.log(pobj, req, rtn);
if(rtn && rtn.status === 0 ){
//保存缓存
await this.redisClient.setWithEx(shaStr, JSON.stringify(rtn), 30);
}
return rtn;
} catch (e) {
this.logClient.log(pobj, req, null, e.stack);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment