提交 91aa8453 编写于 作者: C codfrm

update reward

上级 3f58e1dd
......@@ -14,6 +14,8 @@ title: 捐赠
|金额|渠道|捐赠者|备注|
|----|----|----|----|
|¥ 50.00|QQ红包|陈哲.IT||
|¥ 20.00|QQ红包|鸪||
|¥ 10.00|QQ红包|幻蓝|打赏了一个鸡腿|
|¥ 10.00|微信赞赏码|温瞳_|验证码接口推荐换成若快等,(会考虑增加)|
|¥ 5.00|微信赞赏码|xbei|ᕕ(˵•̀෴•́˵)ᕗ
......
{
"name": "cxmooc-tools",
"version": "2.0.8",
"version": "2.1.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
......@@ -7702,6 +7702,7 @@
"resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz",
"integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==",
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
......
......@@ -45,7 +45,7 @@ app.use(bodyParser.urlencoded({
}));
app.use(express.static(path.join(__dirname, 'static'), {
maxage: '7d'
maxage: '1d'
}));
app.get('/', function (req, res) {
......@@ -61,7 +61,7 @@ app.use(function (req, res, next) {
redis.onlineAdd(ip);
res.header("Access-Control-Allow-Origin", req.headers['origin']);
res.header("Access-Control-Allow-Headers", "Content-Type,Content-Length,Authorization,Accept,X-Requested-With");
res.header("Access-Control-Allow-Headers", "Content-Type,Content-Length,Authorization,Accept,X-Requested-With,X-Version");
res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
if (req.method == "OPTIONS") {
return res.status(200).send('success');
......@@ -89,6 +89,7 @@ app.post('/answer', function (req, res) {
});
}
let num = 0;
let addTokenNum = 0;
for (let i in req.body) {
let topic = req.body[i];
if (topic.correct == undefined || topic.type == undefined || topic.topic == undefined ||
......@@ -113,6 +114,8 @@ app.post('/answer', function (req, res) {
data.platform = platform;
data.token = token;
mooc.insert('answer', data);
//增加token次数
addTokenNum += 10;
} else if ((type == 4 && result.type == 4) || (type == 2 && result.type == 2)) {
//填空多选,答案合并
try {
......@@ -128,10 +131,15 @@ app.post('/answer', function (req, res) {
}
ret.push(cond);
if (ret.length == num) {
res.send({
code: 0,
msg: 'success',
result: ret
redis.getTokenNum(token, function (num) {
redis.setToken(token, parseInt(num) + addTokenNum)
res.send({
code: 0,
msg: 'success',
result: ret,
token_num: parseInt(num) + addTokenNum,
add_token_num: addTokenNum
});
});
}
});
......@@ -183,12 +191,12 @@ app.post('/v2/answer', function (req, res) {
let platform = req.query.platform || 'cx';
selectAnswer(topic, res, function (i) {
let where = {};
let topic_n = dealSymbol(topic[i].replace(/[-\/\\^$*+?.|[\]{}]/g, '\\$&'));
let topic_n = dealSymbol(topic[i].replace(/[-\/\\^$*+.|[\]{}]/g, '\\$&'));
// topic[i] = topic;
if (type[i] != undefined) {
where = { type: parseInt(type[i]) };
}
where.topic = { $regex: '^'+topic_n };
where.topic = { $regex: '^' + topic_n };
return where;
});
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册