...
|
...
|
@@ -482,6 +482,30 @@ const article = { |
|
|
message: INVALID_PARAMS
|
|
|
});
|
|
|
}
|
|
|
const user_ip = req.headers['X-Forwarded-For'] || req.ip || req.connection.remoteAddress;
|
|
|
|
|
|
return req.ctx(ArticleModel).getActLimit(actId).then(actInfo => {
|
|
|
const {repeat_limit, vote_limit} = actInfo[0];
|
|
|
|
|
|
return req.ctx(ArticleModel).getArticleIp(actId, 0, user_ip).then(userCount => {
|
|
|
if (userCount > vote_limit) {
|
|
|
return Promise.reject({code: 400});
|
|
|
}
|
|
|
if (repeat_limit) {
|
|
|
return Promise.resolve();
|
|
|
}
|
|
|
return req.ctx(ArticleModel).getArticleIp(actId, articleId, user_ip).then(actCount => {
|
|
|
if (actCount > 0) {
|
|
|
return Promise.reject({code: 400});
|
|
|
}
|
|
|
return Promise.resolve();
|
|
|
});
|
|
|
});
|
|
|
}).then(() => {
|
|
|
return vote();
|
|
|
}, (result) => {
|
|
|
return res.json(result);
|
|
|
}).catch(next);
|
|
|
|
|
|
// 获取活动投票限制参数
|
|
|
req.ctx(ArticleModel).getActLimit(actId)
|
...
|
...
|
@@ -494,7 +518,7 @@ const article = { |
|
|
return {repeat: repeat, limit: limit};
|
|
|
}).then(limit_result => {
|
|
|
console.log(limit_result);
|
|
|
let user_ip = req.headers['X-Forwarded-For'] || req.ip || req.connection.remoteAddress;
|
|
|
|
|
|
|
|
|
// 获取用户IP今日已投票次数
|
|
|
req.ctx(ArticleModel).getArticleIp(actId, articleId, user_ip)
|
...
|
...
|
|