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
b9c0ae9a
Commit
b9c0ae9a
authored
Apr 23, 2020
by
qinxunjia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
创建模板的逻辑
parent
e42d6120
Changes
19
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
358 additions
and
81 deletions
+358
-81
BizController.java
src/main/java/com/jz/sms/api/BizController.java
+4
-4
ChuangLanApi.java
src/main/java/com/jz/sms/api/ChuangLanApi.java
+36
-0
ChuangLanSMSConfig.java
.../java/com/jz/sms/chuanglan/config/ChuangLanSMSConfig.java
+25
-11
CLNotifyRequest.java
src/main/java/com/jz/sms/chuanglan/dto/CLNotifyRequest.java
+76
-0
CLSendFixedRequest.java
...ain/java/com/jz/sms/chuanglan/dto/CLSendFixedRequest.java
+1
-1
CLSendFixedResponse.java
...in/java/com/jz/sms/chuanglan/dto/CLSendFixedResponse.java
+1
-5
CLSendVariableRequest.java
.../java/com/jz/sms/chuanglan/dto/CLSendVariableRequest.java
+1
-1
CLSendVariableResponse.java
...java/com/jz/sms/chuanglan/dto/CLSendVariableResponse.java
+1
-1
CLTemplateRequest.java
...main/java/com/jz/sms/chuanglan/dto/CLTemplateRequest.java
+1
-1
CLTemplateResponse.java
...ain/java/com/jz/sms/chuanglan/dto/CLTemplateResponse.java
+66
-0
ChuanLanSmsService.java
...java/com/jz/sms/chuanglan/service/ChuanLanSmsService.java
+5
-3
ChuanLanSmsServiceImpl.java
...jz/sms/chuanglan/service/impl/ChuanLanSmsServiceImpl.java
+64
-35
ChuangLanSmsUtil.java
...ain/java/com/jz/sms/chuanglan/utils/ChuangLanSmsUtil.java
+1
-1
CLTemplateResponse.java
...main/java/com/jz/sms/chuanlan/dto/CLTemplateResponse.java
+0
-4
ResponseCode.java
src/main/java/com/jz/sms/config/ResponseCode.java
+23
-0
SmsTemplateInfo.java
...in/java/com/jz/sms/repository/domain/SmsTemplateInfo.java
+19
-0
MessageServiceImpl.java
...main/java/com/jz/sms/service/impl/MessageServiceImpl.java
+29
-13
application-prod.yml
src/main/resources/application-prod.yml
+3
-1
application-test.yml
src/main/resources/application-test.yml
+2
-0
No files found.
src/main/java/com/jz/sms/api/BizController.java
View file @
b9c0ae9a
...
@@ -28,11 +28,11 @@ public class BizController {
...
@@ -28,11 +28,11 @@ public class BizController {
* @return
* @return
*/
*/
@PostMapping
(
"/sms/template"
)
@PostMapping
(
"/sms/template"
)
public
String
template
(
@RequestBody
DmHubTemplateRequest
params
)
{
public
DmHubTemplateResponse
template
(
@RequestBody
DmHubTemplateRequest
params
)
{
log
.
info
(
"**********创建模板入参*******:{}"
,
JSONObject
.
toJSONString
(
params
));
log
.
info
(
"**********创建模板
接口
入参*******:{}"
,
JSONObject
.
toJSONString
(
params
));
DmHubTemplateResponse
template
=
messageService
.
createTemplate
(
params
);
DmHubTemplateResponse
template
=
messageService
.
createTemplate
(
params
);
log
.
info
(
"**********创建模板接口出参*******:{}"
,
JSONObject
.
toJSONString
(
template
));
return
"ok"
;
return
template
;
}
}
...
...
src/main/java/com/jz/sms/api/ChuangLanApi.java
0 → 100644
View file @
b9c0ae9a
package
com
.
jz
.
sms
.
api
;
import
com.jz.sms.chuanglan.dto.CLNotifyRequest
;
import
com.jz.sms.chuanglan.service.ChuanLanSmsService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.Map
;
@RequestMapping
(
"/test/chuanglan"
)
@RestController
public
class
ChuangLanApi
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
ChuangLanApi
.
class
);
@Autowired
private
ChuanLanSmsService
chuanLanSmsService
;
@PostMapping
(
"/notify"
)
public
String
notify
(
@RequestParam
CLNotifyRequest
notifyInfo
)
{
log
.
info
(
"创蓝异步通知接口入参:{}"
,
notifyInfo
);
chuanLanSmsService
.
asyncNotify
(
notifyInfo
);
String
response
=
"success"
;
log
.
info
(
"创蓝异步通知接口出参:{}"
,
response
);
return
response
;
}
}
src/main/java/com/jz/sms/c
onfig/
SMSConfig.java
→
src/main/java/com/jz/sms/c
huanglan/config/ChuangLan
SMSConfig.java
View file @
b9c0ae9a
package
com
.
jz
.
sms
.
config
;
package
com
.
jz
.
sms
.
c
huanglan
.
c
onfig
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -7,7 +7,7 @@ import org.springframework.stereotype.Component;
...
@@ -7,7 +7,7 @@ import org.springframework.stereotype.Component;
* 短信参数配置
* 短信参数配置
*/
*/
@Component
@Component
public
class
SMSConfig
{
public
class
ChuangLan
SMSConfig
{
// 通知类短信账号
// 通知类短信账号
...
@@ -28,50 +28,64 @@ public class SMSConfig {
...
@@ -28,50 +28,64 @@ public class SMSConfig {
public
static
String
pullReport
;
public
static
String
pullReport
;
// 创建短信模板
// 创建短信模板
public
static
String
addTemplate
;
public
static
String
addTemplate
;
// 接口用户名
public
static
String
interfaceUser
;
// 接口密码
public
static
String
interfacePassword
;
@Value
(
"${system.config.chuanlan.notificationAccount}"
)
@Value
(
"${system.config.chuanlan.notificationAccount}"
)
public
void
setNotificationAccount
(
String
notificationAccount
)
{
public
void
setNotificationAccount
(
String
notificationAccount
)
{
SMSConfig
.
notificationAccount
=
notificationAccount
;
ChuangLan
SMSConfig
.
notificationAccount
=
notificationAccount
;
}
}
@Value
(
"${system.config.chuanlan.notificationPassword}"
)
@Value
(
"${system.config.chuanlan.notificationPassword}"
)
public
void
setNotificationPassword
(
String
notificationPassword
)
{
public
void
setNotificationPassword
(
String
notificationPassword
)
{
SMSConfig
.
notificationPassword
=
notificationPassword
;
ChuangLan
SMSConfig
.
notificationPassword
=
notificationPassword
;
}
}
@Value
(
"${system.config.chuanlan.marketingAccount}"
)
@Value
(
"${system.config.chuanlan.marketingAccount}"
)
public
void
setMarketingAccount
(
String
marketingAccount
)
{
public
void
setMarketingAccount
(
String
marketingAccount
)
{
SMSConfig
.
marketingAccount
=
marketingAccount
;
ChuangLan
SMSConfig
.
marketingAccount
=
marketingAccount
;
}
}
@Value
(
"${system.config.chuanlan.marketingPassword}"
)
@Value
(
"${system.config.chuanlan.marketingPassword}"
)
public
void
setMarketingPassword
(
String
marketingPassword
)
{
public
void
setMarketingPassword
(
String
marketingPassword
)
{
SMSConfig
.
marketingPassword
=
marketingPassword
;
ChuangLan
SMSConfig
.
marketingPassword
=
marketingPassword
;
}
}
@Value
(
"${system.config.chuanlan.sendFixed}"
)
@Value
(
"${system.config.chuanlan.sendFixed}"
)
public
void
setSendFixed
(
String
sendFixed
)
{
public
void
setSendFixed
(
String
sendFixed
)
{
SMSConfig
.
sendFixed
=
sendFixed
;
ChuangLan
SMSConfig
.
sendFixed
=
sendFixed
;
}
}
@Value
(
"${system.config.chuanlan.sendVariable}"
)
@Value
(
"${system.config.chuanlan.sendVariable}"
)
public
void
setSendVariable
(
String
sendVariable
)
{
public
void
setSendVariable
(
String
sendVariable
)
{
SMSConfig
.
sendVariable
=
sendVariable
;
ChuangLan
SMSConfig
.
sendVariable
=
sendVariable
;
}
}
@Value
(
"${system.config.chuanlan.reportUrl}"
)
@Value
(
"${system.config.chuanlan.reportUrl}"
)
public
void
setReportUrl
(
String
reportUrl
)
{
public
void
setReportUrl
(
String
reportUrl
)
{
SMSConfig
.
reportUrl
=
reportUrl
;
ChuangLan
SMSConfig
.
reportUrl
=
reportUrl
;
}
}
@Value
(
"${system.config.chuanlan.pullReport}"
)
@Value
(
"${system.config.chuanlan.pullReport}"
)
public
void
setPullReport
(
String
pullReport
)
{
public
void
setPullReport
(
String
pullReport
)
{
SMSConfig
.
pullReport
=
pullReport
;
ChuangLan
SMSConfig
.
pullReport
=
pullReport
;
}
}
@Value
(
"${system.config.chuanlan.addTemplate}"
)
@Value
(
"${system.config.chuanlan.addTemplate}"
)
public
void
setAddTemplate
(
String
addTemplate
)
{
public
void
setAddTemplate
(
String
addTemplate
)
{
SMSConfig
.
addTemplate
=
addTemplate
;
ChuangLanSMSConfig
.
addTemplate
=
addTemplate
;
}
@Value
(
"${system.config.chuanlan.interfaceUser}"
)
public
void
setInterfaceUser
(
String
interfaceUser
)
{
ChuangLanSMSConfig
.
interfaceUser
=
interfaceUser
;
}
@Value
(
"${system.config.chuanlan.interfacePassword}"
)
public
void
setInterfacePassword
(
String
interfacePassword
)
{
ChuangLanSMSConfig
.
interfacePassword
=
interfacePassword
;
}
}
}
}
src/main/java/com/jz/sms/chuanglan/dto/CLNotifyRequest.java
0 → 100644
View file @
b9c0ae9a
package
com
.
jz
.
sms
.
chuanglan
.
dto
;
public
class
CLNotifyRequest
{
// 接口用户名
private
String
username
;
// 十位时间戳
private
String
timestamp
;
// 签名串
private
String
signature
;
// 模块
private
String
action
;
// 模板id
private
String
id
;
// 审核状态(模板(1审核,2驳回),签名(2通过,3驳回))
private
String
auditStatus
;
// 驳回原因
private
String
auditReason
;
public
String
getUsername
()
{
return
username
;
}
public
void
setUsername
(
String
username
)
{
this
.
username
=
username
;
}
public
String
getTimestamp
()
{
return
timestamp
;
}
public
void
setTimestamp
(
String
timestamp
)
{
this
.
timestamp
=
timestamp
;
}
public
String
getSignature
()
{
return
signature
;
}
public
void
setSignature
(
String
signature
)
{
this
.
signature
=
signature
;
}
public
String
getAction
()
{
return
action
;
}
public
void
setAction
(
String
action
)
{
this
.
action
=
action
;
}
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
String
getAuditStatus
()
{
return
auditStatus
;
}
public
void
setAuditStatus
(
String
auditStatus
)
{
this
.
auditStatus
=
auditStatus
;
}
public
String
getAuditReason
()
{
return
auditReason
;
}
public
void
setAuditReason
(
String
auditReason
)
{
this
.
auditReason
=
auditReason
;
}
}
src/main/java/com/jz/sms/chuanlan/dto/CLSendFixedRequest.java
→
src/main/java/com/jz/sms/chuan
g
lan/dto/CLSendFixedRequest.java
View file @
b9c0ae9a
package
com
.
jz
.
sms
.
chuanlan
.
dto
;
package
com
.
jz
.
sms
.
chuan
g
lan
.
dto
;
public
class
CLSendFixedRequest
{
public
class
CLSendFixedRequest
{
...
...
src/main/java/com/jz/sms/chuanlan/dto/CLSendFixedResponse.java
→
src/main/java/com/jz/sms/chuan
g
lan/dto/CLSendFixedResponse.java
View file @
b9c0ae9a
package
com
.
jz
.
sms
.
chuanlan
.
dto
;
package
com
.
jz
.
sms
.
chuanglan
.
dto
;
import
com.jz.sms.util.DateUtil
;
import
java.text.DateFormat
;
public
class
CLSendFixedResponse
{
public
class
CLSendFixedResponse
{
/**
/**
...
...
src/main/java/com/jz/sms/chuanlan/dto/CLSendVariableRequest.java
→
src/main/java/com/jz/sms/chuan
g
lan/dto/CLSendVariableRequest.java
View file @
b9c0ae9a
package
com
.
jz
.
sms
.
chuanlan
.
dto
;
package
com
.
jz
.
sms
.
chuan
g
lan
.
dto
;
public
class
CLSendVariableRequest
{
public
class
CLSendVariableRequest
{
...
...
src/main/java/com/jz/sms/chuanlan/dto/CLSendVariableResponse.java
→
src/main/java/com/jz/sms/chuan
g
lan/dto/CLSendVariableResponse.java
View file @
b9c0ae9a
package
com
.
jz
.
sms
.
chuanlan
.
dto
;
package
com
.
jz
.
sms
.
chuan
g
lan
.
dto
;
public
class
CLSendVariableResponse
{
public
class
CLSendVariableResponse
{
/**
/**
...
...
src/main/java/com/jz/sms/chuanlan/dto/CLTemplateRequest.java
→
src/main/java/com/jz/sms/chuan
g
lan/dto/CLTemplateRequest.java
View file @
b9c0ae9a
package
com
.
jz
.
sms
.
chuanlan
.
dto
;
package
com
.
jz
.
sms
.
chuan
g
lan
.
dto
;
public
class
CLTemplateRequest
{
public
class
CLTemplateRequest
{
}
}
src/main/java/com/jz/sms/chuanglan/dto/CLTemplateResponse.java
0 → 100644
View file @
b9c0ae9a
package
com
.
jz
.
sms
.
chuanglan
.
dto
;
import
com.jz.sms.config.ResponseCode
;
import
java.io.Serializable
;
public
class
CLTemplateResponse
implements
Serializable
{
private
String
code
;
private
String
msg
;
private
String
id
;
public
CLTemplateResponse
()
{
}
public
CLTemplateResponse
(
ResponseCode
responseCode
,
String
id
)
{
this
.
code
=
responseCode
.
getCode
();
this
.
msg
=
responseCode
.
getMsg
();
this
.
id
=
id
;
}
public
CLTemplateResponse
(
ResponseCode
responseCode
,
String
msg
,
int
nullInfo
)
{
this
.
code
=
responseCode
.
getCode
();
this
.
msg
=
responseCode
.
getMsg
()+
msg
;
}
public
CLTemplateResponse
(
String
code
,
String
msg
)
{
this
.
code
=
code
;
this
.
msg
=
msg
;
}
public
CLTemplateResponse
(
String
code
,
String
msg
,
String
id
)
{
this
.
code
=
code
;
this
.
msg
=
msg
;
this
.
id
=
id
;
}
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
String
getMsg
()
{
return
msg
;
}
public
void
setMsg
(
String
msg
)
{
this
.
msg
=
msg
;
}
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
}
src/main/java/com/jz/sms/chuanlan/service/ChuanLanSmsService.java
→
src/main/java/com/jz/sms/chuan
g
lan/service/ChuanLanSmsService.java
View file @
b9c0ae9a
package
com
.
jz
.
sms
.
chuanlan
.
service
;
package
com
.
jz
.
sms
.
chuan
g
lan
.
service
;
import
com.jz.sms.chuanlan.dto.CLSendFixedResponse
;
import
com.jz.sms.chuanglan.dto.CLNotifyRequest
;
import
com.jz.sms.chuanlan.dto.CLTemplateResponse
;
import
com.jz.sms.chuanglan.dto.CLSendFixedResponse
;
import
com.jz.sms.chuanglan.dto.CLTemplateResponse
;
import
com.jz.sms.dto.*
;
import
com.jz.sms.dto.*
;
import
java.util.List
;
import
java.util.List
;
...
@@ -23,4 +24,5 @@ public interface ChuanLanSmsService {
...
@@ -23,4 +24,5 @@ public interface ChuanLanSmsService {
DmHubBatchSendResponse
sendBatchByVariable
(
DmHubBatchSendRequest
requestDTO
);
DmHubBatchSendResponse
sendBatchByVariable
(
DmHubBatchSendRequest
requestDTO
);
void
asyncNotify
(
CLNotifyRequest
notifyInfo
);
}
}
src/main/java/com/jz/sms/chuanlan/service/impl/ChuanLanSmsServiceImpl.java
→
src/main/java/com/jz/sms/chuan
g
lan/service/impl/ChuanLanSmsServiceImpl.java
View file @
b9c0ae9a
package
com
.
jz
.
sms
.
chuanlan
.
service
.
impl
;
package
com
.
jz
.
sms
.
chuan
g
lan
.
service
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.mapper.EntityWrapper
;
import
com.jz.sms.api.BizController
;
import
com.jz.sms.api.BizController
;
import
com.jz.sms.chuanlan.dto.CLSendFixedRequest
;
import
com.jz.sms.chuanglan.dto.CLNotifyRequest
;
import
com.jz.sms.chuanlan.dto.CLSendFixedResponse
;
import
com.jz.sms.chuanglan.dto.CLSendFixedRequest
;
import
com.jz.sms.chuanlan.dto.CLTemplateResponse
;
import
com.jz.sms.chuanglan.dto.CLSendFixedResponse
;
import
com.jz.sms.chuanlan.service.ChuanLanSmsService
;
import
com.jz.sms.chuanglan.dto.CLTemplateResponse
;
import
com.jz.sms.chuanlan.utils.ChuangLanSmsUtil
;
import
com.jz.sms.chuanglan.service.ChuanLanSmsService
;
import
com.jz.sms.config.SMSConfig
;
import
com.jz.sms.chuanglan.utils.ChuangLanSmsUtil
;
import
com.jz.sms.chuanglan.config.ChuangLanSMSConfig
;
import
com.jz.sms.config.ResponseCode
;
import
com.jz.sms.dto.*
;
import
com.jz.sms.dto.*
;
import
com.jz.sms.repository.domain.SmsTemplateInfo
;
import
com.jz.sms.service.SmsTemplateService
;
import
com.jz.sms.util.HttpUtil
;
import
com.jz.sms.util.HttpUtil
;
import
com.jz.sms.util.Md5Util
;
import
com.jz.sms.util.Md5Util
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -29,25 +34,29 @@ import java.util.Map;
...
@@ -29,25 +34,29 @@ import java.util.Map;
public
class
ChuanLanSmsServiceImpl
implements
ChuanLanSmsService
{
public
class
ChuanLanSmsServiceImpl
implements
ChuanLanSmsService
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
BizController
.
class
);
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
BizController
.
class
);
private
static
final
String
SUCCESS
=
"success"
;
private
static
final
String
ERROR
=
"error"
;
private
static
final
String
CODE
=
"code"
;
private
static
final
String
DATA
=
"data"
;
@Autowired
private
SmsTemplateService
templateService
;
@Override
@Override
public
CLTemplateResponse
createTemplate
(
String
content
,
String
type
)
throws
Exception
{
public
CLTemplateResponse
createTemplate
(
String
content
,
String
type
)
throws
Exception
{
log
.
info
(
"进入创蓝创建短信接口模板的逻辑:{}"
,
content
);
log
.
info
(
"进入创蓝创建短信接口模板的逻辑:{}"
,
content
);
Map
<
String
,
Object
>
requestMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
requestMap
=
new
HashMap
<>();
String
appId
;
String
appId
;
String
username
;
String
username
=
ChuangLanSMSConfig
.
interfaceUser
;
String
password
;
String
password
=
ChuangLanSMSConfig
.
interfacePassword
;
if
(
"notification"
.
equals
(
type
))
{
if
(
"notification"
.
equals
(
type
))
{
appId
=
"49"
;
appId
=
"49"
;
username
=
SMSConfig
.
notificationAccount
;
password
=
SMSConfig
.
notificationPassword
;
}
else
if
(
"marketing"
.
equals
(
type
))
{
}
else
if
(
"marketing"
.
equals
(
type
))
{
appId
=
"52"
;
appId
=
"52"
;
username
=
SMSConfig
.
marketingAccount
;
password
=
SMSConfig
.
notificationPassword
;
}
else
{
}
else
{
// TODO 自定义异常
// TODO 自定义异常,发送警告
throw
new
Exception
(
""
);
log
.
error
(
"错误,传入的模板类型未知,类型为:{}"
,
type
);
return
new
CLTemplateResponse
(
ResponseCode
.
SYSTEM_ERROR
,
"未知的模板类型:"
+
type
,
0
);
}
}
String
timestamp
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
String
timestamp
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
...
@@ -58,10 +67,18 @@ public class ChuanLanSmsServiceImpl implements ChuanLanSmsService {
...
@@ -58,10 +67,18 @@ public class ChuanLanSmsServiceImpl implements ChuanLanSmsService {
requestMap
.
put
(
"appid"
,
appId
);
requestMap
.
put
(
"appid"
,
appId
);
requestMap
.
put
(
"content"
,
content
);
requestMap
.
put
(
"content"
,
content
);
log
.
info
(
"请求创蓝创建短信模板的请求参数为:{}"
,
requestMap
);
log
.
info
(
"请求创蓝创建短信模板的请求参数为:{}"
,
requestMap
);
String
retStr
=
HttpUtil
.
doPost
(
SMSConfig
.
addTemplate
,
requestMap
);
String
retStr
=
HttpUtil
.
doPost
(
ChuangLan
SMSConfig
.
addTemplate
,
requestMap
);
log
.
info
(
"请求创蓝创建短信模板的返回数据为:{}"
,
retStr
);
log
.
info
(
"请求创蓝创建短信模板的返回数据为:{}"
,
retStr
);
JSONObject
retJson
=
JSONObject
.
parseObject
(
retStr
);
return
new
CLTemplateResponse
();
String
status
=
retJson
.
getString
(
"status"
);
if
(
SUCCESS
.
equals
(
status
))
{
JSONObject
data
=
retJson
.
getJSONObject
(
"data"
);
String
id
=
data
.
getString
(
"id"
);
return
new
CLTemplateResponse
(
ResponseCode
.
SUCCESS
,
id
);
}
else
{
String
msg
=
retJson
.
getString
(
"msg"
);
return
new
CLTemplateResponse
(
ResponseCode
.
UPSTREAM_FAIL
.
getCode
(),
msg
);
}
}
}
@Override
@Override
...
@@ -69,12 +86,12 @@ public class ChuanLanSmsServiceImpl implements ChuanLanSmsService {
...
@@ -69,12 +86,12 @@ public class ChuanLanSmsServiceImpl implements ChuanLanSmsService {
String
account
;
String
account
;
String
password
;
String
password
;
if
(
"notification"
.
equals
(
type
))
{
if
(
"notification"
.
equals
(
type
))
{
account
=
SMSConfig
.
notificationAccount
;
account
=
ChuangLan
SMSConfig
.
notificationAccount
;
password
=
SMSConfig
.
notificationPassword
;
password
=
ChuangLan
SMSConfig
.
notificationPassword
;
log
.
info
(
"发送短信的模式为:{通知类}"
);
log
.
info
(
"发送短信的模式为:{通知类}"
);
}
else
if
(
"marketing"
.
equals
(
type
))
{
}
else
if
(
"marketing"
.
equals
(
type
))
{
account
=
SMSConfig
.
marketingAccount
;
account
=
ChuangLan
SMSConfig
.
marketingAccount
;
password
=
SMSConfig
.
marketingPassword
;
password
=
ChuangLan
SMSConfig
.
marketingPassword
;
log
.
info
(
"发送短信的模式为:{营销类}"
);
log
.
info
(
"发送短信的模式为:{营销类}"
);
}
else
{
}
else
{
log
.
info
(
"发送短信的模式为:{未知类型}"
);
log
.
info
(
"发送短信的模式为:{未知类型}"
);
...
@@ -85,7 +102,7 @@ public class ChuanLanSmsServiceImpl implements ChuanLanSmsService {
...
@@ -85,7 +102,7 @@ public class ChuanLanSmsServiceImpl implements ChuanLanSmsService {
String
requestJson
=
JSONObject
.
toJSONString
(
request
);
String
requestJson
=
JSONObject
.
toJSONString
(
request
);
log
.
info
(
"【{}】发送固定内容短信,请求上游数据为:{}"
,
batchId
,
requestJson
);
log
.
info
(
"【{}】发送固定内容短信,请求上游数据为:{}"
,
batchId
,
requestJson
);
String
responseStr
=
ChuangLanSmsUtil
.
sendSmsByPost
(
SMSConfig
.
sendFixed
,
requestJson
);
String
responseStr
=
ChuangLanSmsUtil
.
sendSmsByPost
(
ChuangLan
SMSConfig
.
sendFixed
,
requestJson
);
log
.
info
(
"【{}】发送固定内容短信,上游返回数据为:{}"
,
batchId
,
requestJson
);
log
.
info
(
"【{}】发送固定内容短信,上游返回数据为:{}"
,
batchId
,
requestJson
);
if
(
StringUtils
.
isBlank
(
responseStr
))
{
if
(
StringUtils
.
isBlank
(
responseStr
))
{
...
@@ -100,23 +117,17 @@ public class ChuanLanSmsServiceImpl implements ChuanLanSmsService {
...
@@ -100,23 +117,17 @@ public class ChuanLanSmsServiceImpl implements ChuanLanSmsService {
return
s
;
return
s
;
}
}
public
static
void
main
(
String
[]
args
)
{
List
<
String
>
arr
=
new
ArrayList
<>();
arr
.
add
(
"aa,444"
);
System
.
out
.
printf
(
arr
.
toString
());
}
@Override
@Override
public
CLSendFixedResponse
sendByVariable
(
String
batchId
,
String
content
,
List
<
String
>
params
,
String
type
)
throws
Exception
{
public
CLSendFixedResponse
sendByVariable
(
String
batchId
,
String
content
,
List
<
String
>
params
,
String
type
)
throws
Exception
{
String
account
;
String
account
;
String
password
;
String
password
;
if
(
"notification"
.
equals
(
type
))
{
if
(
"notification"
.
equals
(
type
))
{
account
=
SMSConfig
.
notificationAccount
;
account
=
ChuangLan
SMSConfig
.
notificationAccount
;
password
=
SMSConfig
.
notificationPassword
;
password
=
ChuangLan
SMSConfig
.
notificationPassword
;
log
.
info
(
"发送短信的模式为:{通知类}"
);
log
.
info
(
"发送短信的模式为:{通知类}"
);
}
else
if
(
"marketing"
.
equals
(
type
))
{
}
else
if
(
"marketing"
.
equals
(
type
))
{
account
=
SMSConfig
.
marketingAccount
;
account
=
ChuangLan
SMSConfig
.
marketingAccount
;
password
=
SMSConfig
.
marketingPassword
;
password
=
ChuangLan
SMSConfig
.
marketingPassword
;
log
.
info
(
"发送短信的模式为:{营销类}"
);
log
.
info
(
"发送短信的模式为:{营销类}"
);
}
else
{
}
else
{
log
.
info
(
"发送短信的模式为:{未知类型}"
);
log
.
info
(
"发送短信的模式为:{未知类型}"
);
...
@@ -127,7 +138,7 @@ public class ChuanLanSmsServiceImpl implements ChuanLanSmsService {
...
@@ -127,7 +138,7 @@ public class ChuanLanSmsServiceImpl implements ChuanLanSmsService {
String
requestJson
=
JSONObject
.
toJSONString
(
request
);
String
requestJson
=
JSONObject
.
toJSONString
(
request
);
log
.
info
(
"【{}】发送固定内容短信,请求上游数据为:{}"
,
batchId
,
requestJson
);
log
.
info
(
"【{}】发送固定内容短信,请求上游数据为:{}"
,
batchId
,
requestJson
);
String
responseStr
=
ChuangLanSmsUtil
.
sendSmsByPost
(
SMSConfig
.
sendFixed
,
requestJson
);
String
responseStr
=
ChuangLanSmsUtil
.
sendSmsByPost
(
ChuangLan
SMSConfig
.
sendFixed
,
requestJson
);
log
.
info
(
"【{}】发送固定内容短信,上游返回数据为:{}"
,
batchId
,
requestJson
);
log
.
info
(
"【{}】发送固定内容短信,上游返回数据为:{}"
,
batchId
,
requestJson
);
if
(
StringUtils
.
isBlank
(
responseStr
))
{
if
(
StringUtils
.
isBlank
(
responseStr
))
{
...
@@ -146,4 +157,22 @@ public class ChuanLanSmsServiceImpl implements ChuanLanSmsService {
...
@@ -146,4 +157,22 @@ public class ChuanLanSmsServiceImpl implements ChuanLanSmsService {
public
DmHubBatchSendResponse
sendBatchByVariable
(
DmHubBatchSendRequest
requestDTO
)
{
public
DmHubBatchSendResponse
sendBatchByVariable
(
DmHubBatchSendRequest
requestDTO
)
{
return
null
;
return
null
;
}
}
@Override
public
void
asyncNotify
(
CLNotifyRequest
notifyInfo
)
{
String
action
=
notifyInfo
.
getAction
();
if
(!
"messageModel"
.
equals
(
action
))
{
return
;
}
String
id
=
notifyInfo
.
getId
();
String
status
=
notifyInfo
.
getAuditStatus
();
if
(!
"1"
.
equals
(
status
))
{
String
msg
=
notifyInfo
.
getAuditReason
();
boolean
update
=
templateService
.
updateForSet
(
"status = abnormal,up_reject_msg = "
+
msg
,
new
EntityWrapper
<
SmsTemplateInfo
>().
eq
(
"up_template_id"
,
id
));
// TODO 发送钉钉告警
log
.
error
(
"短信模板审核不通过,原因:{}"
,
msg
);
}
}
}
}
src/main/java/com/jz/sms/chuanlan/utils/ChuangLanSmsUtil.java
→
src/main/java/com/jz/sms/chuan
g
lan/utils/ChuangLanSmsUtil.java
View file @
b9c0ae9a
package
com
.
jz
.
sms
.
chuanlan
.
utils
;
package
com
.
jz
.
sms
.
chuan
g
lan
.
utils
;
import
java.io.BufferedReader
;
import
java.io.BufferedReader
;
import
java.io.InputStreamReader
;
import
java.io.InputStreamReader
;
...
...
src/main/java/com/jz/sms/chuanlan/dto/CLTemplateResponse.java
deleted
100644 → 0
View file @
e42d6120
package
com
.
jz
.
sms
.
chuanlan
.
dto
;
public
class
CLTemplateResponse
{
}
src/main/java/com/jz/sms/config/ResponseCode.java
0 → 100644
View file @
b9c0ae9a
package
com
.
jz
.
sms
.
config
;
public
enum
ResponseCode
{
SUCCESS
(
"200"
,
"处理成功"
),
UPSTREAM_FAIL
(
"UF01"
,
"渠道交易失败"
),
SYSTEM_ERROR
(
"99"
,
"系统异常:"
);
private
String
code
;
private
String
msg
;
ResponseCode
(
String
code
,
String
msg
)
{
this
.
code
=
code
;
this
.
msg
=
msg
;
}
public
String
getCode
()
{
return
code
;
}
public
String
getMsg
()
{
return
msg
;
}
}
src/main/java/com/jz/sms/repository/domain/SmsTemplateInfo.java
View file @
b9c0ae9a
...
@@ -36,6 +36,9 @@ public class SmsTemplateInfo {
...
@@ -36,6 +36,9 @@ public class SmsTemplateInfo {
private
String
templateName
;
private
String
templateName
;
private
String
upTemplateId
;
private
String
upRejectMsg
;
public
SmsTemplateInfo
()
{
public
SmsTemplateInfo
()
{
}
}
...
@@ -133,4 +136,20 @@ public class SmsTemplateInfo {
...
@@ -133,4 +136,20 @@ public class SmsTemplateInfo {
public
void
setLastUpdated
(
Date
lastUpdated
)
{
public
void
setLastUpdated
(
Date
lastUpdated
)
{
this
.
lastUpdated
=
lastUpdated
;
this
.
lastUpdated
=
lastUpdated
;
}
}
public
String
getUpTemplateId
()
{
return
upTemplateId
;
}
public
void
setUpTemplateId
(
String
upTemplateId
)
{
this
.
upTemplateId
=
upTemplateId
;
}
public
String
getUpRejectMsg
()
{
return
upRejectMsg
;
}
public
void
setUpRejectMsg
(
String
upRejectMsg
)
{
this
.
upRejectMsg
=
upRejectMsg
;
}
}
}
src/main/java/com/jz/sms/service/impl/MessageServiceImpl.java
View file @
b9c0ae9a
...
@@ -2,9 +2,10 @@ package com.jz.sms.service.impl;
...
@@ -2,9 +2,10 @@ package com.jz.sms.service.impl;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.mapper.EntityWrapper
;
import
com.baomidou.mybatisplus.mapper.EntityWrapper
;
import
com.jz.sms.chuanlan.dto.CLSendFixedResponse
;
import
com.jz.sms.chuanglan.dto.CLSendFixedResponse
;
import
com.jz.sms.chuanlan.dto.CLTemplateResponse
;
import
com.jz.sms.chuanglan.dto.CLTemplateResponse
;
import
com.jz.sms.chuanlan.service.ChuanLanSmsService
;
import
com.jz.sms.chuanglan.service.ChuanLanSmsService
;
import
com.jz.sms.config.ResponseCode
;
import
com.jz.sms.dto.*
;
import
com.jz.sms.dto.*
;
import
com.jz.sms.repository.domain.SmsTemplateInfo
;
import
com.jz.sms.repository.domain.SmsTemplateInfo
;
import
com.jz.sms.repository.domain.SysBatchInfo
;
import
com.jz.sms.repository.domain.SysBatchInfo
;
...
@@ -36,6 +37,8 @@ public class MessageServiceImpl implements MessageService {
...
@@ -36,6 +37,8 @@ public class MessageServiceImpl implements MessageService {
@Autowired
@Autowired
private
ChuanLanSmsService
chuanLanSmsService
;
private
ChuanLanSmsService
chuanLanSmsService
;
String
a
=
"亲爱的${name@6!\"\"},您的手机号码:${mobile@12!\"\"}参与了优惠活动,详见: ${surl!'https://www.baidu.com/?cl_sr=短消息'} 回TD退订"
;
/**
/**
* 短信模板创建
* 短信模板创建
*
*
...
@@ -56,7 +59,7 @@ public class MessageServiceImpl implements MessageService {
...
@@ -56,7 +59,7 @@ public class MessageServiceImpl implements MessageService {
String
templateName
=
requestDTO
.
getTemplateName
();
String
templateName
=
requestDTO
.
getTemplateName
();
// 替换模板格式,保存适合创蓝发送短信的模板,避免发送时修改模板格式
// 替换模板格式,保存适合创蓝发送短信的模板,避免发送时修改模板格式
String
upContent
=
dmHub2ChuanLan
(
templateContent
);
String
chuanlanSend
=
dmHub2ChuanLanSend
(
templateContent
);
SmsTemplateInfo
info
=
new
SmsTemplateInfo
();
SmsTemplateInfo
info
=
new
SmsTemplateInfo
();
info
.
setContent
(
templateContent
);
info
.
setContent
(
templateContent
);
...
@@ -68,13 +71,26 @@ public class MessageServiceImpl implements MessageService {
...
@@ -68,13 +71,26 @@ public class MessageServiceImpl implements MessageService {
info
.
setTemplateName
(
templateName
);
info
.
setTemplateName
(
templateName
);
info
.
setDateCreated
(
new
Date
());
info
.
setDateCreated
(
new
Date
());
info
.
setLastUpdated
(
new
Date
());
info
.
setLastUpdated
(
new
Date
());
info
.
setUpContent
(
upContent
);
info
.
setUpContent
(
chuanlanSend
);
boolean
insert
=
smsTemplateService
.
insert
(
info
);
boolean
insert
=
smsTemplateService
.
insert
(
info
);
if
(!
insert
)
{
if
(!
insert
)
{
return
new
DmHubTemplateResponse
(
"500"
,
"系统异常"
);
//TODO 发送告警
//TODO 发送告警
}
}
CLTemplateResponse
template
=
chuanLanSmsService
.
createTemplate
(
templateContent
,
smsType
);
String
chaunglanCreate
=
dmHub2ChuanLanCreate
(
chuanlanSend
);
CLTemplateResponse
template
=
chuanLanSmsService
.
createTemplate
(
chaunglanCreate
,
smsType
);
if
(
ResponseCode
.
SUCCESS
.
getCode
().
equals
(
template
.
getCode
()))
{
String
id
=
template
.
getId
();
SmsTemplateInfo
updateInfo
=
new
SmsTemplateInfo
();
updateInfo
.
setId
(
info
.
getId
());
updateInfo
.
setUpTemplateId
(
id
);
smsTemplateService
.
updateById
(
updateInfo
);
return
responseDTO
;
}
else
{
//TODO 发送告警,模板添加失败。
return
new
DmHubTemplateResponse
(
template
.
getCode
(),
template
.
getMsg
());
}
}
catch
(
Exception
exception
)
{
}
catch
(
Exception
exception
)
{
log
.
error
(
"错误信息"
,
exception
);
log
.
error
(
"错误信息"
,
exception
);
responseDTO
=
new
DmHubTemplateResponse
(
"500"
,
"系统异常"
);
responseDTO
=
new
DmHubTemplateResponse
(
"500"
,
"系统异常"
);
...
@@ -84,13 +100,7 @@ public class MessageServiceImpl implements MessageService {
...
@@ -84,13 +100,7 @@ public class MessageServiceImpl implements MessageService {
}
}
public
String
dmHub2ChuanLan
(
String
content
)
{
public
String
dmHub2ChuanLanSend
(
String
content
)
{
// String content = "亲爱的${name@0!\"\"},您好!点击以下链接可以获取10元优惠券哦! ${surl!'https://www.baidu.com/?abcdesf=${name}&cl_sr=短消息'}";
// String content = "亲爱的${name@6!\"\"},您的手机号码:${mobile@12!\"\"}参与了优惠活动,详见: ${surl!'https://www.baidu.com/?cl_sr=短消息'} 回TD退订";
// String content = "感谢你的关注";
// String content = "亲爱的${name@0!\"\"},您好!点击以下链接可以获取10元优惠券哦! ${surl!'https://www.baidu.com/?abcdesf=${name}&cl_sr=短消息'}";
//
boolean
flag
=
false
;
boolean
flag
=
false
;
if
(
content
.
contains
(
"${surl!"
))
{
if
(
content
.
contains
(
"${surl!"
))
{
...
@@ -134,6 +144,12 @@ public class MessageServiceImpl implements MessageService {
...
@@ -134,6 +144,12 @@ public class MessageServiceImpl implements MessageService {
}
}
public
String
dmHub2ChuanLanCreate
(
String
content
)
{
content
=
content
.
replaceAll
(
"\\{\\$var\\}"
,
"\\{s20\\}"
);
return
content
;
}
public
String
escapeRegex
(
String
s
)
{
public
String
escapeRegex
(
String
s
)
{
String
[]
symbols
=
new
String
[]{
"\\/"
,
"\\["
,
"\\]"
,
"\\("
,
"\\)"
,
"\\{"
,
"\\}"
,
"\\?"
,
"\\+"
,
"\\*"
,
"\\|"
,
"\\."
,
"\\^"
,
"\\-"
,
"\\^"
};
String
[]
symbols
=
new
String
[]{
"\\/"
,
"\\["
,
"\\]"
,
"\\("
,
"\\)"
,
"\\{"
,
"\\}"
,
"\\?"
,
"\\+"
,
"\\*"
,
"\\|"
,
"\\."
,
"\\^"
,
"\\-"
,
"\\^"
};
if
(
s
!=
null
)
{
if
(
s
!=
null
)
{
...
...
src/main/resources/application-prod.yml
View file @
b9c0ae9a
...
@@ -26,4 +26,6 @@ system:
...
@@ -26,4 +26,6 @@ system:
sendVariable
:
http://smssh1.253.com/msg/variable/json
# 变量短信下发接口
sendVariable
:
http://smssh1.253.com/msg/variable/json
# 变量短信下发接口
reportUrl
:
http://test.9z.com/msg/report
# 短信报告
reportUrl
:
http://test.9z.com/msg/report
# 短信报告
pullReport
:
http://smssh1.253.com/msg/pull/report
# 拉取短信报告
pullReport
:
http://smssh1.253.com/msg/pull/report
# 拉取短信报告
addTemplate
:
https://zz.253.com/apis/template/add
# 创建短信模板
addTemplate
:
https://zz.253.com/apis/template/add
# 创建短信模板
\ No newline at end of file
interfaceUser
:
admin001
# 接口用户名
interfacePassword
:
9zdata0423
# 接口密码
\ No newline at end of file
src/main/resources/application-test.yml
View file @
b9c0ae9a
...
@@ -28,4 +28,6 @@ system:
...
@@ -28,4 +28,6 @@ system:
reportUrl
:
http://test.9z.com/msg/report
# 短信报告
reportUrl
:
http://test.9z.com/msg/report
# 短信报告
pullReport
:
http://smssh1.253.com/msg/pull/report
# 拉取短信报告
pullReport
:
http://smssh1.253.com/msg/pull/report
# 拉取短信报告
addTemplate
:
https://zz.253.com/apis/template/add
# 创建短信模板
addTemplate
:
https://zz.253.com/apis/template/add
# 创建短信模板
interfaceUser
:
admin001
# 接口用户名
interfacePassword
:
9zdata0423
# 接口密码
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