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
8230d29a
Commit
8230d29a
authored
May 12, 2016
by
刘文胜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
帖子管理 - 列表查询 接口
parent
46bfc13e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
136 additions
and
0 deletions
+136
-0
forumThreadManagement.js
app/controllers/admin/forumThreadManagement.js
+136
-0
No files found.
app/controllers/admin/forumThreadManagement.js
0 → 100644
View file @
8230d29a
'use strict'
;
//插件
var
router
=
require
(
'express'
).
Router
(),
returnCode
=
require
(
'../../utils/returnCode'
),
_
=
require
(
'lodash'
),
then
=
require
(
'thenjs'
),
moment
=
require
(
'moment'
),
mongoose
=
require
(
'mongoose'
),
async
=
require
(
'async'
);
//模型
var
ForumThread
=
mongoose
.
model
(
'ForumThread'
),
ForumPVLog
=
mongoose
.
model
(
'ForumPVLog'
);
//服务
var
forumThreadService
=
require
(
'../../service/forumThreadService'
),
forumUserService
=
require
(
'../../service/forumUserService'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/admin/forum'
,
router
);
};
//格式化日期 (格式:年-月-日)
function
date_format
(
date
)
{
return
moment
(
date
).
format
(
'YYYY-MM-DD hh:mm:ss'
);
}
//文章列表
router
.
get
(
'/threadManagement/threads/list'
,
function
(
req
,
res
,
next
)
{
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
var
infoId
=
req
.
query
.
infoId
;
var
tagId
=
req
.
query
.
tagId
;
var
pid
=
req
.
query
.
pid
;
//父文章id
var
content
=
req
.
query
.
content
;
//标题 或 内容
var
type
=
req
.
query
.
type
;
//1普通文章,话题,照片墙
var
nickName
=
req
.
query
.
nickName
;
var
mid
=
req
.
query
.
mid
;
var
begin_time
=
req
.
query
.
begin_time
;
var
end_time
=
req
.
query
.
end_time
;
var
tab
=
req
.
query
.
tab
;
//全部,官方贴,推荐贴,置顶帖,加精贴,活动贴,屏蔽贴
var
sortBy
=
{
//默认排序
created
:
-
1
};
if
(
req
.
query
.
sort
){
//指定排序字段
sortBy
=
({}[
req
.
query
.
sort
]
=
-
1
);
}
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
,
level
:
1
,
status
:
{
$ne
:
3
}
};
if
(
infoId
)
{
conditions
.
info
=
infoId
;
}
if
(
tagId
)
{
conditions
.
tag
=
{
$in
:
[
tagId
]
};
}
if
(
pid
)
{
conditions
.
pid
=
pid
;
conditions
.
level
=
2
;
}
if
(
content
)
{
conditions
.
$or
=
[
{
title
:{
$regex
:
content
,
$options
:
'i'
}
},
{
content
:{
$regex
:
content
,
$options
:
'i'
}
}
];
}
if
(
type
)
{
conditions
.
type
=
Number
(
type
);
}
if
(
tab
){
if
(
tab
===
'admin'
){
//官方贴
conditions
.
isPublishByBg
=
1
;
}
else
if
(
tab
===
'new_recommend'
){
//推荐贴
conditions
.
new_recommend
=
1
;
}
else
if
(
tab
===
'top'
){
//置顶贴
conditions
.
top
=
1
;
}
else
if
(
tab
===
'recommend'
){
//加精贴
conditions
.
recommend
=
1
;
}
else
if
(
tab
===
'event'
){
//活动贴
conditions
.
isEvent
=
1
;
}
else
if
(
tab
===
'closed'
){
//屏蔽贴
conditions
.
status
=
0
;
}
}
if
(
begin_time
&&
end_time
){
conditions
.
created
=
{
$gte
:
begin_time
,
$lte
:
end_time
};
}
else
if
(
end_time
){
conditions
.
created
=
{
$lte
:
end_time
};
}
else
if
(
begin_time
){
conditions
.
created
=
{
$gte
:
begin_time
};
}
var
callback
=
function
(
err
,
results
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
if
(
pid
)
{
forumThreadService
.
getById
(
pid
,
function
(
err
,
parentThread
)
{
res
.
json
(
_
.
assign
({
parentThread
:
parentThread
},
results
,
returnCode
.
SUCCESS
));
});
}
else
{
res
.
json
(
_
.
assign
(
results
,
returnCode
.
SUCCESS
));
}
}
};
if
(
mid
)
{
forumThreadService
.
getAllThreadByFidAndMid
(
mid
,
conditions
,
pageNo
,
pageSize
,
sortBy
,
callback
);
}
else
if
(
nickName
)
{
forumThreadService
.
getAllThreadByFidAndNickName
(
nickName
,
conditions
,
pageNo
,
pageSize
,
sortBy
,
callback
);
}
else
{
forumThreadService
.
getAllThreadByFid
(
conditions
,
pageNo
,
pageSize
,
sortBy
,
callback
);
}
});
\ 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