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
48197adc
Commit
48197adc
authored
Apr 01, 2016
by
陈家荣
2
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加板块收藏数
parent
e3d71624
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
2 deletions
+44
-2
forumInfo.js
app/controllers/mobile/forumInfo.js
+43
-1
forumInfoService.js
app/service/forumInfoService.js
+1
-1
No files found.
app/controllers/mobile/forumInfo.js
View file @
48197adc
...
@@ -108,6 +108,19 @@ router.get('/info/:fid/get', function(req, res, next) {
...
@@ -108,6 +108,19 @@ router.get('/info/:fid/get', function(req, res, next) {
callback
(
null
,
threadCount
);
callback
(
null
,
threadCount
);
}
}
});
});
},
function
(
callback
)
{
var
conditions
=
{
ent_code
:
ent_code
,
info
:
fid
};
forumFollowInfoService
.
count
(
conditions
,
function
(
err
,
count
)
{
if
(
err
)
{
callback
(
err
,
null
);
}
else
{
callback
(
null
,
count
);
}
});
}
}
],
function
(
err
,
results
)
{
],
function
(
err
,
results
)
{
if
(
err
)
{
if
(
err
)
{
...
@@ -117,6 +130,7 @@ router.get('/info/:fid/get', function(req, res, next) {
...
@@ -117,6 +130,7 @@ router.get('/info/:fid/get', function(req, res, next) {
var
rs
=
{};
var
rs
=
{};
rs
.
data
=
results
[
0
].
toObject
();
rs
.
data
=
results
[
0
].
toObject
();
rs
.
data
.
threadCount
=
results
[
1
];
rs
.
data
.
threadCount
=
results
[
1
];
rs
.
data
.
favor_by
=
results
[
2
];
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
}
});
});
...
@@ -824,6 +838,35 @@ router.get('/info/list/allWithThreadCount', function(req, res, next) {
...
@@ -824,6 +838,35 @@ router.get('/info/list/allWithThreadCount', function(req, res, next) {
callback
(
err
,
datas
.
items
);
callback
(
err
,
datas
.
items
);
});
});
},
},
function
(
infos
,
callback
)
{
//获取关注数
var
asyncTasks
=
[];
_
.
forEach
(
infos
,
function
(
info
,
i
)
{
asyncTasks
.
push
(
function
(
cont
)
{
var
conditions
=
{
ent_code
:
ent_code
,
info
:
info
.
_id
};
forumFollowInfoService
.
count
(
conditions
,
function
(
err
,
count
)
{
if
(
err
)
{
console
.
error
(
err
);
cont
(
err
,
null
);
}
else
{
if
(
infos
[
i
].
toObject
)
{
infos
[
i
]
=
infos
[
i
].
toObject
();
}
console
.
log
(
count
);
infos
[
i
].
favor_by
=
count
;
cont
(
null
,
info
);
}
});
});
});
then
.
parallel
(
asyncTasks
).
then
(
function
(
cont
,
datas
)
{
callback
(
null
,
infos
);
}).
fail
(
function
(
err
,
cont
)
{
callback
(
err
,
null
);
});
},
function
(
infos
,
callback
)
{
//获取用户
function
(
infos
,
callback
)
{
//获取用户
var
asyncTasks
=
[];
var
asyncTasks
=
[];
_
.
forEach
(
infos
,
function
(
info
,
i
)
{
_
.
forEach
(
infos
,
function
(
info
,
i
)
{
...
@@ -850,7 +893,6 @@ router.get('/info/list/allWithThreadCount', function(req, res, next) {
...
@@ -850,7 +893,6 @@ router.get('/info/list/allWithThreadCount', function(req, res, next) {
if
(
infos
[
i
].
toObject
)
{
if
(
infos
[
i
].
toObject
)
{
infos
[
i
]
=
infos
[
i
].
toObject
();
infos
[
i
]
=
infos
[
i
].
toObject
();
}
}
infos
[
i
].
favor_by
=
infos
[
i
].
favor_by
.
length
;
infos
[
i
].
threadCount
=
count
;
infos
[
i
].
threadCount
=
count
;
cont
(
null
,
info
);
cont
(
null
,
info
);
}
}
...
...
app/service/forumInfoService.js
View file @
48197adc
...
@@ -84,7 +84,7 @@ exports.getAllByGid= function(conditions,pageNo,pageSize,callback) {
...
@@ -84,7 +84,7 @@ exports.getAllByGid= function(conditions,pageNo,pageSize,callback) {
}
else
{
}
else
{
var
skip
=
(
pageNo
-
1
)
*
pageSize
;
var
skip
=
(
pageNo
-
1
)
*
pageSize
;
var
limit
=
count
-
skip
>
pageSize
?
pageSize
:
(
count
-
skip
);
var
limit
=
count
-
skip
>
pageSize
?
pageSize
:
(
count
-
skip
);
ForumInfo
.
find
(
conditions
).
populate
(
'group'
).
skip
(
skip
).
limit
(
limit
).
sort
({
order_idx
:
-
1
}).
exec
(
function
(
err
,
docs
)
{
ForumInfo
.
find
(
conditions
).
skip
(
skip
).
limit
(
limit
).
sort
({
order_idx
:
-
1
}).
exec
(
function
(
err
,
docs
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
err
);
console
.
error
(
err
);
callback
(
err
,
null
);
callback
(
err
,
null
);
...
...
strong
@strong
mentioned in commit
8cfa1e84
·
Apr 01, 2016
mentioned in commit
8cfa1e84
mentioned in commit 8cfa1e849c18a6da491ff8abd351707949512748
Toggle commit list
strong
@strong
mentioned in commit
831344de
·
Apr 01, 2016
mentioned in commit
831344de
mentioned in commit 831344de2f8e1f9d900ba051e47c84eb7f097789
Toggle commit list
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