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
7c887285
Commit
7c887285
authored
May 31, 2016
by
刘文胜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
升级lodash到3.10 帖子管理接口 新增批量屏蔽,删除帖子(查询结果), 帖子评论批量屏蔽,删除(查询结果)
parent
40607f9e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
508 additions
and
2 deletions
+508
-2
forumThreadManagement.js
app/controllers/admin/forumThreadManagement.js
+507
-1
package.json
package.json
+1
-1
No files found.
app/controllers/admin/forumThreadManagement.js
View file @
7c887285
...
...
@@ -141,6 +141,332 @@ router.get('/threadManagement/threads/list', function(req, res, next) {
}
});
//删除查询结果的所有帖子
router
.
post
(
'/threadManagement/threads/list/deleteAll'
,
function
(
req
,
res
,
next
)
{
var
infoId
=
req
.
body
.
infoId
;
var
tagId
=
req
.
body
.
tagId
;
var
pid
=
req
.
body
.
pid
;
//父文章id
var
content
=
req
.
body
.
content
;
//标题 或 内容
var
type
=
req
.
body
.
type
;
//1普通文章,话题,照片墙
var
nickName
=
req
.
body
.
nickName
;
var
mid
=
req
.
body
.
mid
;
var
begin_time
=
req
.
body
.
begin_time
;
var
end_time
=
req
.
body
.
end_time
;
var
tab
=
req
.
body
.
tab
;
//全部,官方贴,推荐贴,置顶帖,加精贴,活动贴,屏蔽贴
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
,
result
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
_
.
assign
({
data
:
result
},
returnCode
.
SUCCESS
));
}
};
var
deleteAll
=
function
(
condition
,
callback
){
ForumThread
.
find
(
conditions
).
select
(
'_id'
).
exec
(
function
(
err
,
docs
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
var
_tasks
=
[];
_
.
forEach
(
docs
,
function
(
doc
){
_tasks
.
push
(
function
(
cb
){
forumThreadService
.
logicDeleteThreadById
(
doc
.
_id
,
function
(
err
)
{
if
(
err
)
{
cb
(
err
,
null
);
}
else
{
forumAboutMEService
.
updateThreadStatus
(
doc
.
_id
,
3
);
cb
(
null
,
true
);
}
});
});
});
var
chunks
=
_
.
chunk
(
_tasks
,
100
);
var
tasks
=
[];
_
.
forEach
(
chunks
,
function
(
chunk
){
tasks
.
push
(
function
(
cb
){
async
.
parallel
(
chunk
,
function
(
err
){
cb
(
err
,
true
);
});
});
});
async
.
series
(
tasks
,
function
(
err
){
callback
(
err
,
true
);
});
}
});
};
if
(
mid
)
{
forumUserService
.
searchMembersByMid
(
mid
,
function
(
err
,
users
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
//查询对应用户的文章
var
user_ids
=
[];
for
(
var
i
in
users
){
user_ids
.
push
(
users
[
i
].
_id
);
}
conditions
.
from
=
{
"$in"
:
user_ids
};
deleteAll
(
conditions
,
callback
);
}
});
}
else
if
(
nickName
)
{
//查询到用户
forumUserService
.
searchMembersByNickName
(
nickName
,
function
(
err
,
users
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
//查询对应用户的文章
var
user_ids
=
[];
for
(
var
i
in
users
){
user_ids
.
push
(
users
[
i
].
_id
);
}
conditions
.
from
=
{
"$in"
:
user_ids
};
deleteAll
(
conditions
,
callback
);
}
});
}
else
{
deleteAll
(
conditions
,
callback
);
}
});
//屏蔽查询结果的所有帖子
router
.
post
(
'/threadManagement/threads/list/closeAll'
,
function
(
req
,
res
,
next
)
{
var
infoId
=
req
.
body
.
infoId
;
var
tagId
=
req
.
body
.
tagId
;
var
pid
=
req
.
body
.
pid
;
//父文章id
var
content
=
req
.
body
.
content
;
//标题 或 内容
var
type
=
req
.
body
.
type
;
//1普通文章,话题,照片墙
var
nickName
=
req
.
body
.
nickName
;
var
mid
=
req
.
body
.
mid
;
var
begin_time
=
req
.
body
.
begin_time
;
var
end_time
=
req
.
body
.
end_time
;
var
tab
=
req
.
body
.
tab
;
//全部,官方贴,推荐贴,置顶帖,加精贴,活动贴,屏蔽贴
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
,
result
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
_
.
assign
({
data
:
result
},
returnCode
.
SUCCESS
));
}
};
var
closeAll
=
function
(
condition
,
callback
){
ForumThread
.
find
(
conditions
).
select
(
'_id'
).
exec
(
function
(
err
,
docs
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
var
_tasks
=
[];
_
.
forEach
(
docs
,
function
(
doc
){
_tasks
.
push
(
function
(
cb
){
forumThreadService
.
updateThreadById
(
doc
.
_id
,
{
status
:
0
},
function
(
err
)
{
if
(
err
)
{
cb
(
err
,
null
);
}
else
{
forumAboutMEService
.
updateThreadStatus
(
doc
.
_id
,
0
);
cb
(
null
,
true
);
}
});
});
});
var
chunks
=
_
.
chunk
(
_tasks
,
100
);
var
tasks
=
[];
_
.
forEach
(
chunks
,
function
(
chunk
){
tasks
.
push
(
function
(
cb
){
async
.
parallel
(
chunk
,
function
(
err
){
cb
(
err
,
true
);
});
});
});
async
.
series
(
tasks
,
function
(
err
){
callback
(
err
,
true
);
});
}
});
};
if
(
mid
)
{
forumUserService
.
searchMembersByMid
(
mid
,
function
(
err
,
users
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
//查询对应用户的文章
var
user_ids
=
[];
for
(
var
i
in
users
){
user_ids
.
push
(
users
[
i
].
_id
);
}
conditions
.
from
=
{
"$in"
:
user_ids
};
closeAll
(
conditions
,
callback
);
}
});
}
else
if
(
nickName
)
{
//查询到用户
forumUserService
.
searchMembersByNickName
(
nickName
,
function
(
err
,
users
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
//查询对应用户的文章
var
user_ids
=
[];
for
(
var
i
in
users
){
user_ids
.
push
(
users
[
i
].
_id
);
}
conditions
.
from
=
{
"$in"
:
user_ids
};
closeAll
(
conditions
,
callback
);
}
});
}
else
{
closeAll
(
conditions
,
callback
);
}
});
//获取帖子总数,帖子数,用户发帖数,帖子加精数
router
.
get
(
'/threadManagement/threads/statistics'
,
function
(
req
,
res
,
next
)
{
var
infoId
=
req
.
query
.
infoId
;
...
...
@@ -576,7 +902,7 @@ router.get('/threadManagement/threads/:tid/comment/search', function(req, res, n
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
,
thread
:
tid
,
level
:
1
,
level
:
1
};
if
(
content
)
{
conditions
.
content
=
{
...
...
@@ -617,6 +943,186 @@ router.get('/threadManagement/threads/:tid/comment/search', function(req, res, n
}
});
//删除帖子的评论(查询结果)
router
.
post
(
'/threadManagement/threads/:tid/comment/search/deleteAll'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
params
.
tid
||
null
,
mid
=
req
.
query
.
mid
,
floor_start
=
req
.
query
.
floor_start
,
floor_end
=
req
.
query
.
floor_end
,
content
=
req
.
query
.
content
||
''
;
var
ent_code
=
req
.
session
.
user
.
ent_code
;
var
status
=
2
;
//删除状态为2
var
conditions
=
{
ent_code
:
ent_code
,
thread
:
tid
,
level
:
1
};
if
(
content
)
{
conditions
.
content
=
{
$regex
:
content
,
$options
:
'i'
};
}
if
(
floor_start
){
conditions
.
floor
=
{
$gte
:
floor_start
};
}
if
(
floor_end
){
conditions
.
floor
=
{
$lte
:
floor_end
};
}
var
callback
=
function
(
err
,
result
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
_
.
assign
({
data
:
result
},
returnCode
.
SUCCESS
));
}
};
var
deleteAll
=
function
(
condition
,
callback
){
ForumComment
.
find
(
conditions
).
select
(
'_id'
).
exec
(
function
(
err
,
docs
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
var
ids
=
[];
_
.
forEach
(
docs
,
function
(
doc
){
ids
.
push
(
doc
.
_id
);
});
var
chunks
=
_
.
chunk
(
ids
,
100
);
var
tasks
=
[];
_
.
forEach
(
chunks
,
function
(
chunk
){
tasks
.
push
(
function
(
cb
){
batchUpdateCommentStatus
(
ent_code
,
chunk
,
status
,
function
(
err
,
result
){
cb
(
err
,
result
);
});
});
});
async
.
series
(
tasks
,
function
(
err
){
callback
(
err
,
true
);
});
}
});
};
if
(
tid
&&
mid
)
{
forumUserService
.
searchMembersByMid
(
mid
,
function
(
err
,
users
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
//查询对应用户
var
user_ids
=
[];
for
(
var
i
in
users
)
{
user_ids
.
push
(
users
[
i
].
_id
);
}
conditions
.
from
=
{
$in
:
user_ids
}
deleteAll
(
conditions
,
callback
);
}
});
}
else
if
(
tid
){
deleteAll
(
conditions
,
callback
);
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
//屏蔽帖子的评论(查询结果)
router
.
post
(
'/threadManagement/threads/:tid/comment/search/closeAll'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
params
.
tid
||
null
,
mid
=
req
.
query
.
mid
,
floor_start
=
req
.
query
.
floor_start
,
floor_end
=
req
.
query
.
floor_end
,
content
=
req
.
query
.
content
||
''
;
var
ent_code
=
req
.
session
.
user
.
ent_code
;
var
status
=
0
;
//屏蔽的状态为0
var
conditions
=
{
ent_code
:
ent_code
,
thread
:
tid
,
level
:
1
};
if
(
content
)
{
conditions
.
content
=
{
$regex
:
content
,
$options
:
'i'
};
}
if
(
floor_start
){
conditions
.
floor
=
{
$gte
:
floor_start
};
}
if
(
floor_end
){
conditions
.
floor
=
{
$lte
:
floor_end
};
}
var
callback
=
function
(
err
,
result
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
_
.
assign
({
data
:
result
},
returnCode
.
SUCCESS
));
}
};
var
closeAll
=
function
(
condition
,
callback
){
ForumComment
.
find
(
conditions
).
select
(
'_id'
).
exec
(
function
(
err
,
docs
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
var
ids
=
[];
_
.
forEach
(
docs
,
function
(
doc
){
ids
.
push
(
doc
.
_id
);
});
var
chunks
=
_
.
chunk
(
ids
,
100
);
var
tasks
=
[];
_
.
forEach
(
chunks
,
function
(
chunk
){
tasks
.
push
(
function
(
cb
){
batchUpdateCommentStatus
(
ent_code
,
chunk
,
status
,
function
(
err
,
result
){
cb
(
err
,
result
);
});
});
});
async
.
series
(
tasks
,
function
(
err
){
callback
(
err
,
true
);
});
}
});
};
if
(
tid
&&
mid
)
{
forumUserService
.
searchMembersByMid
(
mid
,
function
(
err
,
users
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
//查询对应用户
var
user_ids
=
[];
for
(
var
i
in
users
)
{
user_ids
.
push
(
users
[
i
].
_id
);
}
conditions
.
from
=
{
$in
:
user_ids
}
closeAll
(
conditions
,
callback
);
}
});
}
else
if
(
tid
){
closeAll
(
conditions
,
callback
);
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
});
//查询帖子的收藏数
router
.
get
(
'/threadManagement/threads/:tid/collects'
,
function
(
req
,
res
,
next
)
{
var
tid
=
req
.
params
.
tid
||
null
;
...
...
package.json
View file @
7c887285
...
...
@@ -19,7 +19,7 @@
"
glob
"
:
"
~4.3.1
"
,
"
gridfs-stream
"
:
"
^1.1.0
"
,
"
hiredis
"
:
"
^0.4.0
"
,
"
lodash
"
:
"
~
2.4
.1
"
,
"
lodash
"
:
"
~
3.10
.1
"
,
"
method-override
"
:
"
~2.3.0
"
,
"
moment
"
:
"
^2.10.6
"
,
"
mongoose
"
:
"
^4.1.0
"
,
...
...
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