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
9567247d
Commit
9567247d
authored
Apr 22, 2015
by
邓军
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
标签置顶
parent
21a75806
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
5 deletions
+50
-5
forumTag.js
app/controllers/admin/forumTag.js
+15
-0
forumThread.js
app/controllers/admin/forumThread.js
+1
-2
forumTag.js
app/controllers/mobile/forumTag.js
+4
-1
forumThread.js
app/models/forumThread.js
+8
-0
forumThreadService.js
app/service/forumThreadService.js
+22
-2
No files found.
app/controllers/admin/forumTag.js
View file @
9567247d
...
...
@@ -7,6 +7,7 @@ var mongoose = require('mongoose');
var
ForumTag
=
mongoose
.
model
(
'ForumTag'
);
var
forumTagService
=
require
(
'../../service/forumTagService'
);
var
forumThreadService
=
require
(
'../../service/forumThreadService'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/admin/forum'
,
router
);
...
...
@@ -27,6 +28,20 @@ router.post('/tag/create', function(req, res, next) {
});
});
//标签置顶
router
.
get
(
'/tag/:tid/top'
,
function
(
req
,
res
,
next
){
var
tid
=
req
.
params
.
tid
;
var
tag_top
=
req
.
query
.
tag_top
;
forumThreadService
.
updateTagTop
(
tid
,
tag_top
,
function
(
err
,
result
){
if
(
err
){
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
_
.
assign
(
result
,
returnCode
.
SUCCESS
));
}
});
});
//删除论坛标签
router
.
post
(
'/tag/:tid/delete'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
params
.
tid
;
...
...
app/controllers/admin/forumThread.js
View file @
9567247d
...
...
@@ -289,8 +289,7 @@ router.post('/thread/comment/update/:cid/comments',function(req,res,next){
callback
(
err
,
null
);
}
else
{
var
commentList
=
result
.
comments
;
console
.
log
(
'准备插入:'
+
replayComment_id
);
console
.
log
(
result
.
_id
);
result
.
comments
.
push
(
replayComment_id
);
...
...
app/controllers/mobile/forumTag.js
View file @
9567247d
...
...
@@ -51,11 +51,14 @@ router.get('/tag/mobileList', function(req, res, next) {
});
});
//查询标签下的文章列表
router
.
get
(
'/tag/:tid/threads'
,
function
(
req
,
res
,
next
)
{
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
var
tid
=
req
.
params
.
tid
;
var
sort
=
req
.
query
.
sort
||
''
;
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
};
...
...
@@ -84,7 +87,7 @@ router.get('/tag/:tid/threads', function(req, res, next) {
if
(
result
){
conditions
.
_id
=
{
$nin
:
result
.
thread
};
}
forumThreadService
.
getAllThreadByFid
(
conditions
,
pageNo
,
pageSize
,
null
,
function
(
err
,
results
){
forumThreadService
.
getAllThreadByFid
(
conditions
,
pageNo
,
pageSize
,
sort
,
function
(
err
,
results
){
if
(
err
){
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
...
...
app/models/forumThread.js
View file @
9567247d
...
...
@@ -60,6 +60,14 @@ var ForumThreadSchema = new Schema({
},
topTime
:{
//置顶时间
type
:
Date
}
,
tag_top
:
{
//标签话题是否置顶0否,1是
type
:
Number
,
require
:
true
,
default
:
0
},
tag_topTime
:{
//标签话题置顶时间
type
:
Date
},
tag
:
[{
type
:
Schema
.
Types
.
ObjectId
,
ref
:
'ForumTag'
}],
//话题归属标签,
comments
:
[{
type
:
Schema
.
Types
.
ObjectId
,
ref
:
'ForumComment'
}],
//评论内容列表
...
...
app/service/forumThreadService.js
View file @
9567247d
...
...
@@ -9,7 +9,7 @@ var forumCommentService = require('./forumCommentService');
var
async
=
require
(
'async'
);
var
then
=
require
(
'thenjs'
);
//
查询帖子
//
根据发帖者分页查询话题列表
exports
.
findThreadByPage
=
function
(
pageNo
,
pageSize
,
q
,
callback
)
{
then
(
function
(
cont
)
{
ForumThread
.
find
(
q
).
populate
(
'from'
).
count
(
cont
);
...
...
@@ -476,7 +476,7 @@ function getAllThreadByFidHelp(conditions, pageNo, pageSize, sort, callback) {
}
else
{
var
skip
=
(
pageNo
-
1
)
*
pageSize
;
var
limit
=
count
-
skip
>
pageSize
?
pageSize
:
(
count
-
skip
);
var
sortBy
=
'-topTime -created'
;
var
sortBy
=
'-topTime -
tag_topTime -
created'
;
if
(
sort
)
{
sortBy
=
sort
;
}
...
...
@@ -585,6 +585,26 @@ exports.updateUnTopByThreadId = function(infoId, threadId, callback) {
});
};
//根据板块ID更新标签置顶(置顶)
exports
.
updateTagTop
=
function
(
tid
,
tag_top
,
callback
){
var
time
=
''
;
if
(
tag_top
==
1
){
time
=
new
Date
();
}
ForumThread
.
findOneAndUpdate
({
_id
:
tid
},
{
tag_top
:
tag_top
,
tag_topTime
:
time
},
function
(
err
,
doc
)
{
if
(
err
)
{
callback
(
err
,
null
);
}
else
{
callback
(
null
,
doc
);
}
});
};
//更新文章点赞数
exports
.
updateThreadRaiseCount
=
function
(
threadId
,
callback
)
{
ForumThread
.
update
({
...
...
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