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

Merge branch 'development' of git.wxpai.cn:scrmgroup/pisns-forum-api into development

parents 6a5fdb67 454540ef
......@@ -81,9 +81,7 @@ router.post('/thread/create', function(req, res, next) {
}
});
}
});
}
}
}); } }
});
});
......@@ -212,6 +210,7 @@ router.get('/threads/list', function(req, res, next) {
var infoId = req.query.infoId;
var tagId = req.query.tagId;
var pid = req.query.pid;
var content = req.query.content;
var conditions = {
ent_code: req.session.user.ent_code,
level: 1
......@@ -230,6 +229,13 @@ router.get('/threads/list', function(req, res, next) {
conditions.level = 2;
}
if(content){
conditions.content = {
$regex: content,
$options: 'i'
}
}
forumThreadService.getAllThreadByFid(conditions, pageNo, pageSize, null, function(err, results) {
if (err) {
console.error(err);
......@@ -357,28 +363,21 @@ router.post('/thread/comment/update/:cid/comments', function(req, res, next) {
var cid = req.params.cid || null;
var replayComment_id = req.body.replayComment_id;
// 获取评论的子评论列表
forumCommentService.getCommentById(cid, function(err, result) {
// 更新文章评论 + 1
forumThreadService.updateThreadCommentCountInc(tid, function(err, thread) {
if (err) {
console.error(err);
callback(err, null);
}
});
// 更新评论对象
// result.comment_count+=1; // 回复评论+1
forumCommentService.updateCommentById(cid, {$push:{comments:replayComment_id},$inc:{comment_count:1}}, function(err, result) {
if (err) {
console.error(err);
res.json(returnCode.BUSY);
} else {
// 更新文章评论 + 1
forumThreadService.updateThreadCommentCountInc(tid, function(err, thread) {
if (err) {
callback(err, null);
}
});
// 更新评论对象
result.comments.push(replayComment_id); // 添加子评论ID
// result.comment_count+=1; // 回复评论+1
forumCommentService.updateCommentById(cid, result, function(err, result) {
if (err) {
res.json(returnCode.BUSY);
} else {
res.json(returnCode.SUCCESS);
}
});
res.json(returnCode.SUCCESS);
}
});
});
......
This diff is collapsed.
......@@ -466,7 +466,7 @@ router.post('/thread/:tid/comment/create', function(req, res, next) {
function(callback) {
//3.更新文章统计数据(评论数)
if (thread) {
forumThreadService.updateThreadCommentCount(tid, function(err, results) {
forumThreadService.updateThreadCommentCountInc(tid, function(err, results) {
if (err) {
console.log(err);
callback(err, null);
......@@ -914,7 +914,8 @@ router.get('/thread/:tid/latestPhotos', function(req, res, next) {
var conditions = {
ent_code: req.session.user.ent_code,
pid: tid,
type: 3
type: 3,
images: {$exists: true, $not: {$size: 0}}
};
if (tid) {
......@@ -967,7 +968,8 @@ router.get('/thread/:tid/hotPhotos', function(req, res, next) {
var conditions = {
ent_code: req.session.user.ent_code,
pid: tid,
type: 3
type: 3,
images: {$exists: true, $not: {$size: 0}}
};
if (tid) {
......
......@@ -5,36 +5,72 @@ var mongoose = require('mongoose'),
//分享日志
var ForumShareLogSchema = new Schema({
ent_code: {
type: Number,
require: true,
index: true
},
user: { //分享者
type: Schema.Types.ObjectId,
require: true,
index: true,
ref: 'ForumUser'
},
thread: { //分享内容
type: Schema.Types.ObjectId,
require: true,
index: true,
ref: 'ForumThread'
},
destination: { //分享的目标,微信好友,微信朋友圈,QQ空间,微博等等
type: String,
require: true,
index: true
},
ip: { //IP地址
type: String,
require: true
},
created: { //分享时间
type: Date,
require: true,
default: Date.now
}
type: Number,
require: true,
index: true
},
user: { //访问者
type: String,
require: true,
index: true,
ref: 'ForumUser'
},
mid: { //会员ID
type: Number,
require: true,
index: true
},
open_id: { //微信公众号唯一识别
type: String,
require: true,
index: true
},
info: { //板块ID
type: String,
index: true,
ref: 'ForumInfo'
},
thread: { //话题、文章、照片墙的ID
type: String,
index: true,
ref: 'forumThread'
},
type: { //页面:1.主页 2.板块 3.文章
type: Number,
index: true,
require: true
},
thread_type: { //文章类型:1.话题 2.文章 3.照片墙 4.子文章
type: Number,
index: true
},
share_type:{ //分享类型:1.微信朋友圈 2.微信单人 3.微信组
type: Number,
index: true,
require: true
},
p_thread: { //父文章ID
type: String,
index: true,
ref: 'forumThread'
},
source: { //分享者
type: String,
require: true,
index: true,
ref: 'ForumUser'
},
ip: { //IP地址
type: String
},
userAgent: {
type: String
},
created: {
type: Date,
required: true,
default: Date.now
}
}, {
'collection': 'pisns_forum_share_log'
});
......
......@@ -179,7 +179,8 @@ exports.getThreadById = function(tid, callback) {
//获取照片墙最新文章列表
var conditions = {
pid: tid,
type: 3
type: 3,
images: {$exists: true, $not: {$size: 0}}
};
getAllThreadByFidHelp(conditions, 1, 10, '-created', function(err, threads) {
if (err) {
......@@ -194,7 +195,8 @@ exports.getThreadById = function(tid, callback) {
//获取照片墙最热文章列表
var conditions = {
pid: tid,
type: 3
type: 3,
images: {$exists: true, $not: {$size: 0}}
};
getAllThreadByFidHelp(conditions, 1, 10, '-praise_count', function(err, threads) {
if (err) {
......
......@@ -16,8 +16,9 @@ var mongoose = require('mongoose'),
moment = require('moment'),
then = require('thenjs');
var ForumPVLog = mongoose.model('ForumPVLog');
var ForumUVLog = mongoose.model('ForumUVLog');
var ForumPVLog = mongoose.model('ForumPVLog'),
ForumUVLog = mongoose.model('ForumUVLog'),
ForumShareLog = mongoose.model('ForumShareLog');
exports.sendRequest = function(ent_code, mid, action, messageid, integral, exp) {
var obj = {
tag: 'member',
......@@ -51,7 +52,6 @@ var getClientIP = function(req) {
};
exports.createLog = function(req,source,info,type,thread_type,thread,p_thread) {
var logObj = {
ent_code: req.session.user.ent_code,
source:source,
......@@ -97,3 +97,24 @@ exports.createLog = function(req,source,info,type,thread_type,thread,p_thread) {
console.error('没有日志信息');
}
};
exports.createShareLog = function(req,share_type) {
var logObj = req.session.mobileForumUser.share_log;
logObj.source = req.session.mobileForumUser.source;
logObj.mid = req.session.openUser.mid;
logObj.ent_code = req.session.user.ent_code;
logObj.user = req.session.mobileForumUser.userId;
logObj.open_id = req.session.mobileForumUser.openId;
logObj.ip = getClientIP(req);
logObj.share_type = share_type;
logObj.userAgent = req.headers['user-agent'];
if(logObj){
then(function(cont){
var share_log_model = new ForumShareLog(logObj);
share_log_model.save(cont);
}).fail(function(cont,err){
console.error(err);
});
}
};
......@@ -25,8 +25,10 @@ exports.identifyUser=function() {
openId:doc.uid
};
if(req.session.source){
req.session.mobileForumUser.source = req.session.source;
delete req.session.source;
if(req.session.source !== req.session.mobileForumUser.userId){
req.session.mobileForumUser.source = req.session.source;
delete req.session.source;
}
}
next(null);
}else{
......@@ -49,8 +51,10 @@ exports.identifyUser=function() {
openId:doc.uid
};
if(req.session.source){
req.session.mobileForumUser.source = req.session.source;
delete req.session.source;
if(req.session.source !== req.session.mobileForumUser.userId){
req.session.mobileForumUser.source = req.session.source;
delete req.session.source;
}
}
next(null);
......@@ -61,6 +65,12 @@ exports.identifyUser=function() {
}
});
}else{
if(req.session.source){
if(req.session.source !== req.session.mobileForumUser.userId){
req.session.mobileForumUser.source = req.session.source;
delete req.session.source;
}
}
next(null);
}
......
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