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
96d68c68
Commit
96d68c68
authored
Sep 16, 2015
by
strong
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'new_thread_bug_fix'
parents
23445589
04c79386
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
487 additions
and
3 deletions
+487
-3
forumThread.js
app/controllers/admin/forumThread.js
+17
-1
forumAboutMe.js
app/controllers/mobile/forumAboutMe.js
+71
-0
forumInfo.js
app/controllers/mobile/forumInfo.js
+48
-0
forumModerator.js
app/controllers/mobile/forumModerator.js
+2
-0
forumTag.js
app/controllers/mobile/forumTag.js
+5
-1
forumThread.js
app/controllers/mobile/forumThread.js
+15
-1
forumAboutMe.js
app/models/forumAboutMe.js
+65
-0
forumAboutMEService.js
app/service/forumAboutMEService.js
+264
-0
No files found.
app/controllers/admin/forumThread.js
View file @
96d68c68
...
...
@@ -16,7 +16,7 @@ var forumTagService = require('../../service/forumTagService');
var
forumUserService
=
require
(
'../../service/forumUserService'
);
// var forumLimitActionRefService = require('../../service/forumLimitActionRefService');
var
forumLimitOperationService
=
require
(
'../../service/forumLimitOperationService'
);
var
forumAboutMEService
=
require
(
'../../service/forumAboutMEService'
);
var
httpService
=
require
(
'../../service/httpService'
);
var
userUtil
=
require
(
'../../utils/user'
);
...
...
@@ -101,6 +101,7 @@ router.post('/thread/create', function(req, res, next) {
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
forumAboutMEService
.
saveThread
(
entity
);
rs
.
data
=
{
'id'
:
entity
.
_id
};
...
...
@@ -126,6 +127,7 @@ router.post('/thread/create', function(req, res, next) {
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
forumAboutMEService
.
saveThread
(
entity
);
rs
.
data
=
{
'id'
:
entity
.
_id
};
...
...
@@ -223,6 +225,9 @@ router.post('/thread/:tid/update', function(req, res, next) {
if
(
err
)
{
res
.
json
(
returnCode
.
BUSY
);
}
else
{
if
(
!
isNaN
(
req
.
body
.
status
)){
forumAboutMEService
.
updateThreadStatus
(
thread
.
_id
,
thread
.
status
)
}
res
.
json
({
message
:
"success"
,
data
:
thread
,
...
...
@@ -572,6 +577,12 @@ router.post('/thread/comment/update/:cid', function(req, res, next) {
});
}
}
else
{
if
(
comment
&&
comment
.
level
==
1
){
forumAboutMEService
.
updateCommentLevel1Status
(
comment
.
_id
,
status
);
}
if
(
comment
&&
comment
.
level
==
2
){
forumAboutMEService
.
updateCommentLevel2Status
(
comment
.
_id
,
status
);
}
callback
();
}
}
...
...
@@ -615,6 +626,7 @@ router.post('/thread/comment/update/:cid/comments', function(req, res, next) {
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
forumAboutMEService
.
saveCommentLevel2BySearch
(
tid
,
cid
,
replayComment_id
);
res
.
json
(
returnCode
.
SUCCESS
);
}
});
...
...
@@ -746,7 +758,11 @@ router.post('/thread/comment/add', function(req, res, next) {
if
(
err
)
{
callback
(
err
);
}
else
{
forumThreadService
.
getById
(
tid
,
function
(
err
,
thread
){
if
(
entity
.
level
==
1
){
forumAboutMEService
.
saveCommentLevel1
(
thread
,
comment
);
}
var
comments
=
thread
.
comments
;
var
array
=
[];
if
(
comments
&&
comments
.
length
>
0
)
{
...
...
app/controllers/mobile/forumAboutMe.js
0 → 100644
View file @
96d68c68
'use strict'
;
var
express
=
require
(
'express'
),
router
=
express
.
Router
(),
user
=
require
(
'../../utils/user'
),
returnCode
=
require
(
'../../utils/returnCode'
),
_
=
require
(
'lodash'
);
var
forumAboutMEService
=
require
(
'../../service/forumAboutMEService'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/v1/forum'
,
router
);
};
router
.
get
(
'/aboutme/me2other'
,
function
(
req
,
res
,
next
)
{
var
userId
=
user
.
getMobileUser
(
req
);
var
entcode
=
req
.
session
.
user
.
ent_code
;
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
console
.
log
(
userId
);
console
.
log
(
entcode
);
forumAboutMEService
.
me2other
(
entcode
,
userId
,
pageNo
,
pageSize
,
function
(
err
,
result
){
if
(
err
){
res
.
json
(
returnCode
.
UNCHECK_ERROR
(
err
));
}
else
{
res
.
json
(
_
.
assign
(
result
,
returnCode
.
SUCCESS
));
}
});
});
router
.
get
(
'/aboutme/other2me'
,
function
(
req
,
res
,
next
)
{
var
userId
=
user
.
getMobileUser
(
req
);
var
entcode
=
req
.
session
.
user
.
ent_code
;
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
console
.
log
(
userId
);
console
.
log
(
entcode
);
forumAboutMEService
.
other2me
(
entcode
,
userId
,
pageNo
,
pageSize
,
function
(
err
,
result
){
if
(
err
){
res
.
json
(
returnCode
.
UNCHECK_ERROR
(
err
));
}
else
{
res
.
json
(
_
.
assign
(
result
,
returnCode
.
SUCCESS
));
}
});
});
router
.
get
(
'/aboutme/he2other/:id/:entcode'
,
function
(
req
,
res
,
next
)
{
var
userId
=
req
.
params
.
id
;
var
entcode
=
req
.
params
.
entcode
;
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
forumAboutMEService
.
me2other
(
entcode
,
userId
,
pageNo
,
pageSize
,
function
(
err
,
result
){
if
(
err
){
res
.
json
(
returnCode
.
UNCHECK_ERROR
(
err
));
}
else
{
res
.
json
(
_
.
assign
(
result
,
returnCode
.
SUCCESS
));
}
});
});
router
.
get
(
'/aboutme/other2he/:id/:entcode'
,
function
(
req
,
res
,
next
)
{
var
userId
=
req
.
params
.
id
;
var
entcode
=
req
.
params
.
entcode
;
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
forumAboutMEService
.
other2me
(
entcode
,
userId
,
pageNo
,
pageSize
,
function
(
err
,
result
){
if
(
err
){
res
.
json
(
returnCode
.
UNCHECK_ERROR
(
err
));
}
else
{
res
.
json
(
_
.
assign
(
result
,
returnCode
.
SUCCESS
));
}
});
});
\ No newline at end of file
app/controllers/mobile/forumInfo.js
View file @
96d68c68
...
...
@@ -415,6 +415,54 @@ router.get('/info/myThreads', function(req, res, next) {
});
});
//获取他的文章列表
router
.
get
(
'/info/hisThreads/:id'
,
function
(
req
,
res
,
next
)
{
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
,
from
:
req
.
params
.
id
};
async
.
waterfall
([
function
(
callback
)
{
callback
();
// forumUserThreadControlService.getUserThreadControlById(user.getMobileUser(req), function(err, doc) {
// if (err) {
// callback(err, null);
// } else {
// if (doc) {
// callback(null, doc);
// } else {
// callback(null, null);
// }
// }
// });
}
],
function
(
err
,
result
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
if
(
result
)
{
conditions
.
_id
=
{
$nin
:
result
.
thread
};
}
//获取子话题数据
forumThreadService
.
getAllThreadByFid
(
conditions
,
pageNo
,
pageSize
,
'-created'
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
_
.
assign
(
results
,
returnCode
.
SUCCESS
));
}
});
}
});
});
//获取我的评论列表
router
.
get
(
'/info/myComments'
,
function
(
req
,
res
,
next
)
{
var
fid
=
req
.
params
.
fid
||
null
;
...
...
app/controllers/mobile/forumModerator.js
View file @
96d68c68
...
...
@@ -12,6 +12,7 @@ var ForumModerator = mongoose.model('ForumModerator');
var
forumThreadService
=
require
(
'../../service/forumThreadService'
);
var
forumLimitOperationService
=
require
(
'../../service/forumLimitOperationService'
);
var
forumModeratorApplyService
=
require
(
'../../service/forumModeratorApplyService'
);
var
forumAboutMEService
=
require
(
'../../service/forumAboutMEService'
);
var
httpService
=
require
(
'../../service/httpService'
);
var
request
=
require
(
'request'
);
var
env
=
process
.
env
.
NODE_ENV
;
...
...
@@ -214,6 +215,7 @@ router.get('/moderators/delthread/:tid', function(req, res, next) {
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
moderatorOperateLog
(
result
.
forumUser
,
t
,
3
);
forumAboutMEService
.
updateThreadStatus
(
tid
,
3
);
}
});
});
...
...
app/controllers/mobile/forumTag.js
View file @
96d68c68
...
...
@@ -36,11 +36,15 @@ router.get('/tag/list', function(req, res, next) {
//查询前台可使用的所有标签(针对发帖)
router
.
get
(
'/tag/mobileList'
,
function
(
req
,
res
,
next
)
{
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
var
pageSize
=
req
.
query
.
pageSize
||
100
;
var
infoId
=
req
.
query
.
infoId
;
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
,
type
:
1
};
if
(
infoId
){
//查询板块
conditions
.
info
=
infoId
;
}
forumTagService
.
getAllTag
(
conditions
,
pageNo
,
pageSize
,
function
(
err
,
results
){
if
(
err
){
console
.
error
(
err
);
...
...
app/controllers/mobile/forumThread.js
View file @
96d68c68
...
...
@@ -18,7 +18,7 @@ var forumLimitOperationService = require('../../service/forumLimitOperationServi
var
forumThreadAttendService
=
require
(
'../../service/forumThreadAttendService'
);
var
commentTips
=
require
(
'../../utils/commentTips'
);
var
httpService
=
require
(
'../../service/httpService'
);
var
forumAboutMEService
=
require
(
'../../service/forumAboutMEService'
);
var
user
=
require
(
'../../utils/user'
);
var
async
=
require
(
'async'
);
module
.
exports
=
function
(
app
)
{
...
...
@@ -181,6 +181,7 @@ router.post('/thread/create', function(req, res, next) {
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
forumAboutMEService
.
saveThread
(
thread
);
forumLimitOperationService
.
checkLimitOperationProhibitionAddIntegral
(
userId
,
function
(
err
,
flag
){
if
(
err
){
console
.
error
(
err
);
...
...
@@ -291,6 +292,9 @@ router.post('/thread/:tid/update', function(req, res, next) {
if
(
err
)
{
res
.
json
(
returnCode
.
BUSY
);
}
else
{
if
(
!
isNaN
(
req
.
body
.
status
)){
forumAboutMEService
.
updateThreadStatus
(
thread
.
_id
,
thread
.
status
)
}
res
.
json
(
returnCode
.
SUCCESS
);
}
});
...
...
@@ -557,6 +561,7 @@ router.post('/thread/:tid/comment/add', function(req, res, next) {
commentTips
.
incrTips
(
req
.
session
.
user
.
ent_code
,
thread
.
from
.
_id
);
forumThreadAttendService
.
threadAttend
(
thread
.
_id
,
user
.
getMobileUser
(
req
),
function
(
err
){});
}
forumAboutMEService
.
saveCommentLevel1
(
thread
,
newComment
);
var
comments
=
thread
.
comments
;
var
array
=
[];
if
(
comments
&&
comments
.
items
&&
comments
.
items
.
length
>
0
)
{
...
...
@@ -699,6 +704,7 @@ router.post('/thread/:tid/comment/create', function(req, res, next) {
commentTips
.
incrTips
(
req
.
session
.
user
.
ent_code
,
thread
.
from
.
_id
);
forumThreadAttendService
.
threadAttend
(
thread
.
_id
,
user
.
getMobileUser
(
req
),
function
(
err
){});
}
forumAboutMEService
.
saveCommentLevel1
(
thread
,
newComment
);
var
comments
=
thread
.
comments
;
// console.log('=========');
// console.log(comments);
...
...
@@ -861,6 +867,7 @@ router.post('/thread/:tid/comment/:cid/create', function(req, res, next) {
commentTips
.
incrTips
(
req
.
session
.
user
.
ent_code
,
req
.
body
.
to
);
forumThreadAttendService
.
threadAttend
(
tid
,
user
.
getMobileUser
(
req
),
function
(
err
){});
}
forumAboutMEService
.
saveCommentLevel2
(
tid
,
comment
,
newComment
);
var
comments
=
comment
.
comments
;
var
array
=
[];
if
(
comments
&&
comments
.
length
>
0
)
{
...
...
@@ -945,6 +952,12 @@ router.post('/thread/:tid/comment/:cid/disable', function(req, res, next) {
if
(
err
)
{
res
.
json
(
returnCode
.
BUSY
);
}
else
{
if
(
comment
&&
comment
.
level
==
1
){
forumAboutMEService
.
updateCommentLevel1Status
(
comment
.
_id
,
comment
.
status
);
}
if
(
comment
&&
comment
.
level
==
2
){
forumAboutMEService
.
updateCommentLevel2Status
(
comment
.
_id
,
comment
.
status
);
}
res
.
json
(
returnCode
.
SUCCESS
);
}
});
...
...
@@ -1365,6 +1378,7 @@ router.post('/thread/:tid/disable', function(req, res, next) {
if
(
err
)
{
res
.
json
(
returnCode
.
BUSY
);
}
else
{
forumAboutMEService
.
updateThreadStatus
(
tid
,
3
);
res
.
json
(
returnCode
.
SUCCESS
);
}
});
...
...
app/models/forumAboutMe.js
0 → 100644
View file @
96d68c68
'use strict'
;
var
mongoose
=
require
(
'mongoose'
),
Schema
=
mongoose
.
Schema
;
//话题评论
var
ForumAboutMeSchema
=
new
Schema
({
ent_code
:
{
type
:
Number
,
require
:
true
,
index
:
true
},
from
:
{
//该记录的作者
type
:
Schema
.
Types
.
ObjectId
,
require
:
true
,
index
:
true
,
ref
:
'ForumUser'
},
to
:
{
//如果是评论, 代表被评论人
type
:
Schema
.
Types
.
ObjectId
,
require
:
false
,
index
:
true
,
ref
:
'ForumUser'
},
type
:{
//分类 1帖子 2一级评论 3二级评论
type
:
Number
,
require
:
true
,
default
:
0
},
thread
:{
//帖子
type
:
Schema
.
Types
.
ObjectId
,
index
:
true
,
ref
:
'ForumThread'
,
require
:
true
},
threadStatus
:{
type
:
Number
},
commentLevel1
:{
//一级评论
type
:
Schema
.
Types
.
ObjectId
,
require
:
false
,
index
:
true
,
ref
:
'ForumComment'
},
commentLevel1Status
:{
type
:
Number
},
commentLevel2
:{
//二级评论
type
:
Schema
.
Types
.
ObjectId
,
require
:
false
,
index
:
true
,
ref
:
'ForumComment'
},
commentLevel2Status
:{
type
:
Number
},
created
:
{
//时间
type
:
Date
,
require
:
true
,
default
:
Date
.
now
}
},
{
'collection'
:
'pisns_forum_about_me'
});
module
.
exports
=
mongoose
.
model
(
'ForumAboutMe'
,
ForumAboutMeSchema
);
\ No newline at end of file
app/service/forumAboutMEService.js
0 → 100644
View file @
96d68c68
'use strict'
;
var
mongoose
=
require
(
'mongoose'
);
var
ForumAboutMe
=
mongoose
.
model
(
'ForumAboutMe'
);
var
THREAD_TYPE
=
1
;
var
COMMENTLEVEL1_TYPE
=
2
;
var
COMMENTLEVEL2_TYPE
=
3
;
var
forumCommentService
=
require
(
'./forumCommentService'
);
var
forumThreadService
=
require
(
'./forumThreadService'
);
exports
.
saveThread
=
function
(
thread
){
var
forumAboutMe
=
new
ForumAboutMe
({
ent_code
:
thread
.
ent_code
,
from
:
thread
.
from
,
type
:
THREAD_TYPE
,
thread
:
thread
.
_id
,
threadStatus
:
thread
.
status
,
created
:
new
Date
()
});
forumAboutMe
.
save
(
function
(
err
){
if
(
err
){
console
.
log
(
err
);
}
});
};
exports
.
saveCommentLevel1
=
function
(
thread
,
commentLevel1
){
var
forumAboutMe
=
new
ForumAboutMe
({
ent_code
:
thread
.
ent_code
,
from
:
commentLevel1
.
from
,
to
:
thread
.
from
,
type
:
COMMENTLEVEL1_TYPE
,
thread
:
thread
.
_id
,
threadStatus
:
thread
.
status
,
commentLevel1
:
commentLevel1
.
_id
,
commentLevel1Status
:
commentLevel1
.
status
,
created
:
new
Date
()
});
forumAboutMe
.
save
(
function
(
err
){
if
(
err
){
console
.
log
(
err
);
}
});
};
exports
.
saveCommentLevel2
=
function
(
tid
,
commentLevel1
,
commentLevel2
){
forumThreadService
.
getById
(
tid
,
function
(
err
,
thread
){
var
forumAboutMe
=
new
ForumAboutMe
({
ent_code
:
commentLevel2
.
ent_code
,
from
:
commentLevel2
.
from
,
to
:
commentLevel2
.
to
,
type
:
COMMENTLEVEL2_TYPE
,
thread
:
thread
.
_id
,
threadStatus
:
thread
.
status
,
commentLevel1
:
commentLevel1
.
_id
,
commentLevel1Status
:
commentLevel1
.
status
,
commentLevel2
:
commentLevel2
.
_id
,
commentLevel2Status
:
commentLevel2
.
status
,
created
:
new
Date
()
});
forumAboutMe
.
save
(
function
(
err
){
if
(
err
){
console
.
log
(
err
);
}
});
});
};
exports
.
saveCommentLevel2BySearch
=
function
(
tid
,
l1id
,
l2id
){
forumThreadService
.
getById
(
tid
,
function
(
err
,
thread
){
if
(
err
||
!
thread
){
return
console
.
log
(
err
||
'没有对应的thread'
);
}
forumCommentService
.
getCommentById
(
l1id
,
function
(
err
,
commentLevel1
){
if
(
err
||
!
commentLevel1
){
return
console
.
log
(
err
||
'没有对应的一级评论'
);
}
forumCommentService
.
getCommentById
(
l2id
,
function
(
err
,
commentLevel2
){
if
(
err
||
!
commentLevel2
){
return
console
.
log
(
err
||
'没有对应的二级评论'
);
}
var
forumAboutMe
=
new
ForumAboutMe
({
ent_code
:
commentLevel2
.
ent_code
,
from
:
commentLevel2
.
from
,
to
:
commentLevel2
.
to
,
type
:
COMMENTLEVEL2_TYPE
,
thread
:
thread
.
_id
,
threadStatus
:
thread
.
status
,
commentLevel1
:
commentLevel1
.
_id
,
commentLevel1Status
:
commentLevel1
.
status
,
commentLevel2
:
commentLevel2
.
_id
,
commentLevel2Status
:
commentLevel2
.
status
,
created
:
new
Date
()
});
forumAboutMe
.
save
(
function
(
err
){
if
(
err
){
console
.
log
(
err
);
}
});
});
});
});
};
exports
.
updateThreadStatus
=
function
(
tid
,
status
){
var
condition
=
{
type
:
THREAD_TYPE
,
thread
:
new
mongoose
.
Types
.
ObjectId
(
tid
),
threadStatus
:{
$ne
:
status
}
}
var
obj
=
{
threadStatus
:
status
};
ForumAboutMe
.
find
(
condition
,
function
(
err
,
docs
){
if
(
err
){
return
console
.
log
(
err
);
}
if
(
!
docs
||
!
docs
.
length
){
return
false
;
}
docs
.
forEach
(
function
(
doc
){
ForumAboutMe
.
findOneAndUpdate
({
_id
:
doc
.
_id
},
obj
,
function
(
err
){
if
(
err
){
console
.
log
(
err
);
}
});
});
});
};
exports
.
updateCommentLevel1Status
=
function
(
cid
,
status
){
var
condition
=
{
type
:
COMMENTLEVEL1_TYPE
,
commentLevel1
:
new
mongoose
.
Types
.
ObjectId
(
cid
),
commentLevel1Status
:{
$ne
:
status
}
}
var
obj
=
{
commentLevel1Status
:
status
};
ForumAboutMe
.
find
(
condition
,
function
(
err
,
docs
){
if
(
err
){
return
console
.
log
(
err
);
}
if
(
!
docs
||
!
docs
.
length
){
return
false
;
}
docs
.
forEach
(
function
(
doc
){
ForumAboutMe
.
findOneAndUpdate
({
_id
:
doc
.
_id
},
obj
,
function
(
err
){
if
(
err
){
console
.
log
(
err
);
}
});
});
});
};
exports
.
updateCommentLevel2Status
=
function
(
cid
,
status
){
var
condition
=
{
type
:
COMMENTLEVEL2_TYPE
,
commentLevel2
:
new
mongoose
.
Types
.
ObjectId
(
cid
),
commentLevel2Status
:{
$ne
:
status
}
}
var
obj
=
{
commentLevel2Status
:
status
};
ForumAboutMe
.
find
(
condition
,
function
(
err
,
docs
){
if
(
err
){
return
console
.
log
(
err
);
}
if
(
!
docs
||
!
docs
.
length
){
return
false
;
}
docs
.
forEach
(
function
(
doc
){
ForumAboutMe
.
findOneAndUpdate
({
_id
:
doc
.
_id
},
obj
,
function
(
err
){
if
(
err
){
console
.
log
(
err
);
}
});
});
});
};
exports
.
me2other
=
function
(
ent_code
,
id
,
pageNo
,
pageSize
,
callback
){
var
condition
=
{
ent_code
:
ent_code
,
from
:
new
mongoose
.
Types
.
ObjectId
(
id
),
$or
:[{
type
:
THREAD_TYPE
,
threadStatus
:
1
},{
type
:
COMMENTLEVEL1_TYPE
,
threadStatus
:
1
,
commentLevel1Status
:
1
},{
type
:
COMMENTLEVEL2_TYPE
,
threadStatus
:
1
,
commentLevel1Status
:
1
,
commentLevel2Status
:
1
}]
};
ForumAboutMe
.
find
(
condition
).
count
(
function
(
err
,
count
){
if
(
err
){
return
callback
&&
callback
(
err
);
}
var
obj
=
{};
obj
.
total
=
count
||
0
;
obj
.
pageNo
=
pageNo
;
obj
.
pageSize
=
pageSize
;
obj
.
items
=
[];
if
(
!
count
){
return
callback
&&
callback
(
null
,
obj
);
}
var
skip
=
(
pageNo
-
1
)
*
pageSize
;
var
limit
=
count
-
skip
>
pageSize
?
pageSize
:
(
count
-
skip
);
var
sortBy
=
'-created'
;
ForumAboutMe
.
find
(
condition
).
populate
({
path
:
'from to'
,
select
:
'uid nickName icon displayName displayIcon classLevel'
}).
populate
({
path
:
'thread'
,
select
:
'-title -topTime -tag_topTime -tag -comments -created'
}).
populate
({
path
:
'commentLevel1 commentLevel2'
,
select
:
'content comment_count praise_count status floor'
}).
limit
(
limit
).
skip
(
skip
).
sort
(
sortBy
).
exec
(
function
(
err
,
docs
)
{
if
(
err
){
return
callback
&&
callback
(
err
);
}
obj
.
items
=
docs
||
[];
return
callback
&&
callback
(
null
,
obj
);
});
});
};
exports
.
other2me
=
function
(
ent_code
,
id
,
pageNo
,
pageSize
,
callback
){
var
condition
=
{
ent_code
:
ent_code
,
to
:
new
mongoose
.
Types
.
ObjectId
(
id
),
$or
:[{
type
:
COMMENTLEVEL1_TYPE
,
threadStatus
:
1
,
commentLevel1Status
:
1
},{
type
:
COMMENTLEVEL2_TYPE
,
threadStatus
:
1
,
commentLevel1Status
:
1
,
commentLevel2Status
:
1
}]
};
ForumAboutMe
.
find
(
condition
).
count
(
function
(
err
,
count
){
if
(
err
){
return
callback
&&
callback
(
err
);
}
var
obj
=
{};
obj
.
total
=
count
||
0
;
obj
.
pageNo
=
pageNo
;
obj
.
pageSize
=
pageSize
;
obj
.
items
=
[];
if
(
!
count
){
return
callback
&&
callback
(
null
,
obj
);
}
var
skip
=
(
pageNo
-
1
)
*
pageSize
;
var
limit
=
count
-
skip
>
pageSize
?
pageSize
:
(
count
-
skip
);
var
sortBy
=
'-created'
;
ForumAboutMe
.
find
(
condition
).
populate
({
path
:
'from to'
,
select
:
'uid nickName icon displayName displayIcon classLevel'
}).
populate
({
path
:
'thread'
,
select
:
'-title -topTime -tag_topTime -tag -comments -created'
}).
populate
({
path
:
'commentLevel1 commentLevel2'
,
select
:
'content comment_count praise_count status floor'
}).
limit
(
limit
).
skip
(
skip
).
sort
(
sortBy
).
exec
(
function
(
err
,
docs
)
{
if
(
err
){
return
callback
&&
callback
(
err
);
}
obj
.
items
=
docs
||
[];
return
callback
&&
callback
(
null
,
obj
);
});
});
};
\ No newline at end of file
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