Commit 6d59361f authored by strong's avatar strong

增加手机端系统消息清空功能。

parent 943e8539
......@@ -168,3 +168,22 @@ router.post('/message/:mid/unShowMsg', function(req, res, next) {
res.json(returnCode.WRONG_PARAM);
}
});
//用户清空消息(修改状态)
router.post('/message/cleanAll', function(req, res, next) {
//消息参数
var userID = user.getMobileUser(req);
if(userID){
//更新用户的消息状态为未读
forumMessageService.updateUserMessageStatus({_id:userID}, null, 2, function(err, result) {
if (err) {
console.error(err);
res.json(returnCode.BUSY);
} else {
res.json(returnCode.SUCCESS);
}
});
}else{
res.json(returnCode.WRONG_PARAM);
}
});
\ No newline at end of file
......@@ -210,6 +210,11 @@ exports.updateUserMessageStatus= function(condition,msgID, status,callback) {
console.error(err);
callback(err,null);
}else{
if(!msgID){
for(var i in docs){
docs[i].status = status;
}
} else {
for(var i in docs){
if (docs[i].msg == msgID) {
if (docs[i].toObject) {
......@@ -219,6 +224,7 @@ exports.updateUserMessageStatus= function(condition,msgID, status,callback) {
break;
}
}
}
//更新用户
ForumUser.update(condition, {messages:docs},null,function(err,result){
if (err) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment