...
|
...
|
@@ -61,14 +61,14 @@ class ActYohoActivitysModel extends global.yoho.BaseModel { |
|
|
let promiseArr = [];
|
|
|
|
|
|
for (let i = 0; i < data.itemLength; i++) {
|
|
|
let member = JSON.stringify({id: (len + (i + 1)), name: 'item_' + (len + (i + 1))});
|
|
|
let member = 'item_' + (len + i + 1);
|
|
|
|
|
|
promiseArr.push(this.client.zadd(key, 0, member));
|
|
|
}
|
|
|
|
|
|
return Promise.all(promiseArr);
|
|
|
} else {
|
|
|
let member = JSON.stringify({id: (len + 1), name: 'item_' + (len + 1)});
|
|
|
let member = 'item_' + (len + 1);
|
|
|
|
|
|
return this.client.zaddAsync(key, 0, member);
|
|
|
}
|
...
|
...
|
@@ -85,18 +85,20 @@ class ActYohoActivitysModel extends global.yoho.BaseModel { |
|
|
let key = `${PARENT_TABLE_NAME}:${data.actId}:items`;
|
|
|
let finalResult = [];
|
|
|
let result = [];
|
|
|
let start = data.start;
|
|
|
let end = data.end;
|
|
|
|
|
|
if (data.order === 'desc') {
|
|
|
result = await this.client.zrevrangeAsync(key, 0, -1);
|
|
|
result = await this.client.zrevrangeAsync(key, start, end);
|
|
|
|
|
|
} else {
|
|
|
result = await this.client.zrangeAsync(key, 0, -1);
|
|
|
result = await this.client.zrangeAsync(key, start, end);
|
|
|
}
|
|
|
|
|
|
for (let i = 0; i < result.length; i++) {
|
|
|
let score = await this.client.zscoreAsync(key, result[i]); // 获取得分
|
|
|
|
|
|
finalResult.push(Object.assign({}, JSON.parse(result[i]), {score: score}));
|
|
|
finalResult.push(Object.assign({}, {id: result[i]}, {score: score}));
|
|
|
}
|
|
|
return finalResult;
|
|
|
}
|
...
|
...
|
@@ -114,7 +116,7 @@ class ActYohoActivitysModel extends global.yoho.BaseModel { |
|
|
let finalResult = [];
|
|
|
|
|
|
for (let i = 0; i < idsArr.length; i++) {
|
|
|
let member = JSON.stringify({id: parseInt(idsArr[i], 10), name: 'item_' + idsArr[i]});
|
|
|
let member = 'item_' + idsArr[i];
|
|
|
|
|
|
let result = await this.client.zincrby(key, 1, member);
|
|
|
|
...
|
...
|
|