vote.js
590 Bytes
/**
* 投票
* @author: leo
* @date: 23/06/2017
*/
const redis = require('redis');
const redisCli = global.yoho.utils.redisCli;
function getAll(req, res) {
redisCli.hget('vote', 'total', function(err, reply) {
res.json({
code: 200,
data: {
total: +reply
}
})
});
}
function addOne(req, res) {
redisCli.hincrby('vote', 'total', 1, function (err, reply) {
res.json({
code: 200,
message: '投票成功。'
});
});
}
module.exports = {
getAll,
addOne
};