Commit eba8660d authored by 刘文胜's avatar 刘文胜

111

parent c65c3a02
......@@ -10,7 +10,8 @@ var router = require('express').Router(),
//模型
var ForumThread = mongoose.model('ForumThread'),
ForumComment = mongoose.model('ForumComment'),
ForumPVLog = mongoose.model('ForumPVLog');
ForumPVLog = mongoose.model('ForumPVLog'),
ForumFollowThread = mongoose.model('ForumFollowThread');
//服务
var forumThreadService = require('../../service/forumThreadService'),
forumUserService = require('../../service/forumUserService'),
......@@ -613,3 +614,77 @@ router.get('/threadManagement/threads/:tid/comment/search', function(req, res, n
res.json(returnCode.WRONG_PARAM);
}
});
//查询帖子的收藏数
router.get('/threadManagement/threads/:tid/collects', function(req, res, next) {
var tid = req.params.tid || null;
var ent_code = req.session.user.ent_code;
var conditions = {
ent_code: ent_code,
thread: tid
};
if (tid && ent_code) {
ForumFollowThread.count(conditions, function(err, count) {
if (err) {
res.json(returnCode.BUSY);
} else {
res.json(_.assign({data:(count||0)}, returnCode.SUCCESS));
}
});
} else {
res.json(returnCode.WRONG_PARAM);
}
});
//查询帖子的子文章数
router.get('/threadManagement/threads/:tid/subtotal', function(req, res, next) {
var tid = req.params.tid || null;
var ent_code = req.session.user.ent_code;
var conditions = {
ent_code: ent_code,
pid: tid,
status:1
};
if (tid && ent_code) {
ForumThread.count(conditions, function(err, count) {
if (err) {
res.json(returnCode.BUSY);
} else {
res.json(_.assign({data:(count||0)}, returnCode.SUCCESS));
}
});
} else {
res.json(returnCode.WRONG_PARAM);
}
});
//查询(话题/照片墙)的参与人数
router.get('/threadManagement/threads/:tid/joined/total', function(req, res, next) {
var tid = req.params.tid || null;
var ent_code = req.session.user.ent_code;
if (tid && ent_code) {
ForumThread.aggregate({
$match: {
ent_code: ent_code,
pid: mongoose.Types.ObjectId(tid)
}
}, {
$group: {
_id: {
from: '$from'
},
count: {
$sum: 1
}
}
}, function(err, data) {
if (err) {
res.json(returnCode.BUSY);
} else {
res.json(_.assign({data:((data && data.length)||0)}, returnCode.SUCCESS));
}
});
} else {
res.json(returnCode.WRONG_PARAM);
}
});
\ No newline at end of file
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