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
941423a0
Commit
941423a0
authored
Mar 16, 2016
by
strong
Browse files
Options
Browse Files
Download
Plain Diff
Merge commit '
07b5828e
'
parents
14e9e276
07b5828e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
127 additions
and
59 deletions
+127
-59
forumThread.js
app/controllers/mobile/forumThread.js
+111
-56
forumModeratorApplyService.js
app/service/forumModeratorApplyService.js
+12
-0
forumThreadService.js
app/service/forumThreadService.js
+4
-3
No files found.
app/controllers/mobile/forumThread.js
View file @
941423a0
...
...
@@ -24,6 +24,7 @@ var user = require('../../utils/user');
var
floorGenerator
=
require
(
'../../utils/floorGenerator'
);
var
async
=
require
(
'async'
);
var
ForumModeratorApply
=
mongoose
.
model
(
'ForumModeratorApply'
);
var
forumModeratorApplyService
=
require
(
'../../service/forumModeratorApplyService'
);
var
redisThreadList
=
require
(
'../../utils/redisThreadList'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/v1/forum'
,
router
);
...
...
@@ -71,7 +72,7 @@ function create(req, callback) {
level
:
'2'
,
pid
:
entity
.
pid
,
from
:
entity
.
from
,
status
:
{
$ne
:
3
}
status
:
1
},
function
(
err
,
doc
)
{
if
(
doc
)
{
var
update
=
{
...
...
@@ -79,7 +80,8 @@ function create(req, callback) {
images
:
entity
.
images
,
content
:
entity
.
content
,
tag
:
entity
.
tag
,
address
:
entity
.
address
address
:
entity
.
address
,
title
:
entity
.
title
}
};
forumThreadService
.
updateThreadById
(
doc
.
_id
,
update
,
function
(
err
,
updatedDoc
)
{
...
...
@@ -638,7 +640,7 @@ router.get('/thread/photo/:pid/get', function(req, res, next) {
level
:
'2'
,
pid
:
pid
,
from
:
userId
,
status
:
{
$ne
:
3
}
status
:
1
},
function
(
err
,
thread
)
{
if
(
err
)
{
console
.
error
(
err
);
...
...
@@ -1210,7 +1212,7 @@ router.post('/thread/:tid/comment/:cid/create', function(req, res, next) {
}
});
});
//更改评论状态为
3
(删除)
//更改评论状态为
2
(删除)
router
.
post
(
'/thread/:tid/comment/:cid/disable'
,
function
(
req
,
res
,
next
)
{
var
user_id
=
user
.
getMobileUser
(
req
),
tid
=
req
.
params
.
tid
,
...
...
@@ -1259,29 +1261,44 @@ router.post('/thread/:tid/comment/:cid/slash', function(req, res, next) {
},
{
recommend
:
null
}];
ForumThread
.
findOne
(
q1
).
populate
(
'from'
).
exec
(
function
(
err
,
t
)
{
if
(
err
||
!
t
)
{
return
res
.
json
(
returnCode
.
BUSY
);
}
if
(
!
t
.
info
){
//没有板块id直接返回
return
res
.
json
(
returnCode
.
BUSY
);
async
.
waterfall
([
function
(
callback
)
{
forumThreadService
.
getByConditions
(
q1
,
function
(
err
,
doc
)
{
//查询文章
if
(
err
||
!
doc
||
!
doc
.
info
)
{
callback
(
err
,
null
);
}
else
{
callback
(
null
,
doc
);
}
});
},
function
(
thread
,
callback
)
{
var
q2
=
{};
//查询当前用户是不是这篇文章的版主
q2
.
status
=
1
;
q2
.
ent_code
=
entCode
;
q2
.
forumUser
=
userid
;
q2
.
infoIds
=
{
$all
:[
t
.
info
]};
ForumModeratorApply
.
findOne
(
q2
).
populate
(
'forumUser'
).
exec
(
function
(
err
,
result
){
if
(
err
){
return
res
.
json
(
returnCode
.
BUSY
);
}
if
(
!
result
){
//不是该版主
return
res
.
json
(
returnCode
.
ACTION_NOT_PERMISSION
);
q2
.
infoIds
=
{
$all
:[
thread
.
info
]};
forumModeratorApplyService
.
getForumModeratorApplyByConditions
(
q2
,
function
(
err
,
doc
)
{
if
(
err
)
{
callback
(
err
,
null
);
}
else
{
callback
(
null
,
doc
);
}
//
});
},
function
(
forumModerator
,
callback
)
{
//查询评论
forumCommentService
.
getCommentById
(
cid
,
function
(
err
,
comment
)
{
if
(
comment
&&
userid
)
{
//屏蔽
if
(
err
)
{
callback
(
err
,
null
,
null
);
}
else
{
callback
(
null
,
forumModerator
,
comment
);
}
});
}
],
function
(
err
,
forumModerator
,
comment
)
{
if
(
err
){
res
.
json
(
returnCode
.
BUSY
);
}
else
if
(
forumModerator
&&
comment
){
//版主屏蔽
forumCommentService
.
changeStatus
(
cid
,
0
,
function
(
err
,
update
)
{
if
(
err
)
{
res
.
json
(
returnCode
.
BUSY
);
...
...
@@ -1292,11 +1309,27 @@ router.post('/thread/:tid/comment/:cid/slash', function(req, res, next) {
res
.
json
(
returnCode
.
SUCCESS
);
}
});
}
else
{
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
else
if
(
comment
&&
userid
){
//用户自己屏蔽
if
(
comment
.
from
.
toString
()
==
userid
.
toString
())
{
forumCommentService
.
changeStatus
(
cid
,
0
,
function
(
err
,
update
)
{
if
(
err
)
{
res
.
json
(
returnCode
.
BUSY
);
}
else
{
if
(
comment
&&
comment
.
level
==
1
)
{
forumAboutMEService
.
updateCommentLevel1Status
(
comment
.
_id
,
2
);
}
if
(
comment
&&
comment
.
level
==
2
)
{
forumAboutMEService
.
updateCommentLevel2Status
(
comment
.
_id
,
2
);
}
res
.
json
(
returnCode
.
SUCCESS
);
}
});
});
}
else
{
res
.
json
(
returnCode
.
ACTION_NOT_PERMISSION
);
}
}
else
{
res
.
json
(
returnCode
.
BUSY
);
}
});
});
...
...
@@ -1597,7 +1630,7 @@ router.post('/thread/:tid/comment/:cid/cancelRaise', function(req, res, next) {
//评论点赞和取消点赞
router
.
post
(
'/thread/:tid/comment/:cid/praiseOrCancelPraise'
,
function
(
req
,
res
,
next
)
{
var
userId
=
req
.
session
.
mobileForumUser
.
userId
;
var
userId
=
user
.
getMobileUser
(
req
)
;
var
tid
=
req
.
params
.
tid
||
null
;
var
cid
=
req
.
params
.
cid
||
null
;
var
mid
=
req
.
session
.
openUser
.
mid
;
...
...
@@ -1713,14 +1746,12 @@ router.get('/thread/:tid/latestPhotos', function(req, res, next) {
var
tid
=
req
.
params
.
tid
||
null
;
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
var
ent_code
=
req
.
session
.
user
.
ent_code
;
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
,
ent_code
:
ent_code
,
pid
:
tid
,
type
:
3
,
status
:
{
$ne
:
3
},
status
:
1
,
images
:
{
$exists
:
true
,
$not
:
{
...
...
@@ -1760,7 +1791,21 @@ router.get('/thread/:tid/latestPhotos', function(req, res, next) {
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
redisPraiseLog
.
get
(
ent_code
,
user
.
getMobileUser
(
req
),
'thread'
,
function
(
error
,
docs
)
{
_
.
forEach
(
results
.
items
,
function
(
d
,
i
)
{
if
(
results
.
items
[
i
].
toObject
)
{
results
.
items
[
i
]
=
results
.
items
[
i
].
toObject
();
}
results
.
items
[
i
].
isPraise
=
false
;
for
(
var
k
=
docs
.
length
-
1
;
k
>=
0
;
k
--
)
{
if
(
results
.
items
[
i
].
_id
==
docs
[
k
])
{
results
.
items
[
i
].
isPraise
=
true
;
break
;
}
};
});
res
.
json
(
_
.
assign
(
results
,
returnCode
.
SUCCESS
));
});
}
});
}
...
...
@@ -1775,14 +1820,12 @@ router.get('/thread/:tid/hotPhotos', function(req, res, next) {
var
tid
=
req
.
params
.
tid
||
null
;
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
var
ent_code
=
req
.
session
.
user
.
ent_code
;
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
,
ent_code
:
ent_code
,
pid
:
tid
,
type
:
3
,
status
:
{
$ne
:
3
},
status
:
1
,
images
:
{
$exists
:
true
,
$not
:
{
...
...
@@ -1822,7 +1865,21 @@ router.get('/thread/:tid/hotPhotos', function(req, res, next) {
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
redisPraiseLog
.
get
(
ent_code
,
user
.
getMobileUser
(
req
),
'thread'
,
function
(
error
,
docs
)
{
_
.
forEach
(
results
.
items
,
function
(
d
,
i
)
{
if
(
results
.
items
[
i
].
toObject
)
{
results
.
items
[
i
]
=
results
.
items
[
i
].
toObject
();
}
results
.
items
[
i
].
isPraise
=
false
;
for
(
var
k
=
docs
.
length
-
1
;
k
>=
0
;
k
--
)
{
if
(
results
.
items
[
i
].
_id
==
docs
[
k
])
{
results
.
items
[
i
].
isPraise
=
true
;
break
;
}
};
});
res
.
json
(
_
.
assign
(
results
,
returnCode
.
SUCCESS
));
});
}
});
}
...
...
@@ -2088,9 +2145,7 @@ router.get('/thread/:tid/get/subThreads/:type', function(req, res, next) {
ent_code
:
ent_code
,
pid
:
tid
,
type
:
2
,
status
:
{
$ne
:
3
}
status
:
1
};
var
sort
=
null
;
//排序条件
...
...
@@ -2103,7 +2158,7 @@ router.get('/thread/:tid/get/subThreads/:type', function(req, res, next) {
if
(
tid
)
{
async
.
waterfall
([
function
(
callback
)
{
forumThreadService
.
getBy
IdSelectyField
(
tid
,
'type'
,
function
(
err
,
thread
)
{
forumThreadService
.
getBy
ConditionsSelectyField
({
_id
:
tid
}
,
'type'
,
function
(
err
,
thread
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
...
...
app/service/forumModeratorApplyService.js
View file @
941423a0
...
...
@@ -112,4 +112,16 @@ exports.getForumModeratorApplys = function(conditions, pageNo, pageSize, sort, c
});
};
//获取条件获取
exports
.
getForumModeratorApplyByConditions
=
function
(
conditions
,
callback
)
{
forumModeratorApply
.
findOne
(
conditions
,
function
(
err
,
doc
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
doc
);
}
});
};
app/service/forumThreadService.js
View file @
941423a0
...
...
@@ -248,8 +248,8 @@ exports.createThread = function(entity, callback) {
};
//根据ID获取文章,选择字段
exports
.
getBy
IdSelectyField
=
function
(
id
,
fields
,
callback
)
{
ForumThread
.
findOne
(
{
_id
:
id
}
).
select
(
fields
).
exec
(
function
(
err
,
result
){
exports
.
getBy
ConditionsSelectyField
=
function
(
conditions
,
fields
,
callback
)
{
ForumThread
.
findOne
(
conditions
).
select
(
fields
).
exec
(
function
(
err
,
result
){
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
...
...
@@ -766,7 +766,8 @@ exports.getAllCountByFid = function(conditions, callback) {
//获取话题、照片墙子文章数据
function
getSubThreads
(
doc
,
sort
,
callback
)
{
var
conditions
=
{
pid
:
doc
.
_id
pid
:
doc
.
_id
,
status
:
1
};
countAllByFid
(
conditions
,
function
(
err
,
count
)
{
if
(
err
)
{
...
...
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