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
0092244b
Commit
0092244b
authored
Aug 27, 2015
by
刘文胜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1111
parent
54ef768f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
17 deletions
+21
-17
commentTips.js
app/controllers/mobile/commentTips.js
+7
-5
forumThread.js
app/controllers/mobile/forumThread.js
+2
-2
commentTips.js
app/utils/commentTips.js
+12
-10
No files found.
app/controllers/mobile/commentTips.js
View file @
0092244b
...
...
@@ -12,8 +12,8 @@ module.exports = function(app) {
router
.
get
(
'/commentTips'
,
function
(
req
,
res
,
next
)
{
var
userId
=
user
.
getMobileUser
(
req
);
console
.
log
(
userId
)
;
commentTips
.
get
(
userId
,
function
(
err
,
result
){
var
entcode
=
req
.
session
.
user
.
ent_code
;
commentTips
.
get
(
entcode
,
userId
,
function
(
err
,
result
){
if
(
err
){
res
.
json
(
returnCode
.
UNCHECK_ERROR
(
err
));
}
else
{
...
...
@@ -22,9 +22,10 @@ router.get('/commentTips', function(req, res, next) {
});
});
router
.
put
(
'/commentTips/:id'
,
function
(
req
,
res
,
next
)
{
router
.
put
(
'/commentTips/:id
/:entcode
'
,
function
(
req
,
res
,
next
)
{
var
userId
=
req
.
params
.
id
;
commentTips
.
incrTips
(
userId
,
function
(
err
,
result
){
var
entcode
=
req
.
params
.
entcode
;
commentTips
.
incrTips
(
entcode
,
userId
,
function
(
err
,
result
){
if
(
err
){
res
.
json
(
returnCode
.
UNCHECK_ERROR
(
err
));
}
else
{
...
...
@@ -35,7 +36,8 @@ router.put('/commentTips/:id', function(req, res, next) {
router
.
put
(
'/commentTips/del'
,
function
(
req
,
res
,
next
)
{
var
userId
=
user
.
getMobileUser
(
req
);
commentTips
.
clear
(
userId
,
function
(
err
,
result
){
var
entcode
=
req
.
session
.
user
.
ent_code
;
commentTips
.
clear
(
entcode
,
userId
,
function
(
err
,
result
){
if
(
err
){
res
.
json
(
returnCode
.
UNCHECK_ERROR
(
err
));
}
else
{
...
...
app/controllers/mobile/forumThread.js
View file @
0092244b
...
...
@@ -506,7 +506,7 @@ router.post('/thread/:tid/comment/create', function(req, res, next) {
callback
(
err
,
null
);
}
else
{
//
commentTips
.
incrTips
(
thread
.
from
);
commentTips
.
incrTips
(
req
.
session
.
user
.
ent_code
,
thread
.
from
);
var
comments
=
thread
.
comments
;
// console.log('=========');
// console.log(comments);
...
...
@@ -666,7 +666,7 @@ router.post('/thread/:tid/comment/:cid/create', function(req, res, next) {
if
(
err
)
{
callback
(
err
,
null
);
}
else
{
commentTips
.
incrTips
(
req
.
body
.
to
);
commentTips
.
incrTips
(
req
.
session
.
user
.
ent_code
,
req
.
body
.
to
);
var
comments
=
comment
.
comments
;
var
array
=
[];
if
(
comments
&&
comments
.
length
>
0
)
{
...
...
app/utils/commentTips.js
View file @
0092244b
'use strict'
;
var
redis
=
global
.
redis
;
var
prefix
=
'
comment-tips-
'
;
function
getKey
(
userId
){
return
prefix
+
userId
;
var
prefix
=
'
_forum_comment_count_
'
;
var
expire
=
60
*
60
*
24
*
180
;
function
getKey
(
entcode
,
userId
){
return
entcode
+
prefix
+
userId
;
}
exports
.
clear
=
function
(
userId
,
callback
){
var
key
=
getKey
(
userId
);
exports
.
clear
=
function
(
entcode
,
userId
,
callback
){
var
key
=
getKey
(
entcode
,
userId
);
if
(
!
redis
){
console
.
log
(
'redis error'
);
return
callback
&&
callback
(
'error'
);
...
...
@@ -18,19 +18,21 @@ exports.clear = function(userId,callback){
});
};
exports
.
incrTips
=
function
(
userId
,
callback
){
var
key
=
getKey
(
userId
);
exports
.
incrTips
=
function
(
entcode
,
userId
,
callback
){
var
key
=
getKey
(
entcode
,
userId
);
if
(
!
redis
){
console
.
log
(
'redis error'
);
return
callback
&&
callback
(
'error'
);
}
redis
.
incr
(
key
,
function
(
error
,
res
){
redis
.
expire
(
key
,
expire
);
return
callback
&&
callback
(
error
,
!!
res
);
});
};
exports
.
get
=
function
(
userId
,
callback
){
var
key
=
getKey
(
userId
);
exports
.
get
=
function
(
entcode
,
userId
,
callback
){
var
key
=
getKey
(
entcode
,
userId
);
if
(
!
redis
){
console
.
log
(
'redis error'
);
return
callback
&&
callback
(
'error'
);
...
...
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