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
fa46f642
Commit
fa46f642
authored
Mar 10, 2016
by
strong
Browse files
Options
Browse Files
Download
Plain Diff
Merge commit '
8d924e48
' into SANDBOX
parents
1b50346c
8d924e48
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
48 deletions
+34
-48
forumThread.js
app/controllers/mobile/forumThread.js
+25
-7
forumThreadService.js
app/service/forumThreadService.js
+9
-41
No files found.
app/controllers/mobile/forumThread.js
View file @
fa46f642
...
@@ -564,16 +564,27 @@ router.get('/thread/:tid/get', function(req, res, next) {
...
@@ -564,16 +564,27 @@ router.get('/thread/:tid/get', function(req, res, next) {
console
.
error
(
err
);
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
}
else
{
if
(
thread
.
toObject
)
{
thread
=
thread
.
toObject
();
}
//获取等级最高的荣誉
if
(
thread
.
from
&&
thread
.
from
.
honorTitles
&&
thread
.
from
.
honorTitles
.
length
>
0
){
var
temp_honorTitles
=
_
.
sortBy
(
thread
.
from
.
honorTitles
,
'order_idx'
);
for
(
var
m
=
temp_honorTitles
.
length
-
1
;
m
>=
0
;
m
-=
1
){
var
honor
=
temp_honorTitles
[
m
]
if
(
honor
.
is_show
==
1
){
thread
.
from
.
honorTitles
=
honor
;
break
;
}
}
}
var
threads
=
[];
var
threads
=
[];
threads
.
push
(
thread
);
threads
.
push
(
thread
);
util
.
loadLevel
(
req
.
session
.
user
.
ent_code
,
threads
,
function
()
{
util
.
loadLevel
(
req
.
session
.
user
.
ent_code
,
threads
,
function
()
{
if
(
threads
&&
threads
.
length
>
0
)
{
if
(
threads
&&
threads
.
length
>
0
)
{
thread
=
threads
[
0
];
thread
=
threads
[
0
];
}
}
//console.log(thread);
//console.log(thread.type == 2 && thread.level == 1&&thread.subThreads.items.length>0);
if
(
thread
.
type
==
2
&&
thread
.
level
==
1
&&
thread
.
subThreads
.
items
.
length
>
0
)
{
if
(
thread
.
type
==
2
&&
thread
.
level
==
1
&&
thread
.
subThreads
.
items
.
length
>
0
)
{
//console.log(thread.subThreads);
util
.
loadLevel
(
req
.
session
.
user
.
ent_code
,
thread
.
subThreads
.
items
,
function
()
{
util
.
loadLevel
(
req
.
session
.
user
.
ent_code
,
thread
.
subThreads
.
items
,
function
()
{
redisPraiseLog
.
get
(
ent_code
,
user
.
getMobileUser
(
req
),
'thread'
,
function
(
error
,
docs
)
{
redisPraiseLog
.
get
(
ent_code
,
user
.
getMobileUser
(
req
),
'thread'
,
function
(
error
,
docs
)
{
if
(
thread
.
toObject
)
{
if
(
thread
.
toObject
)
{
...
@@ -1953,6 +1964,7 @@ router.get('/thread/:tid/get/subThreads/:type', function(req, res, next) {
...
@@ -1953,6 +1964,7 @@ router.get('/thread/:tid/get/subThreads/:type', function(req, res, next) {
function
(
callback
)
{
function
(
callback
)
{
forumThreadService
.
getByIdSelectyField
(
tid
,
'type'
,
function
(
err
,
thread
)
{
forumThreadService
.
getByIdSelectyField
(
tid
,
'type'
,
function
(
err
,
thread
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
callback
(
err
,
null
);
}
else
{
}
else
{
callback
(
null
,
thread
);
callback
(
null
,
thread
);
...
@@ -1962,6 +1974,7 @@ router.get('/thread/:tid/get/subThreads/:type', function(req, res, next) {
...
@@ -1962,6 +1974,7 @@ router.get('/thread/:tid/get/subThreads/:type', function(req, res, next) {
function
(
thread
,
callback
)
{
function
(
thread
,
callback
)
{
forumUserThreadControlService
.
getUserThreadControlById
(
user
.
getMobileUser
(
req
),
function
(
err
,
doc
)
{
forumUserThreadControlService
.
getUserThreadControlById
(
user
.
getMobileUser
(
req
),
function
(
err
,
doc
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
,
null
);
callback
(
err
,
null
,
null
);
}
else
{
}
else
{
if
(
doc
)
{
if
(
doc
)
{
...
@@ -1994,13 +2007,18 @@ router.get('/thread/:tid/get/subThreads/:type', function(req, res, next) {
...
@@ -1994,13 +2007,18 @@ router.get('/thread/:tid/get/subThreads/:type', function(req, res, next) {
}
}
],
function
(
err
,
results
)
{
],
function
(
err
,
results
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
}
else
{
util
.
loadLevel
(
ent_code
,
results
.
items
,
function
()
{
if
(
results
){
handleThreadList
(
req
,
results
,
ent_code
,
function
(
result
){
util
.
loadLevel
(
ent_code
,
results
.
items
,
function
()
{
res
.
json
(
_
.
assign
(
result
,
returnCode
.
SUCCESS
));
handleThreadList
(
req
,
results
,
ent_code
,
function
(
result
){
res
.
json
(
_
.
assign
(
result
,
returnCode
.
SUCCESS
));
});
});
});
});
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
}
}
}
});
});
}
else
{
}
else
{
...
...
app/service/forumThreadService.js
View file @
fa46f642
...
@@ -285,7 +285,14 @@ exports.getByConditions = function(conditions, callback) {
...
@@ -285,7 +285,14 @@ exports.getByConditions = function(conditions, callback) {
}
}
//根据ID获取文章
//根据ID获取文章
exports
.
getThreadById
=
function
(
tid
,
callback
)
{
exports
.
getThreadById
=
function
(
tid
,
callback
)
{
ForumThread
.
findOne
({
_id
:
tid
}).
populate
(
'from'
,
'uid mid nickName icon exp'
).
populate
(
'info'
,
'name icon'
).
populate
(
'share'
).
exec
(
function
(
err
,
doc
)
{
ForumThread
.
findOne
({
_id
:
tid
}).
populate
({
path
:
'from'
,
select
:
'uid mid nickName icon exp honorTitles'
,
options
:
{
populate
:
"honorTitles"
//继续查荣誉
}
}).
populate
(
'info'
,
'name icon'
).
populate
(
'share'
).
exec
(
function
(
err
,
doc
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
err
);
console
.
error
(
err
);
callback
(
err
,
null
);
callback
(
err
,
null
);
...
@@ -569,25 +576,6 @@ exports.updateThreadById = function(tid, entity, callback) {
...
@@ -569,25 +576,6 @@ exports.updateThreadById = function(tid, entity, callback) {
entity
.
share
=
''
;
entity
.
share
=
''
;
}
}
if
(
entity
.
share
)
{
if
(
entity
.
share
)
{
// ForumThread.update({
// _id: tid
// }, entity, null, function(err, result) {
// if (err) {
// console.error(err);
// callback(err, null);
// } else {
// ForumShare.update({
// _id: shareEntity._id
// }, shareEntity, null, function(err, se) {
// if (err) {
// console.error(err);
// callback(err, null);
// } else {
// callback(null, entity);
// }
// });
// }
// });
findOneAndUpdate
({
_id
:
tid
},
entity
,
'updateRedisRecommentThreads'
,
function
(
err
,
result
)
{
findOneAndUpdate
({
_id
:
tid
},
entity
,
'updateRedisRecommentThreads'
,
function
(
err
,
result
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
err
);
console
.
error
(
err
);
...
@@ -622,32 +610,12 @@ exports.updateThreadById = function(tid, entity, callback) {
...
@@ -622,32 +610,12 @@ exports.updateThreadById = function(tid, entity, callback) {
});
});
}
else
{
}
else
{
delete
entity
.
share
;
delete
entity
.
share
;
// ForumThread.update({
// _id: tid
// }, entity, null, function(err, result) {
// if (err) {
// console.error(err);
// callback(err, null);
// } else {
// callback(null, entity);
// }
// });
findOneAndUpdate
({
_id
:
tid
},
entity
,
'updateRedisRecommentThreads'
,
function
(
err
,
result
)
{
findOneAndUpdate
({
_id
:
tid
},
entity
,
'updateRedisRecommentThreads'
,
function
(
err
,
result
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
err
);
console
.
error
(
err
);
callback
(
err
,
null
);
callback
(
err
,
null
);
}
else
{
}
else
{
ForumShare
.
update
({
_id
:
shareEntity
.
_id
},
shareEntity
,
null
,
function
(
err
,
se
)
{
callback
(
null
,
entity
);
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
entity
);
}
});
}
}
});
});
...
...
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