Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pisns-forum-api
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
scrmGroup
pisns-forum-api
Commits
e3456dc4
Commit
e3456dc4
authored
Apr 24, 2015
by
刘文胜
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'development' of git.wxpai.cn:scrmgroup/pisns-forum-api into development
parents
6a5fdb67
454540ef
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
267 additions
and
236 deletions
+267
-236
forumThread.js
app/controllers/admin/forumThread.js
+21
-22
forumShare.js
app/controllers/mobile/forumShare.js
+133
-172
forumThread.js
app/controllers/mobile/forumThread.js
+5
-3
forumShareLog.js
app/models/forumShareLog.js
+66
-30
forumThreadService.js
app/service/forumThreadService.js
+4
-2
httpService.js
app/service/httpService.js
+24
-3
user.js
app/utils/user.js
+14
-4
No files found.
app/controllers/admin/forumThread.js
View file @
e3456dc4
...
...
@@ -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
);
}
});
});
...
...
app/controllers/mobile/forumShare.js
View file @
e3456dc4
This diff is collapsed.
Click to expand it.
app/controllers/mobile/forumThread.js
View file @
e3456dc4
...
...
@@ -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
.
updateThreadCommentCount
Inc
(
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
)
{
...
...
app/models/forumShareLog.js
View file @
e3456dc4
...
...
@@ -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'
});
...
...
app/service/forumThreadService.js
View file @
e3456dc4
...
...
@@ -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
)
{
...
...
app/service/httpService.js
View file @
e3456dc4
...
...
@@ -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
);
});
}
};
app/utils/user.js
View file @
e3456dc4
...
...
@@ -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
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment