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
585ec733
Commit
585ec733
authored
Dec 17, 2015
by
strong
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'remould_1214_api_optimize' into SANDBOX
parents
c75e8d9d
c76dbf7f
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
276 additions
and
176 deletions
+276
-176
commentTips.js
app/controllers/mobile/commentTips.js
+2
-0
forumInfo.js
app/controllers/mobile/forumInfo.js
+28
-28
forumModerator.js
app/controllers/mobile/forumModerator.js
+2
-0
forumThread.js
app/controllers/mobile/forumThread.js
+10
-17
forumCommentService.js
app/service/forumCommentService.js
+13
-1
forumThreadService.js
app/service/forumThreadService.js
+220
-129
express.js
config/express.js
+1
-1
No files found.
app/controllers/mobile/commentTips.js
View file @
585ec733
...
@@ -17,6 +17,8 @@ router.get('/commentTips', function(req, res, next) {
...
@@ -17,6 +17,8 @@ router.get('/commentTips', function(req, res, next) {
if
(
err
){
if
(
err
){
res
.
json
(
returnCode
.
UNCHECK_ERROR
(
err
));
res
.
json
(
returnCode
.
UNCHECK_ERROR
(
err
));
}
else
{
}
else
{
res
.
setHeader
(
'Cache-Control'
,
'private, max-age=600'
);
// 私有缓存一个10分钟
res
.
setHeader
(
'Expires'
,
new
Date
(
Date
.
now
()
+
600000
).
toUTCString
());
res
.
json
(
_
.
assign
({
data
:
result
},
returnCode
.
SUCCESS
));
res
.
json
(
_
.
assign
({
data
:
result
},
returnCode
.
SUCCESS
));
}
}
});
});
...
...
app/controllers/mobile/forumInfo.js
View file @
585ec733
...
@@ -37,6 +37,8 @@ router.get('/info/list/all', function(req, res, next) {
...
@@ -37,6 +37,8 @@ router.get('/info/list/all', function(req, res, next) {
res
.
json
(
returnCode
.
BUSY
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
}
else
{
rs
.
data
=
datas
.
items
;
rs
.
data
=
datas
.
items
;
res
.
setHeader
(
'Cache-Control'
,
'public, max-age=3600'
);
// 公共缓存一个小时
res
.
setHeader
(
'Expires'
,
new
Date
(
Date
.
now
()
+
3600000
).
toUTCString
());
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
}
});
});
...
@@ -66,18 +68,13 @@ router.get('/info/:fid/get', function(req, res, next) {
...
@@ -66,18 +68,13 @@ router.get('/info/:fid/get', function(req, res, next) {
if
(
fid
)
{
if
(
fid
)
{
var
source
=
req
.
session
.
mobileForumUser
.
source
;
var
source
=
req
.
session
.
mobileForumUser
.
source
;
httpService
.
createLog
(
req
,
source
,
fid
,
2
);
httpService
.
createLog
(
req
,
source
,
fid
,
2
);
async
.
waterfall
([
forumInfoService
.
updateInfoPvCount
(
fid
,
function
(
err
,
result
)
{
if
(
err
)
{
console
.
error
(
err
);
}
});
async
.
parallel
([
function
(
callback
)
{
function
(
callback
)
{
//更新浏览数
forumInfoService
.
updateInfoPvCount
(
fid
,
function
(
err
,
result
)
{
if
(
err
)
{
callback
(
err
,
null
);
}
else
{
callback
(
null
,
null
);
}
});
},
function
(
data
,
callback
)
{
forumInfoService
.
getInfoById
(
fid
,
function
(
err
,
info
)
{
forumInfoService
.
getInfoById
(
fid
,
function
(
err
,
info
)
{
if
(
err
)
{
if
(
err
)
{
callback
(
err
,
null
);
callback
(
err
,
null
);
...
@@ -86,25 +83,25 @@ router.get('/info/:fid/get', function(req, res, next) {
...
@@ -86,25 +83,25 @@ router.get('/info/:fid/get', function(req, res, next) {
}
}
});
});
},
},
function
(
info
,
callback
)
{
function
(
callback
)
{
forumThreadService
.
getAllCountByFid
({
forumThreadService
.
getAllCountByFid
({
info
:
fid
info
:
fid
},
function
(
err
,
threadCount
)
{
},
function
(
err
,
threadCount
)
{
if
(
err
)
{
if
(
err
)
{
callback
(
err
,
null
,
null
);
callback
(
err
,
null
);
}
else
{
}
else
{
callback
(
null
,
info
,
threadCount
);
callback
(
null
,
threadCount
);
}
}
});
});
}
}
],
function
(
err
,
info
,
threadCount
)
{
],
function
(
err
,
results
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
err
);
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
}
else
{
var
rs
=
{};
var
rs
=
{};
rs
.
data
=
info
;
rs
.
data
=
results
[
0
]
;
rs
.
data
.
threadCount
=
threadCount
;
rs
.
data
.
threadCount
=
results
[
1
]
;
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
}
});
});
...
@@ -170,17 +167,18 @@ router.get('/info/:fid/threads', function(req, res, next) {
...
@@ -170,17 +167,18 @@ router.get('/info/:fid/threads', function(req, res, next) {
if
(
fid
)
{
if
(
fid
)
{
async
.
waterfall
([
async
.
waterfall
([
function
(
callback
)
{
function
(
callback
)
{
forumUserThreadControlService
.
getUserThreadControlById
(
user
.
getMobileUser
(
req
),
function
(
err
,
doc
)
{
callback
(
null
,
null
);
if
(
err
)
{
// forumUserThreadControlService.getUserThreadControlById(user.getMobileUser(req), function(err, doc) {
callback
(
err
,
null
);
// if (err) {
}
else
{
// callback(err, null);
if
(
doc
)
{
// } else {
callback
(
null
,
doc
);
// if (doc) {
}
else
{
// callback(null, doc);
callback
(
null
,
null
);
// } else {
}
// callback(null, null);
}
// }
});
// }
// });
}
}
],
function
(
err
,
result
)
{
],
function
(
err
,
result
)
{
if
(
err
)
{
if
(
err
)
{
...
@@ -667,6 +665,8 @@ router.get('/info/:fid/tags', function(req, res, next) {
...
@@ -667,6 +665,8 @@ router.get('/info/:fid/tags', function(req, res, next) {
console
.
error
(
err
);
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
}
else
{
res
.
setHeader
(
'Cache-Control'
,
'public, max-age=3600'
);
// 公共缓存一个小时
res
.
setHeader
(
'Expires'
,
new
Date
(
Date
.
now
()
+
3600000
).
toUTCString
());
res
.
json
(
_
.
assign
(
results
,
returnCode
.
SUCCESS
));
res
.
json
(
_
.
assign
(
results
,
returnCode
.
SUCCESS
));
}
}
});
});
...
...
app/controllers/mobile/forumModerator.js
View file @
585ec733
...
@@ -72,6 +72,8 @@ router.get('/moderators/plates', function(req, res, next) {
...
@@ -72,6 +72,8 @@ router.get('/moderators/plates', function(req, res, next) {
if
(
result
&&
result
.
infoIds
){
if
(
result
&&
result
.
infoIds
){
items
=
result
.
infoIds
;
items
=
result
.
infoIds
;
}
}
res
.
setHeader
(
'Cache-Control'
,
'public, max-age=3600'
);
// 公共缓存一个小时
res
.
setHeader
(
'Expires'
,
new
Date
(
Date
.
now
()
+
3600000
).
toUTCString
());
res
.
json
(
_
.
assign
({
items
:
items
},
returnCode
.
SUCCESS
));
res
.
json
(
_
.
assign
({
items
:
items
},
returnCode
.
SUCCESS
));
});
});
});
});
...
...
app/controllers/mobile/forumThread.js
View file @
585ec733
...
@@ -518,20 +518,16 @@ router.get('/thread/:tid/get', function(req, res, next) {
...
@@ -518,20 +518,16 @@ router.get('/thread/:tid/get', function(req, res, next) {
var
tid
=
req
.
params
.
tid
||
null
;
var
tid
=
req
.
params
.
tid
||
null
;
var
ent_code
=
req
.
session
.
user
.
ent_code
;
var
ent_code
=
req
.
session
.
user
.
ent_code
;
if
(
tid
)
{
if
(
tid
)
{
async
.
waterfall
([
async
.
waterfall
([
function
(
callback
)
{
function
(
callback
)
{
forumThreadService
.
updateThreadPvCount
(
tid
,
function
(
err
,
doc
)
{
forumThreadService
.
getThreadById
(
tid
,
function
(
err
,
thread
)
{
//文章类型 1、文章 2、话题 3、照片墙
if
(
err
)
{
if
(
err
)
{
callback
(
err
,
null
);
callback
(
err
,
null
);
}
else
{
}
else
{
callback
(
null
,
null
);
callback
(
null
,
thread
);
}
}
});
},
function
(
data
,
callback
)
{
forumThreadService
.
getThreadById
(
tid
,
function
(
err
,
thread
)
{
//文章类型 1、文章 2、话题 3、照片墙
var
info_id
=
thread
.
info
.
_id
,
var
info_id
=
thread
.
info
.
_id
,
pid
=
thread
.
pid
,
pid
=
thread
.
pid
,
source
=
req
.
session
.
mobileForumUser
.
source
;
source
=
req
.
session
.
mobileForumUser
.
source
;
...
@@ -543,15 +539,12 @@ router.get('/thread/:tid/get', function(req, res, next) {
...
@@ -543,15 +539,12 @@ router.get('/thread/:tid/get', function(req, res, next) {
httpService
.
createLog
(
req
,
source
,
info_id
,
3
,
2
,
tid
);
httpService
.
createLog
(
req
,
source
,
info_id
,
3
,
2
,
tid
);
}
else
if
(
thread
.
type
==
3
&&
thread
.
level
==
1
)
{
}
else
if
(
thread
.
type
==
3
&&
thread
.
level
==
1
)
{
httpService
.
createLog
(
req
,
source
,
info_id
,
3
,
3
,
tid
);
httpService
.
createLog
(
req
,
source
,
info_id
,
3
,
3
,
tid
);
}
}
});
forumThreadService
.
updateThreadPvCount
(
tid
,
function
(
err
,
doc
)
{
if
(
err
)
{
if
(
err
)
{
callback
(
err
,
null
);
console
.
error
(
err
);
}
else
{
}
callback
(
null
,
thread
);
}
});
});
},
},
],
function
(
err
,
thread
)
{
],
function
(
err
,
thread
)
{
...
...
app/service/forumCommentService.js
View file @
585ec733
...
@@ -4,6 +4,18 @@ var ForumComment = mongoose.model('ForumComment');
...
@@ -4,6 +4,18 @@ var ForumComment = mongoose.model('ForumComment');
var
forumUserService
=
require
(
'./forumUserService'
);
var
forumUserService
=
require
(
'./forumUserService'
);
var
async
=
require
(
'async'
);
var
async
=
require
(
'async'
);
var
listCommentFields
=
{
from
:
1
,
content
:
1
,
level
:
1
,
floor
:
1
,
praise_count
:
1
,
comment_count
:
1
,
comments
:
1
,
status
:
1
};
//创建评论
//创建评论
exports
.
createComment
=
function
(
entity
,
callback
)
{
exports
.
createComment
=
function
(
entity
,
callback
)
{
var
forum
=
new
ForumComment
(
entity
);
var
forum
=
new
ForumComment
(
entity
);
...
@@ -125,7 +137,7 @@ exports.getAllComment = function(conditions, pageNo, pageSize, callback) {
...
@@ -125,7 +137,7 @@ exports.getAllComment = function(conditions, pageNo, pageSize, callback) {
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
);
ForumComment
.
find
(
conditions
).
populate
(
'from'
).
populate
(
'to
'
).
limit
(
limit
).
skip
(
skip
).
sort
(
'-created'
).
exec
(
function
(
err
,
docs
)
{
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
)
{
if
(
err
)
{
if
(
err
)
{
console
.
error
(
err
);
console
.
error
(
err
);
callback
(
err
,
null
);
callback
(
err
,
null
);
...
...
app/service/forumThreadService.js
View file @
585ec733
This diff is collapsed.
Click to expand it.
config/express.js
View file @
585ec733
...
@@ -21,7 +21,7 @@ module.exports = function(app, config) {
...
@@ -21,7 +21,7 @@ module.exports = function(app, config) {
app
.
use
(
bodyParser
.
urlencoded
({
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
extended
:
true
}));
}));
app
.
use
(
compress
());
//
app.use(compress());
app
.
use
(
cookieParser
());
app
.
use
(
cookieParser
());
app
.
use
(
methodOverride
());
app
.
use
(
methodOverride
());
app
.
use
(
multiparty
());
app
.
use
(
multiparty
());
...
...
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