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
138583f3
Commit
138583f3
authored
Mar 18, 2016
by
strong
Browse files
Options
Browse Files
Download
Plain Diff
Merge commit '
1301e611
'
parents
0fb26aa0
1301e611
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
60 deletions
+60
-60
forumHonorTitle.js
app/controllers/mobile/forumHonorTitle.js
+24
-0
forumThread.js
app/controllers/mobile/forumThread.js
+5
-30
forumCommentService.js
app/service/forumCommentService.js
+5
-3
forumThreadService.js
app/service/forumThreadService.js
+26
-27
No files found.
app/controllers/mobile/forumHonorTitle.js
View file @
138583f3
...
...
@@ -109,3 +109,27 @@ router.get('/honorTitle/list', function(req, res, next) {
}
});
});
//获取状态为启用的
router
.
get
(
'/honorTitle/allList'
,
function
(
req
,
res
,
next
)
{
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
,
status
:
1
};
forumHonorTitleService
.
find
(
conditions
,
function
(
err
,
results
){
if
(
err
){
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
var
map
=
{};
_
.
forEach
(
results
,
function
(
d
,
i
)
{
map
[
d
.
_id
]
=
d
;
});
var
rs
=
{
data
:
map
};
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
});
});
\ No newline at end of file
app/controllers/mobile/forumThread.js
View file @
138583f3
...
...
@@ -569,17 +569,6 @@ router.get('/thread/:tid/get', function(req, res, next) {
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
=
[];
threads
.
push
(
thread
);
util
.
loadLevel
(
req
.
session
.
user
.
ent_code
,
threads
,
function
()
{
...
...
@@ -1695,10 +1684,8 @@ router.get('/thread/:tid/topics', function(req, res, next) {
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
,
pid
:
tid
,
type
:
2
,
status
:
{
$ne
:
3
}
// type: 2,
status
:
1
};
if
(
tid
)
{
async
.
waterfall
([
...
...
@@ -1750,7 +1737,7 @@ router.get('/thread/:tid/latestPhotos', function(req, res, next) {
var
conditions
=
{
ent_code
:
ent_code
,
pid
:
tid
,
type
:
3
,
//
type: 3,
status
:
1
,
images
:
{
$exists
:
true
,
...
...
@@ -1824,7 +1811,7 @@ router.get('/thread/:tid/hotPhotos', function(req, res, next) {
var
conditions
=
{
ent_code
:
ent_code
,
pid
:
tid
,
type
:
3
,
//
type: 3,
status
:
1
,
images
:
{
$exists
:
true
,
...
...
@@ -2064,18 +2051,6 @@ function handleThreadList(req, results, ent_code, callback){
}
}
//获取等级最高的荣誉
if
(
results
.
items
[
i
].
from
&&
results
.
items
[
i
].
from
.
honorTitles
&&
results
.
items
[
i
].
from
.
honorTitles
.
length
>
0
){
var
temp_honorTitles
=
_
.
sortBy
(
results
.
items
[
i
].
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
){
results
.
items
[
i
].
from
.
honorTitles
=
honor
;
break
;
}
}
}
results
.
items
[
i
].
isPraise
=
false
;
for
(
var
k
=
docs
.
length
-
1
;
k
>=
0
;
k
--
)
{
if
(
results
.
items
[
i
].
_id
==
docs
[
k
])
{
...
...
@@ -2144,7 +2119,7 @@ router.get('/thread/:tid/get/subThreads/:type', function(req, res, next) {
var
conditions
=
{
ent_code
:
ent_code
,
pid
:
tid
,
type
:
2
,
//
type: 2,
status
:
1
};
...
...
app/service/forumCommentService.js
View file @
138583f3
...
...
@@ -144,8 +144,10 @@ exports.getAllComment = function(conditions, pageNo, pageSize, callback) {
}
else
{
var
skip
=
(
pageNo
-
1
)
*
pageSize
;
var
limit
=
count
-
skip
>
pageSize
?
pageSize
:
(
count
-
skip
);
ForumComment
.
find
(
conditions
,
listCommentFields
).
populate
(
'from'
,
'uid mid nickName icon exp'
).
populate
(
'to'
,
'uid mid nickName icon exp'
).
limit
(
limit
).
skip
(
skip
).
sort
(
'-created'
).
exec
(
function
(
err
,
docs
)
{
ForumComment
.
find
(
conditions
,
listCommentFields
).
populate
({
path
:
'from'
,
select
:
'uid mid nickName icon exp honorTitles'
}).
populate
(
'to'
,
'uid mid nickName icon exp'
).
limit
(
limit
).
skip
(
skip
).
sort
(
'-created'
).
exec
(
function
(
err
,
docs
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
...
...
@@ -640,7 +642,7 @@ exports.getAllComment_allstatus = function(conditions, pageNo, pageSize, callbac
var
skip
=
(
pageNo
-
1
)
*
pageSize
;
var
limit
=
count
-
skip
>
pageSize
?
pageSize
:
(
count
-
skip
);
ForumComment
.
find
(
conditions
,
listCommentFields
).
populate
(
'from'
,
'uid mid nickName icon exp'
).
populate
(
'to'
,
'uid mid nickName icon exp'
).
limit
(
limit
).
skip
(
skip
).
sort
(
'-created'
).
exec
(
function
(
err
,
docs
)
{
ForumComment
.
find
(
conditions
,
listCommentFields
).
populate
(
'from'
,
'uid mid nickName icon exp
honorTitles
'
).
populate
(
'to'
,
'uid mid nickName icon exp'
).
limit
(
limit
).
skip
(
skip
).
sort
(
'-created'
).
exec
(
function
(
err
,
docs
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
...
...
app/service/forumThreadService.js
View file @
138583f3
...
...
@@ -9,6 +9,7 @@ var forumCommentService = require('./forumCommentService');
var
async
=
require
(
'async'
);
var
then
=
require
(
'thenjs'
);
var
_
=
require
(
'lodash'
);
var
redisThreadList
=
require
(
'../utils/redisThreadList'
);
...
...
@@ -285,13 +286,9 @@ exports.getByConditions = function(conditions, callback) {
}
//根据ID获取文章
exports
.
getThreadById
=
function
(
tid
,
callback
)
{
ForumThread
.
findOne
({
_id
:
tid
}).
populate
({
path
:
'from'
,
select
:
'uid mid nickName icon exp honorTitles'
,
options
:
{
populate
:
"honorTitles"
//继续查荣誉
}
select
:
'uid mid nickName icon exp honorTitles'
}).
populate
(
'info'
,
'name icon'
).
populate
(
'share'
).
exec
(
function
(
err
,
doc
)
{
if
(
err
)
{
console
.
error
(
err
);
...
...
@@ -769,11 +766,6 @@ function getSubThreads(doc, sort, callback) {
pid
:
doc
.
_id
,
status
:
1
};
countAllByFid
(
conditions
,
function
(
err
,
count
)
{
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
var
sortBy
=
'-top -quality -created'
;
if
(
sort
)
{
sortBy
=
sort
;
...
...
@@ -783,9 +775,21 @@ function getSubThreads(doc, sort, callback) {
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
var
list
=
[];
//用户去重
_
.
forEach
(
docs
,
function
(
one
,
i
)
{
var
flag
=
true
;
_
.
forEach
(
list
,
function
(
two
,
k
)
{
if
(
one
.
from
.
_id
==
two
.
from
.
_id
){
flag
=
false
;
}
});
if
(
flag
){
list
.
push
(
one
);
}
});
var
obj
=
{};
obj
.
total
=
count
;
obj
.
items
=
docs
;
obj
.
total
=
list
.
length
;
obj
.
items
=
list
;
var
newDoc
=
doc
.
toObject
();
newDoc
.
subThreads
=
obj
;
...
...
@@ -793,8 +797,6 @@ function getSubThreads(doc, sort, callback) {
callback
(
null
,
newDoc
);
}
});
}
});
}
function
getAllThreadByFidHelp
(
conditions
,
pageNo
,
pageSize
,
sort
,
callback
)
{
...
...
@@ -1374,10 +1376,7 @@ exports.getThreadWithNotPopulateComment = function(conditions, pageNo, pageSize,
}
ForumThread
.
find
(
conditions
).
populate
({
path
:
'from'
,
select
:
'uid mid nickName icon honorTitles'
,
options
:
{
populate
:
"honorTitles"
//继续查荣誉
}
select
:
'uid mid nickName icon honorTitles'
}).
populate
(
'info'
,
'name icon pv_count'
).
limit
(
limit
).
skip
(
skip
).
sort
(
sortBy
).
exec
(
function
(
err
,
docs
)
{
if
(
err
)
{
console
.
error
(
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