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
4282072b
Commit
4282072b
authored
Aug 27, 2015
by
strong
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'Notice' into SANDBOX
parents
2d9cb4e1
ed71dc9d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
18 deletions
+27
-18
commentTips.js
app/controllers/mobile/commentTips.js
+11
-7
forumThread.js
app/controllers/mobile/forumThread.js
+4
-1
commentTips.js
app/utils/commentTips.js
+12
-10
No files found.
app/controllers/mobile/commentTips.js
View file @
4282072b
'use strict'
;
var
express
=
require
(
'express'
),
router
=
express
.
Router
(),
user
=
require
(
'../../utils/user'
),
returnCode
=
require
(
'../../utils/returnCode'
),
commentTips
=
require
(
'../../utils/commentTips'
),
_
=
require
(
'lodash'
);
...
...
@@ -10,8 +11,9 @@ module.exports = function(app) {
};
router
.
get
(
'/commentTips'
,
function
(
req
,
res
,
next
)
{
var
openId
=
req
.
session
.
openUser
.
openId
;
commentTips
.
get
(
openId
,
function
(
err
,
result
){
var
userId
=
user
.
getMobileUser
(
req
);
var
entcode
=
req
.
session
.
user
.
ent_code
;
commentTips
.
get
(
entcode
,
userId
,
function
(
err
,
result
){
if
(
err
){
res
.
json
(
returnCode
.
UNCHECK_ERROR
(
err
));
}
else
{
...
...
@@ -20,9 +22,10 @@ router.get('/commentTips', function(req, res, next) {
});
});
router
.
put
(
'/commentTips'
,
function
(
req
,
res
,
next
)
{
var
openId
=
req
.
session
.
openUser
.
openId
;
commentTips
.
incrTips
(
openId
,
function
(
err
,
result
){
router
.
put
(
'/commentTips/:id'
,
function
(
req
,
res
,
next
)
{
var
userId
=
req
.
params
.
id
;
var
entcode
=
req
.
session
.
user
.
ent_code
;
commentTips
.
incrTips
(
entcode
,
userId
,
function
(
err
,
result
){
if
(
err
){
res
.
json
(
returnCode
.
UNCHECK_ERROR
(
err
));
}
else
{
...
...
@@ -32,8 +35,9 @@ router.put('/commentTips', function(req, res, next) {
});
router
.
put
(
'/commentTips/del'
,
function
(
req
,
res
,
next
)
{
var
openId
=
req
.
session
.
openUser
.
openId
;
commentTips
.
clear
(
openId
,
function
(
err
,
result
){
var
userId
=
user
.
getMobileUser
(
req
);
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 @
4282072b
...
...
@@ -14,7 +14,7 @@ var forumShareLogService = require('../../service/forumShareLogService');
var
forumCommentService
=
require
(
'../../service/forumCommentService'
);
var
forumUserThreadControlService
=
require
(
'../../service/forumUserThreadControlService'
);
var
forumLimitActionRefService
=
require
(
'../../service/forumLimitActionRefService'
);
var
commentTips
=
require
(
'../../utils/commentTips'
);
var
httpService
=
require
(
'../../service/httpService'
);
var
user
=
require
(
'../../utils/user'
);
...
...
@@ -505,6 +505,8 @@ router.post('/thread/:tid/comment/create', function(req, res, next) {
if
(
err
)
{
callback
(
err
,
null
);
}
else
{
//
commentTips
.
incrTips
(
req
.
session
.
user
.
ent_code
,
thread
.
from
);
var
comments
=
thread
.
comments
;
// console.log('=========');
// console.log(comments);
...
...
@@ -664,6 +666,7 @@ router.post('/thread/:tid/comment/:cid/create', function(req, res, next) {
if
(
err
)
{
callback
(
err
,
null
);
}
else
{
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 @
4282072b
'use strict'
;
var
redis
=
global
.
redis
;
var
prefix
=
'
comment-tips-
'
;
function
getKey
(
open
Id
){
return
prefix
+
open
Id
;
var
prefix
=
'
_forum_comment_count_
'
;
var
expire
=
60
*
60
*
24
*
180
;
function
getKey
(
entcode
,
user
Id
){
return
entcode
+
prefix
+
user
Id
;
}
exports
.
clear
=
function
(
open
Id
,
callback
){
var
key
=
getKey
(
open
Id
);
exports
.
clear
=
function
(
entcode
,
user
Id
,
callback
){
var
key
=
getKey
(
entcode
,
user
Id
);
if
(
!
redis
){
console
.
log
(
'redis error'
);
return
callback
&&
callback
(
'error'
);
...
...
@@ -18,19 +18,21 @@ exports.clear = function(openId,callback){
});
};
exports
.
incrTips
=
function
(
open
Id
,
callback
){
var
key
=
getKey
(
open
Id
);
exports
.
incrTips
=
function
(
entcode
,
user
Id
,
callback
){
var
key
=
getKey
(
entcode
,
user
Id
);
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
(
open
Id
,
callback
){
var
key
=
getKey
(
open
Id
);
exports
.
get
=
function
(
entcode
,
user
Id
,
callback
){
var
key
=
getKey
(
entcode
,
user
Id
);
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