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
465aa545
Commit
465aa545
authored
Aug 27, 2015
by
刘文胜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
我的评论
parent
ed71dc9d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
110 additions
and
0 deletions
+110
-0
forumInfo.js
app/controllers/mobile/forumInfo.js
+69
-0
forumCommentService.js
app/service/forumCommentService.js
+41
-0
No files found.
app/controllers/mobile/forumInfo.js
View file @
465aa545
...
...
@@ -10,6 +10,7 @@ var forumInfoService = require('../../service/forumInfoService');
var
forumThreadService
=
require
(
'../../service/forumThreadService'
);
var
forumUserThreadControlService
=
require
(
'../../service/forumUserThreadControlService'
);
var
forumTagService
=
require
(
'../../service/forumTagService'
);
var
forumCommentService
=
require
(
'../../service/forumCommentService'
);
var
httpService
=
require
(
'../../service/httpService'
);
var
user
=
require
(
'../../utils/user'
);
...
...
@@ -364,6 +365,74 @@ router.get('/info/:fid/myThreads', function(req, res, next) {
}
});
//获取我的文章列表
router
.
get
(
'/info/myThreads'
,
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
:
user
.
getMobileUser
(
req
)
};
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
,
'-praise_count'
,
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
;
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
var
id
=
user
.
getMobileUser
(
req
);
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
,
$or
:[{
from
:
id
},{
to
:
id
}]
};
forumCommentService
.
getMyComment
(
conditions
,
pageNo
,
pageSize
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
_
.
assign
(
results
,
returnCode
.
SUCCESS
));
}
});
});
//搜索文章列表
router
.
get
(
'/info/:fid/serachThreads'
,
function
(
req
,
res
,
next
)
{
var
fid
=
req
.
params
.
fid
||
null
;
...
...
app/service/forumCommentService.js
View file @
465aa545
...
...
@@ -289,3 +289,44 @@ exports.getCommentParent = function(cid,callback){
callback
(
err
,
doc
);
});
};
//我的评论
var
countMyComment
=
function
(
conditions
,
callback
)
{
ForumComment
.
find
(
conditions
)
.
count
(
conditions
,
function
(
err
,
count
)
{
if
(
err
){
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
count
);
}
});
};
//我的评论
exports
.
getMyComment
=
function
(
conditions
,
pageNo
,
pageSize
,
callback
){
countMyComment
(
conditions
,
function
(
err
,
count
){
if
(
err
){
callback
(
err
);
}
else
{
var
skip
=
(
pageNo
-
1
)
*
pageSize
;
var
limit
=
count
-
skip
>
pageSize
?
pageSize
:
(
count
-
skip
);
ForumComment
.
find
(
conditions
)
.
populate
(
'thread'
).
populate
(
'from'
).
populate
(
'to'
).
limit
(
limit
).
skip
(
skip
).
sort
(
'-created'
).
exec
(
function
(
err
,
docs
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
var
obj
=
{};
obj
.
total
=
count
;
obj
.
pageNo
=
pageNo
;
obj
.
pageSize
=
pageSize
;
obj
.
items
=
docs
;
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