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
ac543813
Commit
ac543813
authored
Aug 27, 2015
by
刘文胜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
当用户的帖子或者评论被其他用户评论时,该用户在社区页面的更多按钮上会看到条数提示。api
parent
51aa12a5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
0 deletions
+84
-0
commentTips.js
app/controllers/mobile/commentTips.js
+43
-0
commentTips.js
app/utils/commentTips.js
+41
-0
No files found.
app/controllers/mobile/commentTips.js
0 → 100644
View file @
ac543813
'use strict'
;
var
express
=
require
(
'express'
),
router
=
express
.
Router
(),
returnCode
=
require
(
'../../utils/returnCode'
),
commentTips
=
require
(
'../../utils/commentTips'
),
_
=
require
(
'lodash'
);
module
.
exports
=
function
(
app
)
{
app
.
use
(
'/v1/forum'
,
router
);
};
router
.
get
(
'/commentTips'
,
function
(
req
,
res
,
next
)
{
var
openId
=
req
.
session
.
openUser
.
openId
;
commentTips
.
get
(
openId
,
function
(
err
,
result
){
if
(
err
){
res
.
json
(
returnCode
.
UNCHECK_ERROR
(
err
));
}
else
{
res
.
json
(
_
.
assign
(
result
,
returnCode
.
SUCCESS
));
}
});
});
router
.
put
(
'/commentTips'
,
function
(
req
,
res
,
next
)
{
var
openId
=
req
.
session
.
openUser
.
openId
;
commentTips
.
incrTips
(
openId
,
function
(
err
,
result
){
if
(
err
){
res
.
json
(
returnCode
.
UNCHECK_ERROR
(
err
));
}
else
{
res
.
json
(
_
.
assign
(
result
,
returnCode
.
SUCCESS
));
}
});
});
router
.
put
(
'/commentTips/del'
,
function
(
req
,
res
,
next
)
{
var
openId
=
req
.
session
.
openUser
.
openId
;
commentTips
.
clear
(
openId
,
function
(
err
,
result
){
if
(
err
){
res
.
json
(
returnCode
.
UNCHECK_ERROR
(
err
));
}
else
{
res
.
json
(
_
.
assign
(
result
,
returnCode
.
SUCCESS
));
}
});
});
\ No newline at end of file
app/utils/commentTips.js
0 → 100644
View file @
ac543813
'use strict'
;
var
redis
=
global
.
redis
;
var
prefix
=
'comment-tips-'
;
function
getKey
(
openId
){
return
prefix
+
openId
;
}
exports
.
clear
=
function
(
openId
,
callback
){
var
key
=
getKey
(
openId
);
if
(
!
redis
){
console
.
log
(
'redis error'
);
return
callback
&&
callback
(
'error'
);
}
redis
.
del
(
key
,
function
(
error
,
res
){
return
callback
&&
callback
(
error
,
!!
res
);
});
};
exports
.
incrTips
=
function
(
openId
,
callback
){
var
key
=
getKey
(
openId
);
if
(
!
redis
){
console
.
log
(
'redis error'
);
return
callback
&&
callback
(
'error'
);
}
redis
.
incr
(
key
,
function
(
error
,
res
){
return
callback
&&
callback
(
error
,
!!
res
);
});
};
exports
.
get
=
function
(
openId
,
callback
){
var
key
=
getKey
(
openId
);
if
(
!
redis
){
console
.
log
(
'redis error'
);
return
callback
&&
callback
(
'error'
);
}
redis
.
get
(
key
,
function
(
error
,
res
){
return
callback
&&
callback
(
error
,
res
||
0
);
});
};
\ 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