Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xyqb-user2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
head_group
xyqb-user2
Commits
72aab5e3
Commit
72aab5e3
authored
Apr 23, 2018
by
技术部-任文超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
支持短信验证码模板适配
parent
5c9a378c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
161 additions
and
17 deletions
+161
-17
SmsController.java
...uantgroup/xyqb/controller/internal/sms/SmsController.java
+84
-17
SmsMerchant.java
src/main/java/cn/quantgroup/xyqb/model/sms/SmsMerchant.java
+77
-0
No files found.
src/main/java/cn/quantgroup/xyqb/controller/internal/sms/SmsController.java
View file @
72aab5e3
...
...
@@ -5,6 +5,7 @@ import cn.quantgroup.xyqb.Constants;
import
cn.quantgroup.xyqb.aspect.captcha.CaptchaNewValidator
;
import
cn.quantgroup.xyqb.controller.IBaseController
;
import
cn.quantgroup.xyqb.model.JsonResult
;
import
cn.quantgroup.xyqb.model.sms.SmsMerchant
;
import
cn.quantgroup.xyqb.service.sms.ISmsService
;
import
cn.quantgroup.xyqb.util.DateUtils
;
import
cn.quantgroup.xyqb.util.IPUtil
;
...
...
@@ -51,19 +52,38 @@ public class SmsController implements IBaseController {
/**
* 短信验证码: for H5
* 使用 @FPLock 注解并加入自定义限制参数, 做针对手机号的发送次数限制
*
* @param phoneNo - 手机号
* @param registerFrom -
* @param appName -
* @param smsMerchant - 短信模板/类型
*/
@CaptchaNewValidator
@RequestMapping
(
"/send_sms_verification_code"
)
public
JsonResult
verifyPhoneNoH5
(
@RequestParam
String
phoneNo
,
@RequestParam
(
required
=
false
)
String
registerFrom
,
@RequestParam
(
required
=
false
,
defaultValue
=
""
)
String
appName
)
{
public
JsonResult
verifyPhoneNoH5
(
@RequestParam
String
phoneNo
,
@RequestParam
(
required
=
false
)
String
registerFrom
,
@RequestParam
(
required
=
false
,
defaultValue
=
""
)
String
appName
,
@RequestParam
(
required
=
false
)
String
smsMerchant
)
{
LOGGER
.
info
(
"注册-发送验证码, phoneNo:{}, registerFrom:{}"
,
phoneNo
,
registerFrom
);
return
sendVerificationCode2
(
phoneNo
,
appName
);
return
sendVerificationCode2
(
phoneNo
,
appName
,
smsMerchant
);
}
/**
* 短信验证码 : 重置密码
* @param phoneNo - 手机号
* @param registerFrom -
* @param appName -
* @param smsMerchant - 短信模板/类型
* @return
*/
@CaptchaNewValidator
@RequestMapping
(
"/send_reset_code"
)
public
JsonResult
resetPasswordH5
(
@RequestParam
String
phoneNo
,
@RequestParam
(
required
=
false
)
String
registerFrom
,
@RequestParam
(
required
=
false
,
defaultValue
=
""
)
String
appName
)
{
public
JsonResult
resetPasswordH5
(
@RequestParam
String
phoneNo
,
@RequestParam
(
required
=
false
)
String
registerFrom
,
@RequestParam
(
required
=
false
,
defaultValue
=
""
)
String
appName
,
@RequestParam
(
required
=
false
)
String
smsMerchant
)
{
LOGGER
.
info
(
"重置密码-发送验证码, phoneNo:{}, registerFrom:{}"
,
phoneNo
,
registerFrom
);
return
sendVerificationCode2
(
phoneNo
,
appName
);
return
sendVerificationCode2
(
phoneNo
,
appName
,
smsMerchant
);
}
/**
...
...
@@ -111,25 +131,47 @@ public class SmsController implements IBaseController {
/**
* 快速登陆发送验证码
*
* @param phoneNo - 手机号
* @param appName -
* @param smsMerchant - 短信模板/类型
*/
@CaptchaNewValidator
@RequestMapping
(
"/send_login_code"
)
public
JsonResult
sendLoginCode
(
@RequestParam
String
phoneNo
,
@RequestParam
(
required
=
false
)
String
registerFrom
,
@RequestParam
(
required
=
false
,
defaultValue
=
""
)
String
appName
)
{
public
JsonResult
sendLoginCode
(
@RequestParam
String
phoneNo
,
@RequestParam
(
required
=
false
)
String
registerFrom
,
@RequestParam
(
required
=
false
,
defaultValue
=
""
)
String
appName
,
@RequestParam
(
required
=
false
)
String
smsMerchant
)
{
LOGGER
.
info
(
"快速登陆-发送验证码, phoneNo:{}, registerFrom:{}"
,
phoneNo
,
registerFrom
);
return
sendVerificationCode2
(
phoneNo
,
appName
);
return
sendVerificationCode2
(
phoneNo
,
appName
,
smsMerchant
);
}
/**
* 快速注册发送验证码
*
* @param phoneNo - 手机号
* @param appName -
* @param smsMerchant - 短信模板/类型
*/
@CaptchaNewValidator
@RequestMapping
(
"/send_regist_code"
)
public
JsonResult
sendRegistCode
(
@RequestParam
String
phoneNo
,
@RequestParam
(
required
=
false
)
String
registerFrom
,
@RequestParam
(
required
=
false
,
defaultValue
=
""
)
String
appName
)
{
public
JsonResult
sendRegistCode
(
@RequestParam
String
phoneNo
,
@RequestParam
(
required
=
false
)
String
registerFrom
,
@RequestParam
(
required
=
false
,
defaultValue
=
""
)
String
appName
,
@RequestParam
(
required
=
false
)
String
smsMerchant
)
{
LOGGER
.
info
(
"快速注册-发送验证码, phoneNo:{}, registerFrom:{}"
,
phoneNo
,
registerFrom
);
return
sendVerificationCode2
(
phoneNo
,
appName
);
return
sendVerificationCode2
(
phoneNo
,
appName
,
smsMerchant
);
}
private
JsonResult
sendVerificationCode2
(
String
phoneNo
,
String
appName
)
{
/**
* 短信验证码
*
* @param phoneNo - 手机号
* @param appName -
* @param smsMerchant - 短信模板/类型
* @return
*/
private
JsonResult
sendVerificationCode2
(
String
phoneNo
,
String
appName
,
String
smsMerchant
)
{
if
(!
ValidationUtil
.
validatePhoneNo
(
phoneNo
))
{
return
JsonResult
.
buildErrorStateResult
(
"手机号格式有误"
,
null
);
}
...
...
@@ -149,7 +191,7 @@ public class SmsController implements IBaseController {
MsgParams
message
=
new
MsgParams
.
Builder
()
.
typeList
(
Collections
.
singletonList
(
2
))
.
phoneNo
(
phoneNo
)
.
merchantId
(
"1"
)
.
merchantId
(
SmsMerchant
.
of
(
smsMerchant
).
getMerchantId
()
)
.
contentId
(
"1"
)
.
uniqueId
(
uniqueId
)
.
contentArgs
(
Collections
.
singletonList
(
randomCode
))
...
...
@@ -215,27 +257,52 @@ public class SmsController implements IBaseController {
/**
* 快速登陆发送短信验证码
* @param phoneNo - 手机号
* @param registerFrom -
* @param deviceId -
* @param appName -
* @param smsMerchant - 短信模板/类型
*/
@CaptchaNewValidator
@RequestMapping
(
"/send_login_code_new"
)
public
JsonResult
sendLoginSmsCodeNew
(
@RequestParam
String
phoneNo
,
@RequestParam
(
required
=
false
)
String
registerFrom
,
@RequestParam
(
required
=
false
)
String
deviceId
,
@RequestParam
(
required
=
false
,
defaultValue
=
""
)
String
appName
)
{
public
JsonResult
sendLoginSmsCodeNew
(
@RequestParam
String
phoneNo
,
@RequestParam
(
required
=
false
)
String
registerFrom
,
@RequestParam
(
required
=
false
)
String
deviceId
,
@RequestParam
(
required
=
false
,
defaultValue
=
""
)
String
appName
,
@RequestParam
(
required
=
false
)
String
smsMerchant
)
{
LOGGER
.
info
(
"快速登陆-发送验证码, phoneNo:{}, registerFrom:{}"
,
phoneNo
,
registerFrom
);
return
sendVerificationCode2New
(
phoneNo
,
deviceId
,
true
,
appName
);
return
sendVerificationCode2New
(
phoneNo
,
deviceId
,
true
,
appName
,
smsMerchant
);
}
/**
* 快速登陆发送短信验证码
* @param phoneNo - 手机号
* @param registerFrom -
* @param deviceId -
* @param appName -
* @param smsMerchant - 短信模板/类型
*/
@CaptchaNewValidator
@RequestMapping
(
"/send_login_code_new_forH5"
)
public
JsonResult
sendLoginSmsCodeNewForH5
(
@RequestParam
String
phoneNo
,
@RequestParam
(
required
=
false
)
String
registerFrom
,
@RequestParam
(
required
=
false
)
String
deviceId
,
@RequestParam
(
required
=
false
,
defaultValue
=
""
)
String
appName
)
{
public
JsonResult
sendLoginSmsCodeNewForH5
(
@RequestParam
String
phoneNo
,
@RequestParam
(
required
=
false
)
String
registerFrom
,
@RequestParam
(
required
=
false
)
String
deviceId
,
@RequestParam
(
required
=
false
,
defaultValue
=
""
)
String
appName
,
@RequestParam
(
required
=
false
)
String
smsMerchant
)
{
LOGGER
.
info
(
"快速登陆-发送验证码, phoneNo:{}, registerFrom:{}"
,
phoneNo
,
registerFrom
);
return
sendVerificationCode2New
(
phoneNo
,
deviceId
,
false
,
appName
);
return
sendVerificationCode2New
(
phoneNo
,
deviceId
,
false
,
appName
,
smsMerchant
);
}
/**
* 新版本验证码
* 新版本短信验证码
*
* @param phoneNo - 手机号
* @param deviceId - 设备id
* @param isApp -
* @param appName -
* @param smsMerchant - 短信模板/类型
* @return
*/
private
JsonResult
sendVerificationCode2New
(
String
phoneNo
,
String
deviceId
,
boolean
isApp
,
String
appName
)
{
private
JsonResult
sendVerificationCode2New
(
String
phoneNo
,
String
deviceId
,
boolean
isApp
,
String
appName
,
String
smsMerchant
)
{
if
(!
ValidationUtil
.
validatePhoneNo
(
phoneNo
))
{
return
JsonResult
.
buildErrorStateResult
(
"手机号格式有误"
,
null
);
}
...
...
@@ -285,7 +352,7 @@ public class SmsController implements IBaseController {
MsgParams
message
=
new
MsgParams
.
Builder
()
.
typeList
(
Collections
.
singletonList
(
2
))
.
phoneNo
(
phoneNo
)
.
merchantId
(
"1"
)
.
merchantId
(
SmsMerchant
.
of
(
smsMerchant
).
getMerchantId
()
)
.
contentId
(
"1"
)
.
uniqueId
(
uniqueId
)
.
contentArgs
(
Collections
.
singletonList
(
randomCode
))
...
...
src/main/java/cn/quantgroup/xyqb/model/sms/SmsMerchant.java
0 → 100644
View file @
72aab5e3
package
cn
.
quantgroup
.
xyqb
.
model
.
sms
;
import
lombok.extern.slf4j.Slf4j
;
import
java.util.Optional
;
/**
* 短信模板适配枚举类
* @author renwc
* @date 2018-04-23
*/
@Slf4j
public
enum
SmsMerchant
{
DEFAULT
(
1
,
"默认:函谷关"
),
HAN_GU_GUAN
(
1
,
"函谷关"
),
PAY_CENTER
(
2
,
"支付中心"
),
XIN_YONG_QIAN_BAO
(
3
,
"信用钱包"
),
DI_TING
(
4
,
"谛听"
),
BAI_TIAO_OFFLINE
(
5
,
"线下白条"
),
DB_FLOW_ALLIANCE
(
6
,
"【数据部】流量联盟"
),
BAI_TIAO_MALL
(
7
,
"白条商城"
),
BAI_TIAO
(
8
,
"白条"
),
OPS_ALARM
(
9
,
"运维告警"
),
OPERATION_PLATFORM
(
10
,
"运营平台"
),
SUB_MENU
(
11
,
"分单"
),
RED_PACKET
(
12
,
"红包系统"
),
DATA_VISUAL
(
13
,
"数据可视化平台+运营"
),
CAPITAL_OPERATING
(
14
,
"资金运营系统"
),
COLLECTION
(
15
,
"催收"
),
BAI_TIAO_COMMON
(
16
,
"通用白条"
),
CIRCULATION_QUOTA
(
17
,
"外部循环额度"
),
FLYING_COW_TO_BORROW
(
18
,
"飞牛贷"
);
private
int
merchantId
;
private
String
desc
;
SmsMerchant
(
int
merchantId
,
String
desc
)
{
this
.
merchantId
=
merchantId
;
this
.
desc
=
desc
;
}
/**
* 获取短信模板id
* @return
*/
public
String
getMerchantId
()
{
return
String
.
valueOf
(
this
.
merchantId
);
}
/**
* 根据name实例化枚举值
* 无匹配项时返回默认枚举值
* @param name
* @return
*/
public
static
SmsMerchant
of
(
String
name
){
name
=
Optional
.
ofNullable
(
name
).
orElse
(
""
);
SmsMerchant
merchant
=
null
;
try
{
merchant
=
SmsMerchant
.
valueOf
(
name
.
toUpperCase
());
}
catch
(
Exception
e
){
log
.
warn
(
"短信模板适配类型:[非法值]:{}"
,
name
,
e
);
merchant
=
DEFAULT
;
}
return
merchant
;
}
/*
public static void main(String[] args){
String name = "FLYING_cow_TO_BORROW";
name = null;
name = Optional.ofNullable(name).orElse("");
System.out.println(SmsMerchant.of(name.toUpperCase()));
System.out.println(SmsMerchant.valueOf(name.toUpperCase()));
}
*/
}
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