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
f1a19ceb
Commit
f1a19ceb
authored
Apr 24, 2020
by
qinxunjia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dmhub获取token基础流程
parent
52fa15b7
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
70 additions
and
12 deletions
+70
-12
ChuangLanApi.java
src/main/java/com/jz/sms/api/ChuangLanApi.java
+0
-6
DmHubConfig.java
src/main/java/com/jz/sms/dmHub/config/DmHubConfig.java
+32
-0
DmHubService.java
src/main/java/com/jz/sms/dmHub/service/DmHubService.java
+1
-2
DmHubServiceImpl.java
.../java/com/jz/sms/dmHub/service/impl/DmHubServiceImpl.java
+28
-3
application-prod.yml
src/main/resources/application-prod.yml
+5
-1
application-test.yml
src/main/resources/application-test.yml
+4
-0
No files found.
src/main/java/com/jz/sms/api/ChuangLanApi.java
View file @
f1a19ceb
...
...
@@ -11,9 +11,6 @@ import org.slf4j.LoggerFactory;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
@RequestMapping
(
"/test/chuanglan"
)
@RestController
public
class
ChuangLanApi
{
...
...
@@ -26,10 +23,7 @@ public class ChuangLanApi {
@PostMapping
(
"/notify"
)
public
String
notify
(
@RequestParam
CLNotifyRequest
notifyInfo
)
{
log
.
info
(
"创蓝异步通知接口入参:{}"
,
JSONObject
.
toJSONString
(
notifyInfo
));
chuangLanSmsService
.
asyncNotify
(
notifyInfo
);
String
response
=
"success"
;
log
.
info
(
"创蓝异步通知接口出参:{}"
,
response
);
return
response
;
...
...
src/main/java/com/jz/sms/dmHub/config/DmHubConfig.java
0 → 100644
View file @
f1a19ceb
package
com
.
jz
.
sms
.
dmHub
.
config
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
@Component
public
class
DmHubConfig
{
// 应用过id
public
static
String
applicationId
;
// 应用key
public
static
String
applicationKey
;
public
static
String
tokenUrl
;
@Value
(
"${system.config.dmHub.applicationId}"
)
public
void
setApplicationId
(
String
applicationId
)
{
DmHubConfig
.
applicationId
=
applicationId
;
}
@Value
(
"{system.config.dmHub.applicationKey}"
)
public
void
setApplicationKey
(
String
applicationKey
)
{
DmHubConfig
.
applicationKey
=
applicationKey
;
}
@Value
(
"{system.config.dmHub.tokenUrl}"
)
public
void
setTokenUrl
(
String
tokenUrl
)
{
DmHubConfig
.
tokenUrl
=
tokenUrl
;
}
}
src/main/java/com/jz/sms/dmHub/service/DmHubService.java
View file @
f1a19ceb
...
...
@@ -7,10 +7,9 @@ public interface DmHubService {
/**
* 获取DM hub token,用户请求DM hub接口
*
* @param accInfo
* @return token信息
*/
String
getToken
(
Map
<
String
,
Object
>
accInfo
);
String
getToken
();
/**
...
...
src/main/java/com/jz/sms/dmHub/service/impl/DmHubServiceImpl.java
View file @
f1a19ceb
package
com
.
jz
.
sms
.
dmHub
.
service
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jz.sms.dmHub.config.DmHubConfig
;
import
com.jz.sms.dmHub.service.DmHubService
;
import
com.jz.sms.util.OkHttpUtil
;
import
org.springframework.stereotype.Service
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
...
...
@@ -13,12 +17,33 @@ public class DmHubServiceImpl implements DmHubService {
@Override
public
String
getToken
(
Map
<
String
,
Object
>
accInfo
)
{
return
null
;
public
String
getToken
()
{
String
appid
=
DmHubConfig
.
applicationId
;
String
secret
=
DmHubConfig
.
applicationKey
;
String
tokenUrl
=
DmHubConfig
.
tokenUrl
;
String
grantType
=
"client_credentials"
;
Map
<
String
,
String
>
requestMap
=
new
HashMap
<>();
requestMap
.
put
(
"appid"
,
appid
);
requestMap
.
put
(
"secret"
,
secret
);
requestMap
.
put
(
"grant_type"
,
grantType
);
String
retStr
=
OkHttpUtil
.
get
(
tokenUrl
,
requestMap
);
JSONObject
retJson
=
JSONObject
.
parseObject
(
retStr
);
String
errorCode
=
retJson
.
getString
(
"error_code"
);
if
(
"0"
.
equals
(
errorCode
))
{
String
accessToken
=
retJson
.
getString
(
"access_token"
);
String
expires
=
retJson
.
getString
(
"expires_in"
);
return
accessToken
;
}
else
{
return
null
;
}
// TODO 存redis,过期时间=expires-600(秒)
}
@Override
public
Map
<
String
,
Object
>
smsReport
(
Map
<
String
,
Object
>
accInfo
)
{
public
Map
<
String
,
Object
>
smsReport
(
Map
<
String
,
Object
>
accInfo
)
{
return
null
;
}
}
src/main/resources/application-prod.yml
View file @
f1a19ceb
...
...
@@ -28,4 +28,8 @@ system:
pullReport
:
http://smssh1.253.com/msg/pull/report
# 拉取短信报告
addTemplate
:
https://zz.253.com/apis/template/add
# 创建短信模板
interfaceUser
:
admin001
# 接口用户名
interfacePassword
:
9zdata0423
# 接口密码
\ No newline at end of file
interfacePassword
:
9zdata0423
# 接口密码
dmHub
:
applicationId
:
cl0300171a6012c21
applicationKey
:
4017078e9dfd593b2d9a0ede58eff589644fbe50
tokenUrl
:
https://api.convertlab.com/security/accesstoken
\ No newline at end of file
src/main/resources/application-test.yml
View file @
f1a19ceb
...
...
@@ -30,4 +30,8 @@ system:
addTemplate
:
https://zz.253.com/apis/template/add
# 创建短信模板
interfaceUser
:
admin001
# 接口用户名
interfacePassword
:
9zdata0423
# 接口密码
dmHub
:
applicationId
:
cl0300171a6012c21
applicationKey
:
4017078e9dfd593b2d9a0ede58eff589644fbe50
tokenUrl
:
https://api.convertlab.com/security/accesstoken
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