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
92458d84
Commit
92458d84
authored
Apr 08, 2016
by
刘文胜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
赠送积分改为调用 封装了rabbitmq的restful接口
parent
1c7c8602
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
10 deletions
+55
-10
httpService.js
app/service/httpService.js
+55
-10
No files found.
app/service/httpService.js
View file @
92458d84
...
...
@@ -15,14 +15,43 @@ var ACTION_KEY = {
};
var
mongoose
=
require
(
'mongoose'
),
moment
=
require
(
'moment'
),
then
=
require
(
'thenjs'
);
then
=
require
(
'thenjs'
),
request
=
require
(
'request'
),
config
=
require
(
'../../config/config'
),
_
=
require
(
'lodash'
);
var
ForumPVLog
=
mongoose
.
model
(
'ForumPVLog'
),
ForumUVLog
=
mongoose
.
model
(
'ForumUVLog'
),
ForumShareLog
=
mongoose
.
model
(
'ForumShareLog'
),
ForumThread
=
mongoose
.
model
(
'ForumThread'
);
function
paramSort
(
obj
){
try
{
var
keys
=
_
.
map
(
obj
,
function
(
v
,
k
){
return
k
;
}).
sort
();
return
_
.
map
(
keys
,
function
(
n
){
return
(
obj
[
n
]
||
''
).
toString
();
}).
join
(
''
);
}
catch
(
e
){
console
.
log
(
'参数排序失败'
,
e
);
}
}
function
createSignature
(
str
){
var
signature
=
null
;
try
{
var
Buffer
=
require
(
"buffer"
).
Buffer
;
var
buf
=
new
Buffer
(
str
);
var
str
=
buf
.
toString
(
"binary"
);
return
require
(
"crypto"
).
createHash
(
"md5"
).
update
(
str
).
digest
(
"hex"
);
}
catch
(
e
){
console
.
log
(
'生成参数签名错误'
,
e
);
}
return
signature
;
}
exports
.
sendRequest
=
function
(
ent_code
,
mid
,
action
,
messageid
,
integral
,
exp
)
{
var
obj
=
{
/*
var obj = {
tag: 'member',
key: 'forum',
action: ACTION_KEY[action],
...
...
@@ -36,6 +65,22 @@ exports.sendRequest = function(ent_code, mid, action, messageid, integral, exp)
if (err) {
console.error(err);
}
});*/
//使用 rabbitmq 提供的restful接口
var
obj
=
{
action
:
ACTION_KEY
[
action
],
mid
:
mid
,
entCode
:
ent_code
};
//将参数排序
obj
.
signature
=
createSignature
(
paramSort
(
obj
));
//接口调用参数签名
request
.
post
({
url
:
config
.
rest_api
+
'/v1.0/internal/taskcenter/integral/change'
,
json
:
obj
},
function
(
e
,
r
,
body
)
{
if
(
e
)
{
console
.
log
(
e
)
}
});
};
...
...
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