Commit 27bf9dff authored by 陈志良's avatar 陈志良

1

parent 25827f1e
......@@ -72,7 +72,7 @@ router.post('/user/identifyUser',function(req,res,next){
}
});
}else{
res.json('success');
res.json({result:'success',userId:req.session.mobileForumUser.userId});
}
});
//微信分享带来用户
......@@ -115,7 +115,12 @@ router.post('/user/checkLimitAction', function(req, res, next) {
forumLimitActionRefService.getLimitActionRefByMid(userId,function(err,forumLimitActionRef){
if (err) {
console.error(err);
res.json('success');
var returnObject = {
errcode:'success',
configs:configs,
data:array
}
res.json(returnObject);
} else {
// 获取到用户行为限制记录
if(forumLimitActionRef){
......
......@@ -2,12 +2,14 @@
var express = require('express'),
router = express.Router(),
returnCode = require('../../utils/returnCode'),
_ = require('lodash');
_ = require('lodash'),
then = require('thenjs');
var mongoose = require('mongoose');
var ForumInfo = mongoose.model('ForumInfo');
var forumInfoService=require('../../service/forumInfoService');
var forumThreadService=require('../../service/forumThreadService');
var forumGroupService = require('../../service/forumGroupService');
module.exports = function(app) {
......@@ -17,15 +19,43 @@ module.exports = function(app) {
//新增论坛板块
router.post('/info/create', function(req, res, next) {
var rs = {};
req.body.ent_code=req.session.user.ent_code;
forumInfoService.createInfo(req.body,function(err,info){
if (err) {
console.error(err);
res.json(returnCode.BUSY);
} else {
rs.data = {'id':info._id};
res.json(_.assign(rs, returnCode.SUCCESS));
var entity = req.body;
var ent_code = entity.ent_code = req.session.user.ent_code;
then(function(cont){
//获取所有版块组
forumGroupService.getAll({ent_code:ent_code},1,100,function(err,groups){
cont(err,groups);
});
}).then(function(cont,groups){
//判断是否存在版块组
if(groups && groups.items.length >0){
cont(null,groups.items[0]);
}else{
//创建默认版块组
var group = {
name:'默认分组',
ent_code:ent_code
};
forumGroupService.createGroup(group,function(err,group){
cont(err,group);
});
}
}).then(function(cont,group){
if(group){
//创建版块
entity.group = group._id;
forumInfoService.createInfo(req.body,function(err,info){
cont(err,info);
});
}else{
cont('group error');
}
}).then(function(cont,info){
rs.data = {'id':info._id};
res.json(_.assign(rs, returnCode.SUCCESS));
}).fail(function(err,cont){
console.error(err);
res.json(returnCode.BUSY);
});
});
......
......@@ -615,6 +615,18 @@ router.post('/thread/comment/add', function(req, res, next) {
}
});
}else{
var icon = req.session.user.headPic;
if(icon.indexOf('http://') == -1){
icon = req.host != 'piplus.wxpai.cn'?'http://img3.wxpai.cn/'+ icon : 'http://img2.wxpai.cn/' + icon;
}
if(icon && (!user.icon || user.icon !== icon)){
forumUserService.updateUserById(user._id,{icon:icon},function(err){
if(err){
console.log(err);
}
});
}
entity.from = user;
callback();
}
......@@ -644,16 +656,31 @@ router.post('/thread/comment/add', function(req, res, next) {
},
function(callback){
// 添加评论
forumCommentService.createComment(entity, function(err, result) {
forumCommentService.createComment(entity, function(err, comment) {
if (err) {
callback(err);
} else {
var returnData = {
comment:  result,
errorcode: 0,
errormsg: '请求成功'
}
callback(null,returnData);
forumThreadService.getById(tid,function(err,thread){
var comments = thread.comments;
var array = [];
if (comments && comments.length > 0) {
array = comments;
}
array.push(comment._id);
forumThreadService.updateThreadById(tid, {
comments: array,
$inc: {
comment_count: 1
}
}, function(err, result) {
var returnData = {
comment: comment,
errorcode: 0,
errormsg: '请求成功'
}
callback(null,returnData);
});
});
}
});
}
......
......@@ -19,6 +19,21 @@ module.exports = function(app) {
app.use('/v1/forum', router);
};
//新增论坛板块
router.get('/info/list/all', function(req, res, next) {
var rs = {};
var ent_code = req.session.user.ent_code;
forumInfoService.getAllByGid({ent_code:ent_code},1,100, function(err, datas) {
if (err) {
console.error(err);
res.json(returnCode.BUSY);
} else {
rs.data = datas.items;
res.json(_.assign(rs, returnCode.SUCCESS));
}
});
});
//新增论坛板块
router.post('/info/create', function(req, res, next) {
var rs = {};
......
......@@ -138,6 +138,7 @@ router.post('/thread/create', function(req, res, next) {
res.json(returnCode.PROHIBITION_OF_SPEECH);
}else{
if(isProhibition){
res.json(returnCode.PROHIBITION_OF_SPEECH);
}else{
var integral = req.session.openUser.integral || 0;
......
......@@ -204,8 +204,8 @@ exports.checkLimitActionProhibitionOfSpeech = function(userId,callback) {
//检查用户是否被禁加积分
exports.checkLimitActionProhibitionAddIntegral = function(userId,callback) {
var isProhibition = false;
if(userId){
var isProhibition = false;
getLimitActionRef(userId,function(err,forumLimitActionRef){
if (err) {
console.error(err);
......@@ -228,11 +228,6 @@ exports.checkLimitActionProhibitionAddIntegral = function(userId,callback) {
}
}
}
if(isProhibition){
console.log('Integral:!送积分');
}else{
console.log('Integral:送积分');
}
callback(null, isProhibition);
}else{
callback(null, isProhibition);
......
......@@ -811,7 +811,7 @@ exports.updateRecommendByThreadId = function(threadId, callback) {
}, {
recommend: 1
}, function(err, doc) {
callback(err,null);
callback(err,doc);
});
};
//根据文章ID更新文章为不推荐
......
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