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
afe04c03
Commit
afe04c03
authored
Jan 21, 2016
by
陈家荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加头衔列表查询接口(红人馆):头衔信息、前4头衔人员信息接口
parent
d20ad695
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
173 additions
and
1 deletion
+173
-1
forumHonorTitle.js
app/controllers/mobile/forumHonorTitle.js
+101
-0
forumThread.js
app/controllers/mobile/forumThread.js
+31
-0
forumThreadService.js
app/service/forumThreadService.js
+1
-1
forumUserService.js
app/service/forumUserService.js
+40
-0
No files found.
app/controllers/mobile/forumHonorTitle.js
0 → 100644
View file @
afe04c03
'use strict'
;
var
express
=
require
(
'express'
),
router
=
express
.
Router
(),
then
=
require
(
'thenjs'
),
returnCode
=
require
(
'../../utils/returnCode'
),
async
=
require
(
'async'
),
_
=
require
(
'lodash'
);
var
mongoose
=
require
(
'mongoose'
);
var
forumHonorTitleService
=
require
(
'../../service/forumHonorTitleService'
);
var
forumUserService
=
require
(
'../../service/forumUserService'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/v1/forum'
,
router
);
};
//查询所有头衔信息、前4头衔人员信息
router
.
get
(
'/honorTitle/list'
,
function
(
req
,
res
,
next
)
{
var
pageNo
=
req
.
query
.
pageNo
||
1
,
pageSize
=
req
.
query
.
pageSize
||
4
,
ent_code
=
req
.
session
.
user
.
ent_code
;
var
honorTitle_condition
=
{
ent_code
:
ent_code
,
status
:
1
}
var
fields
=
"nickName icon"
;
async
.
waterfall
([
function
(
callback
)
{
//查询所有头衔
forumHonorTitleService
.
find
(
honorTitle_condition
,
function
(
err
,
list
)
{
callback
(
err
,
list
);
});
},
function
(
list
,
callback
)
{
//更新用户消息
var
asyncTasks
=
[];
_
.
forEach
(
list
,
function
(
one
,
i
)
{
asyncTasks
.
push
(
function
(
cont
)
{
var
user_conditions
=
{
ent_code
:
ent_code
,
honorTitles
:
{
$in
:
[
one
.
_id
]
}
};
forumUserService
.
searchMembersAndFields
(
pageNo
,
pageSize
,
user_conditions
,
fields
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
error
(
err
);
cont
(
err
,
null
);
}
else
{
if
(
list
[
i
].
toObject
)
{
list
[
i
]
=
list
[
i
].
toObject
();
}
list
[
i
].
users
=
results
;
cont
(
null
,
one
);
}
});
});
});
then
.
parallel
(
asyncTasks
).
then
(
function
(
cont
,
datas
)
{
callback
(
null
,
list
);
}).
fail
(
function
(
err
,
cont
)
{
callback
(
err
,
null
);
});
}
],
function
(
err
,
result
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
_
.
assign
(
result
,
returnCode
.
SUCCESS
));
}
});
});
//查询单个头衔信息人员信息
router
.
get
(
'/honorTitle/:hid/list'
,
function
(
req
,
res
,
next
)
{
var
ent_code
=
req
.
session
.
user
.
ent_code
;
var
honorTitleId
=
req
.
params
.
hid
;
var
user_conditions
=
{
ent_code
:
ent_code
,
honorTitles
:
{
$in
:
[
honorTitleId
]
}
};
var
fields
=
"nickName icon"
;
forumUserService
.
searchMembersAndFields
(
1
,
10000
,
user_conditions
,
fields
,
function
(
err
,
results
)
{
if
(
err
)
{
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
res
.
json
(
_
.
assign
(
results
,
returnCode
.
SUCCESS
));
}
});
});
app/controllers/mobile/forumThread.js
View file @
afe04c03
...
@@ -1796,3 +1796,34 @@ router.get('/thread/getThreadWithEssence', function(req, res, next) {
...
@@ -1796,3 +1796,34 @@ router.get('/thread/getThreadWithEssence', function(req, res, next) {
res
.
json
(
returnCode
.
WRONG_PARAM
);
res
.
json
(
returnCode
.
WRONG_PARAM
);
}
}
});
});
//分页查询帖子列表,按时间排序
router
.
get
(
'/thread/searchThread'
,
function
(
req
,
res
,
next
)
{
//参数
var
pageNo
=
req
.
query
.
pageNo
,
pageSize
=
req
.
query
.
pageSize
,
status
=
1
,
ent_code
=
req
.
session
.
user
.
ent_code
;
var
today
=
new
Date
();
if
(
pageNo
&&
pageSize
)
{
var
q
=
{
ent_code
:
ent_code
};
forumThreadService
.
findThreadByPage
(
pageNo
,
pageSize
,
q
,
function
(
err
,
result
)
{
if
(
err
)
{
console
.
error
(
err
);
}
res
.
json
(
result
);
});
}
else
{
console
.
error
(
'params error'
);
res
.
json
({
result
:
false
,
err
:
'params error'
});
}
});
\ No newline at end of file
app/service/forumThreadService.js
View file @
afe04c03
...
@@ -97,7 +97,7 @@ function findOneAndUpdate(id, entity, callback) {
...
@@ -97,7 +97,7 @@ function findOneAndUpdate(id, entity, callback) {
};
};
//
根据发帖者
分页查询话题列表
//分页查询话题列表
exports
.
findThread
=
function
(
pageNo
,
pageSize
,
q
,
sort
,
callback
)
{
exports
.
findThread
=
function
(
pageNo
,
pageSize
,
q
,
sort
,
callback
)
{
then
(
function
(
cont
)
{
then
(
function
(
cont
)
{
ForumThread
.
find
(
q
).
count
(
cont
);
ForumThread
.
find
(
q
).
count
(
cont
);
...
...
app/service/forumUserService.js
View file @
afe04c03
...
@@ -333,3 +333,43 @@ exports.getFavors = function(condition, callback) {
...
@@ -333,3 +333,43 @@ exports.getFavors = function(condition, callback) {
}
}
});
});
};
};
//查询用户信息,只查某些字段
exports
.
searchMembersAndFields
=
function
(
pageNo
,
pageSize
,
q
,
fields
,
callback
)
{
then
(
function
(
cont
)
{
ForumUser
.
find
(
q
).
count
(
cont
);
}).
then
(
function
(
cont
,
count
)
{
var
skip
=
(
pageNo
-
1
)
*
pageSize
;
var
limit
=
count
-
skip
>
pageSize
?
pageSize
:
(
count
-
skip
);
ForumUser
.
find
(
q
).
skip
(
skip
).
limit
(
limit
).
select
(
fields
).
sort
(
'-created'
).
populate
({
path
:
'honorTitles'
,
match
:
{
status
:
{
$ne
:
0
}
},
options
:
{
sort
:
{
order_idx
:
-
1
}
}
}).
exec
(
function
(
err
,
docs
)
{
cont
(
err
,
count
,
docs
);
});
}).
then
(
function
(
cont
,
count
,
members
)
{
var
rsJson
=
{
result
:
true
,
total
:
count
,
datas
:
members
};
callback
(
null
,
rsJson
);
}).
fail
(
function
(
cont
,
err
)
{
console
.
error
(
err
);
var
rsJson
=
{
result
:
false
,
err
:
err
};
callback
(
err
,
rsJson
);
});
};
\ No newline at end of file
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