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
6cd1184e
Commit
6cd1184e
authored
Jun 12, 2020
by
qinxunjia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dmhub发送短信验证码的接口
parent
494b7825
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
118 additions
and
58 deletions
+118
-58
DmHubApi.java
src/main/java/com/bgy/sms/channel/api/DmHubApi.java
+31
-12
DmHubCodeRequest.java
src/main/java/com/bgy/sms/channel/dto/DmHubCodeRequest.java
+30
-0
DmHubResponse.java
src/main/java/com/bgy/sms/channel/dto/DmHubResponse.java
+9
-17
MessageService.java
src/main/java/com/bgy/sms/service/MessageService.java
+7
-5
MessageServiceImpl.java
...ain/java/com/bgy/sms/service/impl/MessageServiceImpl.java
+41
-24
No files found.
src/main/java/com/bgy/sms/channel/api/DmHubApi.java
View file @
6cd1184e
...
...
@@ -25,17 +25,36 @@ public class DmHubApi {
* @return
*/
@PostMapping
(
"/sms/template"
)
public
DmHub
Template
Response
template
(
@RequestBody
DmHubTemplateRequest
params
)
{
public
DmHubResponse
template
(
@RequestBody
DmHubTemplateRequest
params
)
{
log
.
info
(
"**********创建模板接口入参*******:{}"
,
JSONObject
.
toJSONString
(
params
));
DmHub
TemplateResponse
templat
e
;
DmHub
Response
respons
e
;
try
{
templat
e
=
messageService
.
createTemplate
(
params
);
respons
e
=
messageService
.
createTemplate
(
params
);
}
catch
(
Exception
e
)
{
log
.
error
(
"创建模板短信异常"
,
e
);
template
=
new
DmHubTemplateResponse
(
ResponseCode
.
SYSTEM_ERROR
);
response
=
new
DmHubResponse
(
"999"
,
"创建模板短信异常"
);
}
log
.
info
(
"**********创建模板接口出参*******:{}"
,
JSONObject
.
toJSONString
(
template
));
return
template
;
log
.
info
(
"**********创建模板接口出参*******:{}"
,
JSONObject
.
toJSONString
(
response
));
return
response
;
}
/**
* 发送短信验证码
*
* @return
*/
@PostMapping
(
"/sms/verifyCode"
)
public
DmHubResponse
verifyCode
(
@RequestBody
DmHubCodeRequest
params
)
{
log
.
info
(
"**********发送短信验证码*******:{}"
,
JSONObject
.
toJSONString
(
params
));
DmHubResponse
response
;
try
{
response
=
messageService
.
sendCode
(
params
);
}
catch
(
Exception
e
)
{
log
.
error
(
"发送验证码短信异常"
,
e
);
response
=
new
DmHubResponse
(
"999"
,
"发送验证码短信异常"
);
}
log
.
info
(
"**********发送短信验证码出参*******:{}"
,
JSONObject
.
toJSONString
(
response
));
return
response
;
}
...
...
@@ -45,14 +64,14 @@ public class DmHubApi {
* @return
*/
@PostMapping
(
"/sms/batch"
)
public
DmHub
Send
Response
batch
(
@RequestBody
DmHubBatchSendRequest
request
)
{
public
DmHubResponse
batch
(
@RequestBody
DmHubBatchSendRequest
request
)
{
log
.
info
(
"**********批量发送入参*******:{}"
,
JSONObject
.
toJSONString
(
request
));
DmHub
Send
Response
response
;
DmHubResponse
response
;
try
{
response
=
messageService
.
batchSendOneByOne
(
request
);
}
catch
(
Exception
e
)
{
log
.
error
(
"发送批量短信异常"
,
e
);
response
=
new
DmHub
Send
Response
(
ResponseCode
.
SYSTEM_ERROR
);
response
=
new
DmHubResponse
(
ResponseCode
.
SYSTEM_ERROR
);
}
log
.
info
(
"**********批量发送出参*******:{}"
,
response
);
return
response
;
...
...
@@ -64,14 +83,14 @@ public class DmHubApi {
* @return
*/
@RequestMapping
(
"/sms/send"
)
public
DmHub
Send
Response
send
(
@RequestBody
DmHubSendRequest
request
)
{
public
DmHubResponse
send
(
@RequestBody
DmHubSendRequest
request
)
{
log
.
info
(
"**********单条发送入参*******:{}"
,
JSONObject
.
toJSONString
(
request
));
DmHub
Send
Response
response
;
DmHubResponse
response
;
try
{
response
=
messageService
.
send
(
request
);
}
catch
(
Exception
e
)
{
log
.
error
(
"发送单条短信异常"
,
e
);
response
=
new
DmHub
Send
Response
(
ResponseCode
.
SYSTEM_ERROR
);
response
=
new
DmHubResponse
(
ResponseCode
.
SYSTEM_ERROR
);
}
log
.
info
(
"**********单条发送出参*******:{}"
,
JSONObject
.
toJSONString
(
response
));
return
response
;
...
...
src/main/java/com/bgy/sms/channel/dto/DmHub
TemplateResponse
.java
→
src/main/java/com/bgy/sms/channel/dto/DmHub
CodeRequest
.java
View file @
6cd1184e
package
com
.
bgy
.
sms
.
channel
.
dto
;
import
com.bgy.sms.config.ResponseCode
;
import
java.io.Serializable
;
public
class
DmHub
TemplateResponse
implements
Serializable
{
public
class
DmHub
CodeRequest
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
String
mobile
;
private
String
code
;
public
DmHubTemplateResponse
()
{
}
public
DmHubTemplateResponse
(
String
code
,
String
msg
)
{
this
.
code
=
code
;
public
String
getMobile
()
{
return
mobile
;
}
public
DmHubTemplateResponse
(
ResponseCode
responseCod
e
)
{
this
.
code
=
responseCode
.
getCode
()
;
public
void
setMobile
(
String
mobil
e
)
{
this
.
mobile
=
mobile
;
}
public
String
getCode
()
{
...
...
src/main/java/com/bgy/sms/channel/dto/DmHub
Send
Response.java
→
src/main/java/com/bgy/sms/channel/dto/DmHubResponse.java
View file @
6cd1184e
...
...
@@ -5,7 +5,7 @@ import com.bgy.sms.config.ResponseCode;
import
java.io.Serializable
;
public
class
DmHub
Send
Response
implements
Serializable
{
public
class
DmHubResponse
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
...
...
@@ -13,18 +13,18 @@ public class DmHubSendResponse implements Serializable {
private
JSONObject
error
;
public
DmHubSendResponse
()
{
public
DmHubResponse
()
{
}
public
DmHubSendResponse
(
ResponseCode
responseCode
)
{
this
.
code
=
responseCode
.
getCode
();
public
DmHubResponse
(
String
code
,
String
msg
)
{
error
=
new
JSONObject
();
error
.
put
(
"errorCode"
,
code
);
error
.
put
(
"message"
,
msg
);
this
.
code
=
code
;
}
public
DmHubSendResponse
(
String
errorCode
,
String
errorMsg
)
{
error
=
new
JSONObject
();
error
.
put
(
"errorCode"
,
errorCode
);
error
.
put
(
"message"
,
errorMsg
);
public
DmHubResponse
(
ResponseCode
responseCode
)
{
this
.
code
=
responseCode
.
getCode
();
}
public
String
getCode
()
{
...
...
@@ -42,12 +42,4 @@ public class DmHubSendResponse implements Serializable {
public
void
setError
(
JSONObject
error
)
{
this
.
error
=
error
;
}
@Override
public
String
toString
()
{
return
"DmHubSendResponse{"
+
"code='"
+
code
+
'\''
+
"error='"
+
error
.
toString
()
+
'\''
+
'}'
;
}
}
src/main/java/com/bgy/sms/service/MessageService.java
View file @
6cd1184e
...
...
@@ -2,7 +2,7 @@ package com.bgy.sms.service;
import
com.bgy.sms.channel.dto.*
;
public
interface
MessageService
{
public
interface
MessageService
{
/**
* DM hub创建模板同步插件接口
...
...
@@ -10,7 +10,7 @@ public interface MessageService {
* @param requestDTO
* @return
*/
DmHub
Template
Response
createTemplate
(
DmHubTemplateRequest
requestDTO
);
DmHubResponse
createTemplate
(
DmHubTemplateRequest
requestDTO
);
/**
* DM hub发送短信接口
...
...
@@ -18,7 +18,7 @@ public interface MessageService {
* @param requestDTO
* @return
*/
DmHub
Send
Response
send
(
DmHubSendRequest
requestDTO
);
DmHubResponse
send
(
DmHubSendRequest
requestDTO
);
/**
* DM hub批量发送短信接口
...
...
@@ -26,7 +26,7 @@ public interface MessageService {
* @param requestDTO
* @return
*/
DmHub
Send
Response
batchSend
(
DmHubBatchSendRequest
requestDTO
);
DmHubResponse
batchSend
(
DmHubBatchSendRequest
requestDTO
);
/**
* DM hub批量发送短信接口
...
...
@@ -34,5 +34,7 @@ public interface MessageService {
* @param requestDTO
* @return
*/
DmHubSendResponse
batchSendOneByOne
(
DmHubBatchSendRequest
requestDTO
);
DmHubResponse
batchSendOneByOne
(
DmHubBatchSendRequest
requestDTO
);
DmHubResponse
sendCode
(
DmHubCodeRequest
params
);
}
src/main/java/com/bgy/sms/service/impl/MessageServiceImpl.java
View file @
6cd1184e
This diff is collapsed.
Click to expand it.
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