Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dmhub-plugin
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
qinxunjia
dmhub-plugin
Commits
7cbc29fa
Commit
7cbc29fa
authored
Jun 19, 2020
by
qinxunjia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化配置,增加日志
parent
7b5c8a80
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
9 deletions
+18
-9
DmHubApi.java
src/main/java/com/bgy/sms/channel/api/DmHubApi.java
+13
-4
DmHubConfig.java
...in/java/com/bgy/sms/channel/dmHub/config/DmHubConfig.java
+5
-5
No files found.
src/main/java/com/bgy/sms/channel/api/DmHubApi.java
View file @
7cbc29fa
...
@@ -35,7 +35,7 @@ public class DmHubApi {
...
@@ -35,7 +35,7 @@ public class DmHubApi {
try
{
try
{
boolean
checkResult
=
this
.
checkSignature
(
timestamp
,
signature
);
boolean
checkResult
=
this
.
checkSignature
(
timestamp
,
signature
);
if
(!
checkResult
)
{
if
(!
checkResult
)
{
return
new
DmHubResponse
(
"555"
,
"签名校验不通过"
);
return
new
DmHubResponse
(
"555"
,
"
接口请求
签名校验不通过"
);
}
}
response
=
messageService
.
createTemplate
(
params
);
response
=
messageService
.
createTemplate
(
params
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -58,7 +58,7 @@ public class DmHubApi {
...
@@ -58,7 +58,7 @@ public class DmHubApi {
try
{
try
{
boolean
checkResult
=
this
.
checkSignature
(
timestamp
,
signature
);
boolean
checkResult
=
this
.
checkSignature
(
timestamp
,
signature
);
if
(!
checkResult
)
{
if
(!
checkResult
)
{
return
new
DmHubResponse
(
"555"
,
"签名校验不通过"
);
return
new
DmHubResponse
(
"555"
,
"
接口请求
签名校验不通过"
);
}
}
response
=
messageService
.
sendCode
(
params
);
response
=
messageService
.
sendCode
(
params
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -82,7 +82,7 @@ public class DmHubApi {
...
@@ -82,7 +82,7 @@ public class DmHubApi {
try
{
try
{
boolean
checkResult
=
this
.
checkSignature
(
timestamp
,
signature
);
boolean
checkResult
=
this
.
checkSignature
(
timestamp
,
signature
);
if
(!
checkResult
)
{
if
(!
checkResult
)
{
return
new
DmHubResponse
(
"555"
,
"签名校验不通过"
);
return
new
DmHubResponse
(
"555"
,
"
接口请求
签名校验不通过"
);
}
}
response
=
messageService
.
batchSendOneByOne
(
request
);
response
=
messageService
.
batchSendOneByOne
(
request
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -94,8 +94,11 @@ public class DmHubApi {
...
@@ -94,8 +94,11 @@ public class DmHubApi {
}
}
public
boolean
checkSignature
(
String
timestamp
,
String
signature
)
{
public
boolean
checkSignature
(
String
timestamp
,
String
signature
)
{
String
encrypt
=
Md5Util
.
encrypt
(
DmHubConfig
.
appId
+
DmHubConfig
.
appSecret
+
timestamp
);
String
signStr
=
DmHubConfig
.
appId
+
DmHubConfig
.
appSecret
+
"20200619072847"
;
String
encrypt
=
Md5Util
.
encrypt
(
signStr
);
log
.
info
(
"待签名串:"
+
encrypt
);
if
(!
encrypt
.
equals
(
signature
))
{
if
(!
encrypt
.
equals
(
signature
))
{
log
.
error
(
"签名不一致,插件生成签名:{}"
,
encrypt
);
return
false
;
return
false
;
}
}
return
true
;
return
true
;
...
@@ -124,4 +127,10 @@ public class DmHubApi {
...
@@ -124,4 +127,10 @@ public class DmHubApi {
log
.
info
(
"**********单条发送出参*******:{}"
,
JSONObject
.
toJSONString
(
response
));
log
.
info
(
"**********单条发送出参*******:{}"
,
JSONObject
.
toJSONString
(
response
));
return
response
;
return
response
;
}
}
public
static
void
main
(
String
[]
args
)
{
String
a
=
"1smsdemo"
+
"ac031765c3a8c9acc4747808e4fe5918"
+
"20200619070139"
;
String
encrypt
=
Md5Util
.
encrypt
(
a
);
System
.
out
.
println
(
encrypt
);
}
}
}
src/main/java/com/bgy/sms/channel/dmHub/config/DmHubConfig.java
View file @
7cbc29fa
...
@@ -21,27 +21,27 @@ public class DmHubConfig {
...
@@ -21,27 +21,27 @@ public class DmHubConfig {
DmHubConfig
.
applicationId
=
applicationId
;
DmHubConfig
.
applicationId
=
applicationId
;
}
}
@Value
(
"{system.config.dmHub.applicationKey}"
)
@Value
(
"
$
{system.config.dmHub.applicationKey}"
)
public
void
setApplicationKey
(
String
applicationKey
)
{
public
void
setApplicationKey
(
String
applicationKey
)
{
DmHubConfig
.
applicationKey
=
applicationKey
;
DmHubConfig
.
applicationKey
=
applicationKey
;
}
}
@Value
(
"{system.config.dmHub.tokenUrl}"
)
@Value
(
"
$
{system.config.dmHub.tokenUrl}"
)
public
void
setTokenUrl
(
String
tokenUrl
)
{
public
void
setTokenUrl
(
String
tokenUrl
)
{
DmHubConfig
.
tokenUrl
=
tokenUrl
;
DmHubConfig
.
tokenUrl
=
tokenUrl
;
}
}
@Value
(
"{system.config.dmHub.report}"
)
@Value
(
"
$
{system.config.dmHub.report}"
)
public
void
setReport
(
String
report
)
{
public
void
setReport
(
String
report
)
{
DmHubConfig
.
report
=
report
;
DmHubConfig
.
report
=
report
;
}
}
@Value
(
"{system.config.dmHub.appId}"
)
@Value
(
"
$
{system.config.dmHub.appId}"
)
public
void
setAppId
(
String
appId
)
{
public
void
setAppId
(
String
appId
)
{
DmHubConfig
.
appId
=
appId
;
DmHubConfig
.
appId
=
appId
;
}
}
@Value
(
"{system.config.dmHub.appSecret}"
)
@Value
(
"
$
{system.config.dmHub.appSecret}"
)
public
void
setAppSecret
(
String
appSecret
)
{
public
void
setAppSecret
(
String
appSecret
)
{
DmHubConfig
.
appSecret
=
appSecret
;
DmHubConfig
.
appSecret
=
appSecret
;
}
}
...
...
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