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
18abca5d
Commit
18abca5d
authored
Mar 10, 2016
by
陈家荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
子话题最新查询接口
parent
b94dc9c6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
117 additions
and
92 deletions
+117
-92
forumThread.js
app/controllers/mobile/forumThread.js
+103
-82
forumThreadService.js
app/service/forumThreadService.js
+14
-10
No files found.
app/controllers/mobile/forumThread.js
View file @
18abca5d
...
@@ -506,8 +506,6 @@ router.post('/thread/create', function(req, res, next) {
...
@@ -506,8 +506,6 @@ router.post('/thread/create', function(req, res, next) {
}
}
}
}
});
});
// httpService.sendRequest(req.session.user.ent_code, req.session.openUser.mid, 'post');
var
rs
=
{};
var
rs
=
{};
rs
.
data
=
{
rs
.
data
=
{
'id'
:
thread
.
_id
'id'
:
thread
.
_id
...
@@ -525,20 +523,22 @@ router.post('/thread/create', function(req, res, next) {
...
@@ -525,20 +523,22 @@ router.post('/thread/create', function(req, res, next) {
});
});
});
});
//获取
目标论坛
文章
//获取文章
router
.
get
(
'/thread/:tid/get'
,
function
(
req
,
res
,
next
)
{
router
.
get
(
'/thread/:tid/get'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
params
.
tid
||
null
;
var
tid
=
req
.
params
.
tid
||
null
;
var
ent_code
=
req
.
session
.
user
.
ent_code
;
var
ent_code
=
req
.
session
.
user
.
ent_code
;
if
(
tid
)
{
if
(
tid
)
{
async
.
waterfall
([
async
.
waterfall
([
function
(
callback
)
{
function
(
callback
)
{
forumThreadService
.
getThreadById
(
tid
,
function
(
err
,
thread
)
{
forumThreadService
.
getThreadById
(
tid
,
function
(
err
,
thread
)
{
//文章类型 1、文章 2、话题 3、照片墙
//文章类型 1、文章 2、话题 3、照片墙
if
(
err
||
!
thread
)
{
if
(
err
)
{
callback
(
err
,
null
);
callback
(
err
,
null
);
}
else
{
}
else
{
callback
(
null
,
thread
);
callback
(
null
,
thread
);
}
}
if
(
thread
&&
thread
.
info
){
var
info_id
=
thread
.
info
.
_id
,
var
info_id
=
thread
.
info
.
_id
,
pid
=
thread
.
pid
,
pid
=
thread
.
pid
,
source
=
req
.
session
.
mobileForumUser
.
source
;
source
=
req
.
session
.
mobileForumUser
.
source
;
...
@@ -551,6 +551,7 @@ router.get('/thread/:tid/get', function(req, res, next) {
...
@@ -551,6 +551,7 @@ router.get('/thread/:tid/get', function(req, res, next) {
}
else
if
(
thread
.
type
==
3
&&
thread
.
level
==
1
)
{
}
else
if
(
thread
.
type
==
3
&&
thread
.
level
==
1
)
{
httpService
.
createLog
(
req
,
source
,
info_id
,
3
,
3
,
tid
);
httpService
.
createLog
(
req
,
source
,
info_id
,
3
,
3
,
tid
);
}
}
}
});
});
forumThreadService
.
updateThreadPvCount
(
tid
,
function
(
err
,
doc
)
{
forumThreadService
.
updateThreadPvCount
(
tid
,
function
(
err
,
doc
)
{
if
(
err
)
{
if
(
err
)
{
...
@@ -616,7 +617,7 @@ router.get('/thread/:tid/get', function(req, res, next) {
...
@@ -616,7 +617,7 @@ router.get('/thread/:tid/get', function(req, res, next) {
}
}
});
});
//获取
目标论坛
文章
//获取文章
router
.
get
(
'/thread/photo/:pid/get'
,
function
(
req
,
res
,
next
)
{
router
.
get
(
'/thread/photo/:pid/get'
,
function
(
req
,
res
,
next
)
{
var
pid
=
req
.
params
.
pid
||
null
,
var
pid
=
req
.
params
.
pid
||
null
,
userId
=
user
.
getMobileUser
(
req
);
userId
=
user
.
getMobileUser
(
req
);
...
@@ -677,36 +678,6 @@ router.post('/thread/:tid/delete', function(req, res, next) {
...
@@ -677,36 +678,6 @@ router.post('/thread/:tid/delete', function(req, res, next) {
}
}
});
});
//文章点赞
router
.
post
(
'/thread/:tid/raise'
,
function
(
req
,
res
,
next
)
{
var
userId
=
req
.
session
.
mobileForumUser
.
userId
;
var
mid
=
req
.
session
.
openUser
.
mid
;
var
tid
=
req
.
params
.
tid
||
null
;
var
ent_code
=
req
.
session
.
user
.
ent_code
;
if
(
tid
)
{
raiseOrcancelRaise
(
req
,
ent_code
,
tid
,
userId
,
function
(
result
){
res
.
json
(
result
);
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
//文章取消点赞
router
.
post
(
'/thread/:tid/cancelRaise'
,
function
(
req
,
res
,
next
)
{
var
userId
=
req
.
session
.
mobileForumUser
.
userId
;
var
mid
=
req
.
session
.
openUser
.
mid
;
var
tid
=
req
.
params
.
tid
||
null
;
var
ent_code
=
req
.
session
.
user
.
ent_code
;
if
(
tid
)
{
raiseOrcancelRaise
(
req
,
ent_code
,
tid
,
userId
,
function
(
result
){
res
.
json
(
result
);
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
//文章点赞和取消点赞
//文章点赞和取消点赞
router
.
post
(
'/thread/:tid/praiseOrCancelPraise'
,
function
(
req
,
res
,
next
)
{
router
.
post
(
'/thread/:tid/praiseOrCancelPraise'
,
function
(
req
,
res
,
next
)
{
var
userId
=
req
.
session
.
mobileForumUser
.
userId
;
var
userId
=
req
.
session
.
mobileForumUser
.
userId
;
...
@@ -1469,39 +1440,6 @@ router.get('/thread/:tid/comment/list/byFloor', function(req, res, next) {
...
@@ -1469,39 +1440,6 @@ router.get('/thread/:tid/comment/list/byFloor', function(req, res, next) {
}
}
});
});
//评论点赞
router
.
post
(
'/thread/:tid/comment/:cid/raise'
,
function
(
req
,
res
,
next
)
{
var
userId
=
req
.
session
.
mobileForumUser
.
userId
;
var
tid
=
req
.
params
.
tid
||
null
;
var
cid
=
req
.
params
.
cid
||
null
;
var
mid
=
req
.
session
.
openUser
.
mid
;
var
ent_code
=
req
.
session
.
user
.
ent_code
;
if
(
tid
&&
cid
)
{
conmentRaiseOrcancelRaise
(
req
,
ent_code
,
tid
,
cid
,
userId
,
function
(
result
){
res
.
json
(
result
);
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
//评论取消点赞
router
.
post
(
'/thread/:tid/comment/:cid/cancelRaise'
,
function
(
req
,
res
,
next
)
{
var
userId
=
req
.
session
.
mobileForumUser
.
userId
;
var
tid
=
req
.
params
.
tid
||
null
;
var
cid
=
req
.
params
.
cid
||
null
;
var
mid
=
req
.
session
.
openUser
.
mid
;
var
ent_code
=
req
.
session
.
user
.
ent_code
;
if
(
tid
&&
cid
)
{
conmentRaiseOrcancelRaise
(
req
,
ent_code
,
tid
,
cid
,
userId
,
function
(
result
){
res
.
json
(
result
);
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
//评论点赞和取消点赞
//评论点赞和取消点赞
router
.
post
(
'/thread/:tid/comment/:cid/praiseOrCancelPraise'
,
function
(
req
,
res
,
next
)
{
router
.
post
(
'/thread/:tid/comment/:cid/praiseOrCancelPraise'
,
function
(
req
,
res
,
next
)
{
var
userId
=
req
.
session
.
mobileForumUser
.
userId
;
var
userId
=
req
.
session
.
mobileForumUser
.
userId
;
...
@@ -1574,9 +1512,7 @@ router.get('/thread/:tid/topics', function(req, res, next) {
...
@@ -1574,9 +1512,7 @@ router.get('/thread/:tid/topics', function(req, res, next) {
$ne
:
3
$ne
:
3
}
}
};
};
if
(
tid
)
{
if
(
tid
)
{
async
.
waterfall
([
async
.
waterfall
([
function
(
callback
)
{
function
(
callback
)
{
forumUserThreadControlService
.
getUserThreadControlById
(
user
.
getMobileUser
(
req
),
function
(
err
,
doc
)
{
forumUserThreadControlService
.
getUserThreadControlById
(
user
.
getMobileUser
(
req
),
function
(
err
,
doc
)
{
...
@@ -1986,3 +1922,88 @@ router.get('/thread/getThreadWithNotPopulateComment/hot', function(req, res, nex
...
@@ -1986,3 +1922,88 @@ router.get('/thread/getThreadWithNotPopulateComment/hot', function(req, res, nex
}
}
});
});
});
});
//获取话题下子文章
router
.
get
(
'/thread/:tid/get/subThreads/:type'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
params
.
tid
||
null
;
var
type
=
req
.
params
.
type
||
null
;
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
var
ent_code
=
req
.
session
.
user
.
ent_code
;
var
rs
=
{};
var
conditions
=
{
ent_code
:
ent_code
,
pid
:
tid
,
type
:
2
,
status
:
{
$ne
:
3
}
};
var
sort
=
null
;
//排序条件
if
(
type
==
1
){
//最新
sort
=
'-created'
;
}
else
if
(
type
==
2
){
//最热
}
if
(
tid
)
{
async
.
waterfall
([
function
(
callback
)
{
forumThreadService
.
getByIdSelectyField
(
tid
,
'type'
,
function
(
err
,
thread
)
{
if
(
err
)
{
callback
(
err
,
null
);
}
else
{
callback
(
null
,
thread
);
}
});
},
function
(
thread
,
callback
)
{
forumUserThreadControlService
.
getUserThreadControlById
(
user
.
getMobileUser
(
req
),
function
(
err
,
doc
)
{
if
(
err
)
{
callback
(
err
,
null
,
null
);
}
else
{
if
(
doc
)
{
callback
(
null
,
thread
,
doc
);
}
else
{
callback
(
null
,
thread
,
null
);
}
}
});
},
function
(
thread
,
doc
,
callback
)
{
if
(
thread
.
type
==
2
)
{
//查询子列表
if
(
doc
)
{
conditions
.
_id
=
{
$nin
:
doc
.
thread
};
}
//获取子话题数据
forumThreadService
.
getThreadWithNotPopulateComment
(
conditions
,
pageNo
,
pageSize
,
sort
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
results
);
}
});
}
else
{
callback
(
null
,
null
);
}
}
],
function
(
err
,
results
)
{
if
(
err
)
{
res
.
json
(
returnCode
.
BUSY
);
}
else
{
util
.
loadLevel
(
ent_code
,
results
.
items
,
function
()
{
handleThreadList
(
req
,
results
,
ent_code
,
function
(
result
){
res
.
json
(
_
.
assign
(
result
,
returnCode
.
SUCCESS
));
});
});
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
\ No newline at end of file
app/service/forumThreadService.js
View file @
18abca5d
...
@@ -191,9 +191,6 @@ exports.findCommentByPage = function(pageNo, pageSize, q, callback) {
...
@@ -191,9 +191,6 @@ exports.findCommentByPage = function(pageNo, pageSize, q, callback) {
});
});
};
};
//创建文章
//创建文章
exports
.
createThread
=
function
(
entity
,
callback
)
{
exports
.
createThread
=
function
(
entity
,
callback
)
{
if
(
!
entity
.
share
)
{
if
(
!
entity
.
share
)
{
...
@@ -231,6 +228,18 @@ exports.createThread = function(entity, callback) {
...
@@ -231,6 +228,18 @@ exports.createThread = function(entity, callback) {
}
}
};
};
//根据ID获取文章,选择字段
exports
.
getByIdSelectyField
=
function
(
id
,
fields
,
callback
)
{
ForumThread
.
findOne
({
_id
:
id
}).
select
(
fields
).
exec
(
function
(
err
,
result
){
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
result
);
}
});
}
//根据ID获取文章记录,不查评论,子话题
//根据ID获取文章记录,不查评论,子话题
exports
.
getById
=
function
(
id
,
callback
)
{
exports
.
getById
=
function
(
id
,
callback
)
{
ForumThread
.
findOne
({
ForumThread
.
findOne
({
...
@@ -257,7 +266,6 @@ exports.getByConditions = function(conditions, callback) {
...
@@ -257,7 +266,6 @@ exports.getByConditions = function(conditions, callback) {
}
}
//根据ID获取文章
//根据ID获取文章
exports
.
getThreadById
=
function
(
tid
,
callback
)
{
exports
.
getThreadById
=
function
(
tid
,
callback
)
{
ForumThread
.
findOne
({
_id
:
tid
}).
populate
(
'from'
,
'uid mid nickName icon exp'
).
populate
(
'info'
,
'name icon'
).
populate
(
'share'
).
exec
(
function
(
err
,
doc
)
{
ForumThread
.
findOne
({
_id
:
tid
}).
populate
(
'from'
,
'uid mid nickName icon exp'
).
populate
(
'info'
,
'name icon'
).
populate
(
'share'
).
exec
(
function
(
err
,
doc
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
err
);
console
.
error
(
err
);
...
@@ -273,7 +281,6 @@ exports.getThreadById = function(tid, callback) {
...
@@ -273,7 +281,6 @@ exports.getThreadById = function(tid, callback) {
var
conditions
=
{
var
conditions
=
{
thread
:
tid
,
thread
:
tid
,
level
:
'1'
level
:
'1'
// status:1
};
};
//获取最新10条评论
//获取最新10条评论
forumCommentService
.
getAllComment
(
conditions
,
1
,
10
,
function
(
err
,
results
)
{
forumCommentService
.
getAllComment
(
conditions
,
1
,
10
,
function
(
err
,
results
)
{
...
@@ -1149,7 +1156,6 @@ exports.remove = function(array,val) {
...
@@ -1149,7 +1156,6 @@ exports.remove = function(array,val) {
return
array
;
return
array
;
};
};
function
getAllThreadByFidAndUserHelp
(
user_ids
,
conditions
,
pageNo
,
pageSize
,
sort
,
callback
)
{
function
getAllThreadByFidAndUserHelp
(
user_ids
,
conditions
,
pageNo
,
pageSize
,
sort
,
callback
)
{
conditions
.
from
=
{
conditions
.
from
=
{
"$in"
:
user_ids
"$in"
:
user_ids
...
@@ -1231,7 +1237,6 @@ exports.getAllThreadByFidAndMid = function(mid, conditions, pageNo, pageSize, so
...
@@ -1231,7 +1237,6 @@ exports.getAllThreadByFidAndMid = function(mid, conditions, pageNo, pageSize, so
});
});
}
}
//更新文章
//更新文章
exports
.
updateThread
=
function
(
condition
,
entity
,
callback
)
{
exports
.
updateThread
=
function
(
condition
,
entity
,
callback
)
{
ForumThread
.
findOneAndUpdate
(
condition
,
entity
,
function
(
err
,
doc
){
ForumThread
.
findOneAndUpdate
(
condition
,
entity
,
function
(
err
,
doc
){
...
@@ -1256,8 +1261,6 @@ exports.updateByIdWithOptions = function(condition, entity, options, callback) {
...
@@ -1256,8 +1261,6 @@ exports.updateByIdWithOptions = function(condition, entity, options, callback) {
});
});
};
};
//查询列表数据,不获取评论,话题获取参与用户
//查询列表数据,不获取评论,话题获取参与用户
exports
.
getThreadWithNotPopulateComment
=
function
(
conditions
,
pageNo
,
pageSize
,
sort
,
callback
)
{
exports
.
getThreadWithNotPopulateComment
=
function
(
conditions
,
pageNo
,
pageSize
,
sort
,
callback
)
{
countAllByFid
(
conditions
,
function
(
err
,
count
)
{
countAllByFid
(
conditions
,
function
(
err
,
count
)
{
...
@@ -1319,3 +1322,4 @@ exports.getThreadWithNotPopulateComment = function(conditions, pageNo, pageSize,
...
@@ -1319,3 +1322,4 @@ exports.getThreadWithNotPopulateComment = function(conditions, pageNo, pageSize,
});
});
};
};
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