|
@@ -61,14 +61,14 @@ class ActYohoActivitysModel extends global.yoho.BaseModel { |
|
@@ -61,14 +61,14 @@ class ActYohoActivitysModel extends global.yoho.BaseModel { |
61
|
let promiseArr = [];
|
61
|
let promiseArr = [];
|
62
|
|
62
|
|
63
|
for (let i = 0; i < data.itemLength; i++) {
|
63
|
for (let i = 0; i < data.itemLength; i++) {
|
64
|
- let member = JSON.stringify({id: (len + (i + 1)), name: 'item_' + (len + (i + 1))});
|
64
|
+ let member = 'item_' + (len + i + 1);
|
65
|
|
65
|
|
66
|
promiseArr.push(this.client.zadd(key, 0, member));
|
66
|
promiseArr.push(this.client.zadd(key, 0, member));
|
67
|
}
|
67
|
}
|
68
|
|
68
|
|
69
|
return Promise.all(promiseArr);
|
69
|
return Promise.all(promiseArr);
|
70
|
} else {
|
70
|
} else {
|
71
|
- let member = JSON.stringify({id: (len + 1), name: 'item_' + (len + 1)});
|
71
|
+ let member = 'item_' + (len + 1);
|
72
|
|
72
|
|
73
|
return this.client.zaddAsync(key, 0, member);
|
73
|
return this.client.zaddAsync(key, 0, member);
|
74
|
}
|
74
|
}
|
|
@@ -85,18 +85,20 @@ class ActYohoActivitysModel extends global.yoho.BaseModel { |
|
@@ -85,18 +85,20 @@ class ActYohoActivitysModel extends global.yoho.BaseModel { |
85
|
let key = `${PARENT_TABLE_NAME}:${data.actId}:items`;
|
85
|
let key = `${PARENT_TABLE_NAME}:${data.actId}:items`;
|
86
|
let finalResult = [];
|
86
|
let finalResult = [];
|
87
|
let result = [];
|
87
|
let result = [];
|
|
|
88
|
+ let start = data.start;
|
|
|
89
|
+ let end = data.end;
|
88
|
|
90
|
|
89
|
if (data.order === 'desc') {
|
91
|
if (data.order === 'desc') {
|
90
|
- result = await this.client.zrevrangeAsync(key, 0, -1);
|
92
|
+ result = await this.client.zrevrangeAsync(key, start, end);
|
91
|
|
93
|
|
92
|
} else {
|
94
|
} else {
|
93
|
- result = await this.client.zrangeAsync(key, 0, -1);
|
95
|
+ result = await this.client.zrangeAsync(key, start, end);
|
94
|
}
|
96
|
}
|
95
|
|
97
|
|
96
|
for (let i = 0; i < result.length; i++) {
|
98
|
for (let i = 0; i < result.length; i++) {
|
97
|
let score = await this.client.zscoreAsync(key, result[i]); // 获取得分
|
99
|
let score = await this.client.zscoreAsync(key, result[i]); // 获取得分
|
98
|
|
100
|
|
99
|
- finalResult.push(Object.assign({}, JSON.parse(result[i]), {score: score}));
|
101
|
+ finalResult.push(Object.assign({}, {id: result[i]}, {score: score}));
|
100
|
}
|
102
|
}
|
101
|
return finalResult;
|
103
|
return finalResult;
|
102
|
}
|
104
|
}
|
|
@@ -114,7 +116,7 @@ class ActYohoActivitysModel extends global.yoho.BaseModel { |
|
@@ -114,7 +116,7 @@ class ActYohoActivitysModel extends global.yoho.BaseModel { |
114
|
let finalResult = [];
|
116
|
let finalResult = [];
|
115
|
|
117
|
|
116
|
for (let i = 0; i < idsArr.length; i++) {
|
118
|
for (let i = 0; i < idsArr.length; i++) {
|
117
|
- let member = JSON.stringify({id: parseInt(idsArr[i], 10), name: 'item_' + idsArr[i]});
|
119
|
+ let member = 'item_' + idsArr[i];
|
118
|
|
120
|
|
119
|
let result = await this.client.zincrby(key, 1, member);
|
121
|
let result = await this.client.zincrby(key, 1, member);
|
120
|
|
122
|
|