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
5673127d
Commit
5673127d
authored
Sep 15, 2015
by
刘文胜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
11
parent
65eddaa0
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
141 additions
and
51 deletions
+141
-51
forumThread.js
app/controllers/admin/forumThread.js
+9
-0
forumAboutMe.js
app/controllers/mobile/forumAboutMe.js
+4
-0
forumModerator.js
app/controllers/mobile/forumModerator.js
+2
-0
forumThread.js
app/controllers/mobile/forumThread.js
+10
-0
forumAboutMe.js
app/models/forumAboutMe.js
+9
-1
forumAboutMEService.js
app/service/forumAboutMEService.js
+107
-50
No files found.
app/controllers/admin/forumThread.js
View file @
5673127d
...
...
@@ -225,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
,
...
...
@@ -574,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
();
}
}
...
...
app/controllers/mobile/forumAboutMe.js
View file @
5673127d
...
...
@@ -15,6 +15,8 @@ router.get('/aboutme/me2other', function(req, res, next) {
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
));
...
...
@@ -29,6 +31,8 @@ router.get('/aboutme/other2me', function(req, res, next) {
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
));
...
...
app/controllers/mobile/forumModerator.js
View file @
5673127d
...
...
@@ -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/forumThread.js
View file @
5673127d
...
...
@@ -292,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
);
}
});
...
...
@@ -949,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
);
}
});
...
...
@@ -1369,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
View file @
5673127d
...
...
@@ -32,18 +32,27 @@ var ForumAboutMeSchema = new Schema({
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
,
...
...
@@ -53,5 +62,4 @@ var ForumAboutMeSchema = new Schema({
'collection'
:
'pisns_forum_about_me'
});
module
.
exports
=
mongoose
.
model
(
'ForumAboutMe'
,
ForumAboutMeSchema
);
\ No newline at end of file
app/service/forumAboutMEService.js
View file @
5673127d
...
...
@@ -5,12 +5,14 @@ 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
){
...
...
@@ -27,7 +29,9 @@ exports.saveCommentLevel1=function(thread,commentLevel1){
to
:
commentLevel1
.
to
,
type
:
COMMENTLEVEL1_TYPE
,
thread
:
thread
.
_id
,
threadStatus
:
thread
.
status
,
commentLevel1
:
commentLevel1
.
_id
,
commentLevel1Status
:
commentLevel1
.
status
,
created
:
new
Date
()
});
forumAboutMe
.
save
(
function
(
err
){
...
...
@@ -38,96 +42,149 @@ exports.saveCommentLevel1=function(thread,commentLevel1){
};
exports
.
saveCommentLevel2
=
function
(
tid
,
commentLevel1
,
commentLevel2
){
var
forumAboutMe
=
new
ForumAboutMe
({
ent_code
:
commentLevel2
.
ent_code
,
from
:
commentLevel2
.
from
,
to
:
commentLevel2
.
to
,
type
:
COMMENTLEVEL2_TYPE
,
thread
:
tid
,
commentLevel1
:
commentLevel1
.
_id
,
commentLevel2
:
commentLevel2
.
_id
,
created
:
new
Date
()
});
forumAboutMe
.
save
(
function
(
err
){
if
(
err
){
console
.
log
(
err
);
}
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
){
forum
CommentService
.
getCommentById
(
l2id
,
function
(
err
,
commentLevel2
){
if
(
err
){
return
console
.
log
(
err
);
forum
ThreadService
.
getById
(
tid
,
function
(
err
,
thread
){
if
(
err
||
!
thread
){
return
console
.
log
(
err
||
'没有对应的thread'
);
}
if
(
commentLevel2
){
var
forumAboutMe
=
new
ForumAboutMe
({
ent_code
:
commentLevel2
.
ent_code
,
from
:
commentLevel2
.
from
,
to
:
commentLevel2
.
to
,
type
:
COMMENTLEVEL2_TYPE
,
thread
:
tid
,
commentLevel1
:
l1id
,
commentLevel2
:
l2id
,
created
:
new
Date
()
});
forumAboutMe
.
save
(
function
(
err
){
if
(
err
){
console
.
log
(
err
);
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){
exports
.
updateThreadStatus
=
function
(
tid
,
status
){
var
condition
=
{
type
:
THREAD_TYPE
,
thread:tid
thread
:
new
mongoose
.
Types
.
ObjectId
(
tid
),
threadStatus
:{
$ne
:
status
}
}
ForumAboutMe.findOneAndUpdate(condition,{threadStatus:status},function(err){
var
obj
=
{
threadStatus
:
status
};
ForumAboutMe
.
find
(
condition
,
function
(
err
,
docs
){
if
(
err
){
console.log(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:cid
commentLevel1
:
new
mongoose
.
Types
.
ObjectId
(
cid
),
commentLevel1Status
:{
$ne
:
status
}
}
ForumAboutMe.findOneAndUpdate(condition,{commentLevel1Status:status},function(err){
var
obj
=
{
commentLevel1Status
:
status
};
ForumAboutMe
.
find
(
condition
,
function
(
err
,
docs
){
if
(
err
){
console.log(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:cid
commentLevel2
:
new
mongoose
.
Types
.
ObjectId
(
cid
),
commentLevel2Status
:{
$ne
:
status
}
}
ForumAboutMe.findOneAndUpdate(condition,{commentLevel2Status:status},function(err){
var
obj
=
{
commentLevel2Status
:
status
};
ForumAboutMe
.
find
(
condition
,
function
(
err
,
docs
){
if
(
err
){
console.log(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
:
id
,
from
:
new
mongoose
.
Types
.
ObjectId
(
id
)
,
$or
:[{
type
:
THREAD_TYPE
,
'thread.status'
:
1
type
:
THREAD_TYPE
,
threadStatus
:
1
},{
type
:
COMMENTLEVEL1_TYPE
,
'commentLevel1.status'
:
1
type
:
COMMENTLEVEL1_TYPE
,
threadStatus
:
1
,
commentLevel1Status
:
1
},{
type
:
COMMENTLEVEL2_TYPE
,
'commentLevel2.status'
:
1
type
:
COMMENTLEVEL2_TYPE
,
threadStatus
:
1
,
commentLevel1Status
:
1
,
commentLevel2Status
:
1
}]
};
ForumAboutMe
.
find
(
condition
).
count
(
function
(
err
,
count
){
if
(
err
){
return
callback
&&
callback
(
err
);
...
...
@@ -165,11 +222,11 @@ exports.me2other=function(ent_code,id,pageNo,pageSize,callback){
exports
.
other2me
=
function
(
ent_code
,
id
,
pageNo
,
pageSize
,
callback
){
var
condition
=
{
ent_code
:
ent_code
,
to
:
id
,
to
:
new
mongoose
.
Types
.
ObjectId
(
id
)
,
$or
:[{
type
:
COMMENTLEVEL1_TYPE
,
'commentLevel1.status'
:
1
type
:
COMMENTLEVEL1_TYPE
,
threadStatus
:
1
,
commentLevel1Status
:
1
},{
type
:
COMMENTLEVEL2_TYPE
,
'commentLevel2.status'
:
1
type
:
COMMENTLEVEL2_TYPE
,
threadStatus
:
1
,
commentLevel1Status
:
1
,
commentLevel2Status
:
1
}]
};
ForumAboutMe
.
find
(
condition
).
count
(
function
(
err
,
count
){
...
...
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