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
5a896156
Commit
5a896156
authored
Mar 24, 2015
by
张淼
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
c9f35151
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
60 additions
and
22 deletions
+60
-22
forumThread.js
app/controllers/admin/forumThread.js
+4
-0
forumInfo.js
app/controllers/mobile/forumInfo.js
+9
-11
forumThread.js
app/controllers/mobile/forumThread.js
+26
-6
forumCommentService.js
app/service/forumCommentService.js
+1
-1
forumInfoService.js
app/service/forumInfoService.js
+16
-0
forumPraiseLogService.js
app/service/forumPraiseLogService.js
+3
-2
forumThreadService.js
app/service/forumThreadService.js
+1
-2
No files found.
app/controllers/admin/forumThread.js
View file @
5a896156
...
...
@@ -195,11 +195,15 @@ router.get('/threads/list', function(req, res, next) {
var
pageNo
=
req
.
query
.
pageNo
||
1
;
var
pageSize
=
req
.
query
.
pageSize
||
10
;
var
infoId
=
req
.
query
.
infoId
;
var
tagId
=
req
.
query
.
tagId
;
var
conditions
=
{
ent_code
:
req
.
session
.
user
.
ent_code
,
};
if
(
infoId
){
conditions
.
info
=
infoId
;
}
if
(
tagId
){
conditions
.
tag
=
{
$in
:[
tagId
]};
}
forumThreadService
.
getAllThreadByFid
(
conditions
,
pageNo
,
pageSize
,
function
(
err
,
results
){
if
(
err
){
...
...
app/controllers/mobile/forumInfo.js
View file @
5a896156
...
...
@@ -40,22 +40,20 @@ router.get('/info/:fid/get', function(req, res, next) {
if
(
fid
)
{
async
.
waterfall
([
function
(
callback
){
forumInfoService
.
getInfoById
(
fid
,
function
(
err
,
info
){
if
(
err
)
{
//更新浏览数
forumInfoService
.
updateInfoPvCount
(
fid
,
function
(
err
,
result
){
if
(
err
){
callback
(
err
,
null
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
callback
(
null
,
info
);
}
else
{
callback
(
null
,
null
);
}
});
},
function
(
info
,
callback
){
var
pv_count
=
info
.
pv_count
+
1
;
info
.
pv_count
=
pv_count
;
forumInfoService
.
updateInfoById
(
fid
,{
pv_count
:
pv_count
},
function
(
err
,
result
){
if
(
err
){
function
(
data
,
callback
){
forumInfoService
.
getInfoById
(
fid
,
function
(
err
,
info
){
if
(
err
)
{
callback
(
err
,
null
);
}
else
{
}
else
{
callback
(
null
,
info
);
}
});
...
...
app/controllers/mobile/forumThread.js
View file @
5a896156
...
...
@@ -163,7 +163,7 @@ router.post('/thread/:tid/raise', function(req, res, next) {
var
exp
=
req
.
session
.
openUser
.
exp
||
0
;
//判断是否已经点赞
forumPraiseLogService
.
queryPraiseLog
(
tid
,
null
,
user
.
getMobileUser
(),
function
(
err
,
logs
){
forumPraiseLogService
.
queryPraiseLog
(
tid
,
null
,
user
.
getMobileUser
(),
1
,
function
(
err
,
logs
){
if
(
err
){
res
.
json
(
returnCode
.
BUSY
);
}
else
{
...
...
@@ -219,7 +219,16 @@ router.post('/thread/:tid/raise', function(req, res, next) {
res
.
json
(
returnCode
.
BUSY
);
}
else
{
httpService
.
sendRequest
(
req
.
session
.
user
.
ent_code
,
user
.
getOpenId
(),
tid
,
'raise'
);
res
.
json
(
returnCode
.
SUCCESS
);
forumThreadService
.
getThreadById
(
tid
,
function
(
err
,
doc
){
if
(
err
){
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
var
rs
=
{};
rs
.
praise_count
=
doc
.
praise_count
;
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
});
}
});
}
...
...
@@ -624,7 +633,7 @@ router.post('/thread/:tid/comment/:cid/raise', function(req, res, next) {
var
integral
=
req
.
session
.
openUser
.
integral
||
0
;
var
exp
=
req
.
session
.
openUser
.
exp
||
0
;
//判断是否已经点赞
forumPraiseLogService
.
queryPraiseLog
(
tid
,
cid
,
user
.
getMobileUser
(),
function
(
err
,
logs
){
forumPraiseLogService
.
queryPraiseLog
(
tid
,
cid
,
user
.
getMobileUser
(),
2
,
function
(
err
,
logs
){
if
(
err
){
res
.
json
(
returnCode
.
BUSY
);
}
else
{
...
...
@@ -647,9 +656,9 @@ router.post('/thread/:tid/comment/:cid/raise', function(req, res, next) {
forumCommentService
.
updatePraiseCount
(
cid
,
function
(
err
,
results
){
if
(
err
){
console
.
log
(
err
);
res
.
json
(
returnCode
.
BUSY
);
callback
(
err
,
null
);
}
else
{
res
.
json
(
returnCode
.
SUCCESS
);
callback
(
null
,
null
);
}
});
},
...
...
@@ -676,7 +685,18 @@ router.post('/thread/:tid/comment/:cid/raise', function(req, res, next) {
res
.
json
(
returnCode
.
BUSY
);
}
else
{
httpService
.
sendRequest
(
req
.
session
.
user
.
ent_code
,
user
.
getOpenId
(),
tid
,
'raise'
);
res
.
json
(
returnCode
.
SUCCESS
);
//返回点赞总数
forumCommentService
.
getCommentById
(
cid
,
function
(
err
,
doc
){
if
(
err
){
console
.
error
(
err
);
res
.
json
(
returnCode
.
BUSY
);
}
else
{
var
rs
=
{};
rs
.
praise_count
=
doc
.
praise_count
;
res
.
json
(
_
.
assign
(
rs
,
returnCode
.
SUCCESS
));
}
});
}
});
}
...
...
app/service/forumCommentService.js
View file @
5a896156
...
...
@@ -95,7 +95,7 @@ exports.getAllComment= function(conditions,pageNo,pageSize,callback) {
callback
(
err
,
null
);
}
else
{
var
newobj
=
doc
.
toObject
();
newobj
.
comments
=
c
;
newobj
.
comments
=
(
c
==
null
?[]:
c
)
;
callback
(
null
,
newobj
);
}
});
...
...
app/service/forumInfoService.js
View file @
5a896156
...
...
@@ -88,3 +88,19 @@ exports.getAllByGid= function(conditions,pageNo,pageSize,callback) {
}
});
};
//更新板块浏览数
exports
.
updateInfoPvCount
=
function
(
fid
,
callback
){
ForumInfo
.
update
(
{
_id
:
fid
},
{
$inc
:
{
pv_count
:
1
}},
{
w
:
1
,
safe
:
true
},
function
(
err
,
result
){
if
(
err
){
console
.
error
(
err
);
callback
(
err
,
null
);
}
else
{
callback
(
null
,
null
);
}
});
};
app/service/forumPraiseLogService.js
View file @
5a896156
...
...
@@ -15,10 +15,11 @@ exports.createPraiseLog=function(entity,callback){
});
};
exports
.
queryPraiseLog
=
function
(
tid
,
cid
,
user
,
callback
){
exports
.
queryPraiseLog
=
function
(
tid
,
cid
,
user
,
type
,
callback
){
var
conditions
=
{
user
:
user
,
thread
:
tid
thread
:
tid
,
type
:
type
};
if
(
cid
){
conditions
.
comment
=
cid
;
...
...
app/service/forumThreadService.js
View file @
5a896156
...
...
@@ -73,13 +73,12 @@ exports.getThreadById=function(tid,callback){
}
else
{
var
thread
=
results
[
0
];
var
comments
=
results
[
1
];
// console.log(
comments
);
// console.log(
thread
);
var
threadObj
=
thread
.
toObject
();
threadObj
.
comments
=
comments
;
callback
(
null
,
threadObj
);
}
});
};
//根据ID更新文章
...
...
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