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
Show 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;
...
@@ -11,9 +11,6 @@ import org.slf4j.LoggerFactory;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
@RequestMapping
(
"/test/chuanglan"
)
@RequestMapping
(
"/test/chuanglan"
)
@RestController
@RestController
public
class
ChuangLanApi
{
public
class
ChuangLanApi
{
...
@@ -26,10 +23,7 @@ public class ChuangLanApi {
...
@@ -26,10 +23,7 @@ public class ChuangLanApi {
@PostMapping
(
"/notify"
)
@PostMapping
(
"/notify"
)
public
String
notify
(
@RequestParam
CLNotifyRequest
notifyInfo
)
{
public
String
notify
(
@RequestParam
CLNotifyRequest
notifyInfo
)
{
log
.
info
(
"创蓝异步通知接口入参:{}"
,
JSONObject
.
toJSONString
(
notifyInfo
));
log
.
info
(
"创蓝异步通知接口入参:{}"
,
JSONObject
.
toJSONString
(
notifyInfo
));
chuangLanSmsService
.
asyncNotify
(
notifyInfo
);
chuangLanSmsService
.
asyncNotify
(
notifyInfo
);
String
response
=
"success"
;
String
response
=
"success"
;
log
.
info
(
"创蓝异步通知接口出参:{}"
,
response
);
log
.
info
(
"创蓝异步通知接口出参:{}"
,
response
);
return
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 {
...
@@ -7,10 +7,9 @@ public interface DmHubService {
/**
/**
* 获取DM hub token,用户请求DM hub接口
* 获取DM hub token,用户请求DM hub接口
*
*
* @param accInfo
* @return token信息
* @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
;
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.dmHub.service.DmHubService
;
import
com.jz.sms.util.OkHttpUtil
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
/**
/**
...
@@ -13,12 +17,33 @@ public class DmHubServiceImpl implements DmHubService {
...
@@ -13,12 +17,33 @@ public class DmHubServiceImpl implements DmHubService {
@Override
@Override
public
String
getToken
(
Map
<
String
,
Object
>
accInfo
)
{
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
;
return
null
;
}
}
// TODO 存redis,过期时间=expires-600(秒)
}
@Override
@Override
public
Map
<
String
,
Object
>
smsReport
(
Map
<
String
,
Object
>
accInfo
)
{
public
Map
<
String
,
Object
>
smsReport
(
Map
<
String
,
Object
>
accInfo
)
{
return
null
;
return
null
;
}
}
}
}
src/main/resources/application-prod.yml
View file @
f1a19ceb
...
@@ -29,3 +29,7 @@ system:
...
@@ -29,3 +29,7 @@ system:
addTemplate
:
https://zz.253.com/apis/template/add
# 创建短信模板
addTemplate
:
https://zz.253.com/apis/template/add
# 创建短信模板
interfaceUser
:
admin001
# 接口用户名
interfaceUser
:
admin001
# 接口用户名
interfacePassword
:
9zdata0423
# 接口密码
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:
...
@@ -30,4 +30,8 @@ system:
addTemplate
:
https://zz.253.com/apis/template/add
# 创建短信模板
addTemplate
:
https://zz.253.com/apis/template/add
# 创建短信模板
interfaceUser
:
admin001
# 接口用户名
interfaceUser
:
admin001
# 接口用户名
interfacePassword
:
9zdata0423
# 接口密码
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