Showing
2 changed files
with
10 additions
and
2 deletions
@@ -196,7 +196,7 @@ module.exports = class extends global.yoho.BaseModel { | @@ -196,7 +196,7 @@ module.exports = class extends global.yoho.BaseModel { | ||
196 | let [product, content, count] = result; | 196 | let [product, content, count] = result; |
197 | 197 | ||
198 | if (product && product.length) { | 198 | if (product && product.length) { |
199 | - resData = product[0]; | 199 | + resData = product[0] || {}; |
200 | resData.content = _.sortBy(content || [], o => { | 200 | resData.content = _.sortBy(content || [], o => { |
201 | return o.sort; | 201 | return o.sort; |
202 | }); | 202 | }); |
@@ -70,9 +70,17 @@ class SqlHelper { | @@ -70,9 +70,17 @@ class SqlHelper { | ||
70 | 70 | ||
71 | let cacheResult = await this.cache.get(cacheKey); | 71 | let cacheResult = await this.cache.get(cacheKey); |
72 | 72 | ||
73 | - if (!_.isUndefined(cacheResult) && !_.isNull(cacheResult)) { | 73 | + |
74 | + if (cacheResult) { | ||
75 | + try { | ||
76 | + cacheResult = JSON.parse(cacheResult); | ||
77 | + | ||
74 | this.logger.debug('get success from cache.' + cacheString); | 78 | this.logger.debug('get success from cache.' + cacheString); |
79 | + | ||
75 | return Promise.resolve(cacheResult); | 80 | return Promise.resolve(cacheResult); |
81 | + } catch (e) { | ||
82 | + this.logger.debug('cache data parse fail.' + JSON.stringify(e)); | ||
83 | + } | ||
76 | } | 84 | } |
77 | } | 85 | } |
78 | 86 |
-
Please register or login to post a comment