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
4be09bba
Commit
4be09bba
authored
Mar 25, 2016
by
陈家荣
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
33d3f3ba
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
89 additions
and
23 deletions
+89
-23
forumInfo.js
app/controllers/mobile/forumInfo.js
+26
-1
forumUser.js
app/controllers/mobile/forumUser.js
+49
-20
ForumFollowInfoService.js
app/service/ForumFollowInfoService.js
+2
-2
forumThreadService.js
app/service/forumThreadService.js
+12
-0
No files found.
app/controllers/mobile/forumInfo.js
View file @
4be09bba
...
...
@@ -967,7 +967,7 @@ router.get('/info/getUserFavorInfo', function(req, res, next) {
from
:
userId
};
forumFollowInfoService
.
findAll
(
q
,
null
,
function
(
err
,
doc
){
forumFollowInfoService
.
findAll
(
q
,
null
,
null
,
function
(
err
,
doc
){
if
(
err
||
!
doc
){
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
...
...
@@ -1039,4 +1039,29 @@ router.get('/info/getUserFavorInfo', function(req, res, next) {
}
});
});
//获取用户收藏的板块的ID return Map
router
.
get
(
'/info/getUserFavorInfoIds'
,
function
(
req
,
res
,
next
)
{
var
userId
=
user
.
getMobileUser
(
req
);
var
ent_code
=
req
.
session
.
user
.
ent_code
;
var
q
=
{
ent_code
:
ent_code
,
from
:
userId
};
forumFollowInfoService
.
findAll
(
q
,
null
,
'info'
,
function
(
err
,
results
){
if
(
err
||
!
results
){
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
var
map
=
{
//返回map对象,方便前端查找
data
:{}
};
_
.
forEach
(
results
,
function
(
d
){
map
.
data
[
d
.
info
]
=
1
;
});
res
.
json
(
_
.
assign
(
map
,
returnCode
.
SUCCESS
));
}
});
});
\ No newline at end of file
app/controllers/mobile/forumUser.js
View file @
4be09bba
...
...
@@ -336,7 +336,36 @@ router.get('/user/getUserFavorUser', function(req, res, next) {
res
.
json
(
returnCode
.
BUSY
);
}
else
{
util
.
loadLevel
(
ent_code
,
results
.
items
,
function
()
{
res
.
json
(
_
.
assign
(
results
,
returnCode
.
SUCCESS
));
var
asyncTasks
=
[];
_
.
forEach
(
results
.
items
,
function
(
d
,
i
)
{
asyncTasks
.
push
(
function
(
cont
)
{
var
conditions
=
{
ent_code
:
ent_code
,
from
:
d
.
to
.
_id
,
status
:
1
};
forumThreadService
.
getByConditionsSelectyFieldWithOpentions
(
conditions
,
'title'
,
1
,
0
,
'-_id'
,
function
(
err
,
thread
)
{
if
(
err
)
{
console
.
error
(
err
);
cont
(
err
,
null
);
}
else
{
if
(
d
.
toObject
){
d
=
d
.
toObject
();
}
d
.
thread
=
thread
;
cont
(
null
,
d
);
}
});
});
});
async
.
parallel
(
asyncTasks
,
function
(
err
,
datas
){
if
(
err
){
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
_
.
assign
(
datas
,
returnCode
.
SUCCESS
));
}
});
});
}
});
...
...
@@ -345,6 +374,7 @@ router.get('/user/getUserFavorUser', function(req, res, next) {
//查看用户信息
router
.
get
(
'/user/getUserInfo/:userId'
,
function
(
req
,
res
,
next
)
{
var
userId
=
req
.
params
.
userId
;
var
my_userID
=
user
.
getMobileUser
(
req
);
var
ent_code
=
req
.
session
.
user
.
ent_code
;
async
.
waterfall
([
function
(
callback
)
{
...
...
@@ -375,24 +405,17 @@ router.get('/user/getUserInfo/:userId', function(req, res, next) {
forumFollowUserService
.
count
(
follow_by_conditions
,
callback
);
},
function
(
callback
)
{
//获取用户经验值,积分
// var url = API_ADDRESS + '/v1.0/internal/member/infoAndRankInfo';
// request.post({
// url: url,
// json: {
// entCode:ent_code,
// ids:[forumUser.mid]
// }
// }, function(e, r, body) {
// if (e) {
// console.log(e)
// callback(e, null);
// }else{
// callback(null, body.data);
// }
// });
user
.
findMember
(
ent_code
,
forumUser
.
mid
,
callback
);
},
function
(
callback
)
{
//是否已关注当前用户
forumFollowUserService
.
isNotFollow
({
from
:
my_userID
,
to
:
userId
,
ent_code
:
ent_code
},
function
(
result
){
if
(
result
){
callback
(
null
,
true
);
}
else
{
callback
(
null
,
false
);
}
});
}
],
function
(
err
,
results
)
{
if
(
err
)
{
...
...
@@ -407,7 +430,13 @@ router.get('/user/getUserInfo/:userId', function(req, res, next) {
forumUser
.
exp
=
results
[
2
][
0
].
exp
;
forumUser
.
rankName
=
results
[
2
][
0
].
rankName
;
}
callback
(
null
,
forumUser
)
var
object
=
{
forumUser
:
forumUser
,
isFollow
:
results
[
3
]
}
callback
(
null
,
object
)
}
});
}],
function
(
err
,
result
)
{
...
...
@@ -416,7 +445,7 @@ router.get('/user/getUserInfo/:userId', function(req, res, next) {
res
.
json
(
returnCode
.
BUSY
);
}
else
{
var
rs
=
{
data
:
result
data
:
result
};
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
...
...
app/service/ForumFollowInfoService.js
View file @
4be09bba
...
...
@@ -70,12 +70,12 @@ exports.find= function(pageNo, pageSize, conditions, sort, callback) {
};
//获取列表
exports
.
findAll
=
function
(
conditions
,
sort
,
callback
){
exports
.
findAll
=
function
(
conditions
,
sort
,
fields
,
callback
){
var
sortby
=
"-_id"
;
if
(
sort
){
sortby
=
sort
;
}
ForumFollowInfo
.
find
(
conditions
).
sort
(
sortby
).
exec
(
function
(
err
,
docs
){
ForumFollowInfo
.
find
(
conditions
).
s
elect
(
fields
).
s
ort
(
sortby
).
exec
(
function
(
err
,
docs
){
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
...
...
app/service/forumThreadService.js
View file @
4be09bba
...
...
@@ -260,6 +260,18 @@ exports.getByConditionsSelectyField = function(conditions, fields, callback) {
});
}
//根据ID获取文章,选择字段
exports
.
getByConditionsSelectyFieldWithOpentions
=
function
(
conditions
,
fields
,
limit
,
skip
,
sort
,
callback
)
{
ForumThread
.
findOne
(
conditions
).
select
(
fields
).
limit
(
limit
).
skip
(
skip
).
sort
(
sort
).
exec
(
function
(
err
,
result
){
if
(
err
)
{
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
result
);
}
});
}
//根据ID获取文章记录,不查评论,子话题
exports
.
getById
=
function
(
id
,
callback
)
{
ForumThread
.
findOne
({
...
...
strong
@strong
mentioned in commit
d1a4ff35
·
Mar 25, 2016
mentioned in commit
d1a4ff35
mentioned in commit d1a4ff35de03ac2d82b62e80d08d82cac92cf87a
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