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
2bb62bff
Commit
2bb62bff
authored
Nov 21, 2017
by
技术部-任文超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加H5专用短信验证码获取接口
parent
cd093954
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
16 deletions
+14
-16
SmsController.java
...uantgroup/xyqb/controller/internal/sms/SmsController.java
+14
-16
No files found.
src/main/java/cn/quantgroup/xyqb/controller/internal/sms/SmsController.java
View file @
2bb62bff
...
...
@@ -195,7 +195,7 @@ public class SmsController implements IBaseController {
*/
@CaptchaNewValidator
@RequestMapping
(
"/send_login_code_voice_new"
)
public
JsonResult
sendLogin
SmsCod
eNew
(
@RequestParam
String
phoneNo
,
@RequestParam
(
required
=
false
)
String
registerFrom
,
public
JsonResult
sendLogin
CodeVoic
eNew
(
@RequestParam
String
phoneNo
,
@RequestParam
(
required
=
false
)
String
registerFrom
,
String
usage
,
@RequestParam
(
required
=
false
)
String
deviceId
)
{
if
(
StringUtils
.
isEmpty
(
usage
)
||
!
"6"
.
equals
(
usage
))
{
LOGGER
.
error
(
"参数校验失败,用户登录语音验证码usage参数为{}"
,
usage
);
...
...
@@ -211,15 +211,24 @@ public class SmsController implements IBaseController {
*/
@CaptchaNewValidator
@RequestMapping
(
"/send_login_code_new"
)
public
JsonResult
sendLogin
CodeVoic
eNew
(
@RequestParam
String
phoneNo
,
@RequestParam
(
required
=
false
)
String
registerFrom
,
@RequestParam
(
required
=
false
)
String
deviceId
)
{
public
JsonResult
sendLogin
SmsCod
eNew
(
@RequestParam
String
phoneNo
,
@RequestParam
(
required
=
false
)
String
registerFrom
,
@RequestParam
(
required
=
false
)
String
deviceId
)
{
LOGGER
.
info
(
"快速登陆-发送验证码, phoneNo:{}, registerFrom:{}"
,
phoneNo
,
registerFrom
);
return
sendVerificationCode2New
(
phoneNo
,
deviceId
);
return
sendVerificationCode2New
(
phoneNo
,
deviceId
,
true
);
}
/**
* 快速登陆发送短信验证码
*/
@CaptchaNewValidator
@RequestMapping
(
"/send_login_code_new_forH5"
)
public
JsonResult
sendLoginSmsCodeNewForH5
(
@RequestParam
String
phoneNo
,
@RequestParam
(
required
=
false
)
String
registerFrom
,
@RequestParam
(
required
=
false
)
String
deviceId
)
{
LOGGER
.
info
(
"快速登陆-发送验证码, phoneNo:{}, registerFrom:{}"
,
phoneNo
,
registerFrom
);
return
sendVerificationCode2New
(
phoneNo
,
deviceId
,
false
);
}
/**
* 新版本验证码
*/
private
JsonResult
sendVerificationCode2New
(
String
phoneNo
,
String
deviceId
)
{
private
JsonResult
sendVerificationCode2New
(
String
phoneNo
,
String
deviceId
,
boolean
isApp
)
{
if
(!
ValidationUtil
.
validatePhoneNo
(
phoneNo
))
{
return
JsonResult
.
buildErrorStateResult
(
"手机号格式有误"
,
null
);
}
...
...
@@ -232,13 +241,6 @@ public class SmsController implements IBaseController {
return
JsonResult
.
buildErrorStateResult
(
"今天已获取20次短信验证码,请使用语音验证码或明天再试"
,
null
);
}
String
verificationIPCountKey
=
getIp
();
//if (!StringUtils.isEmpty(verificationIPCountKey)) {
// verificationIPCountKey=Constants.REDIS_SMS_IP_COUNT+verificationIPCountKey;
// Long getIPVerificationCount = redisTemplate.opsForHash().increment(verificationIPCountKey, Constants.REDIS_SMS_IP_COUNT, 1);
// //if (getIPVerificationCount > IP_MAX_PER_DAY) {
// // return JsonResult.buildErrorStateResult("您当前ip已经达到获取今天验证码上限", null);
// //}
//}
LOGGER
.
info
(
"请求短信新版本接口:phoneNo:{},deviceId:{},IP:{}"
,
phoneNo
,
deviceId
,
getIp
());
if
(!
StringUtils
.
isEmpty
(
deviceId
))
{
String
verificationDeviceCountKey
=
Constants
.
REDIS_SMS_DEVICE_COUNT
+
deviceId
;
...
...
@@ -260,16 +262,12 @@ public class SmsController implements IBaseController {
String
uniqueId
=
phoneNo
+
UUID
.
randomUUID
().
toString
().
replaceAll
(
"-"
,
""
);
List
<
String
>
newList
=
new
ArrayList
<>();
newList
.
add
(
randomCode
);
/*ConfirmableMsg confirmableMsg = new ConfirmableMsg(
uniqueId, newList, "1", "1", phoneNo
);*/
MsgParams
message
=
new
MsgParams
(
Collections
.
singletonList
(
2
),
phoneNo
,
"1"
,
"1"
,
Collections
.
singletonList
(
randomCode
),
uniqueId
);
try
{
//smsService.getSmsSender().sendConfirmableMessage(confirmableMsg);
smsService
.
getSmsSender
().
sendMsg
(
message
);
redisTemplate
.
opsForValue
().
set
(
key
,
uniqueId
+
":"
+
randomCode
,
EXPIRE_MINUTES
,
TimeUnit
.
MINUTES
);
deleteRetSendCode
(
phoneNo
);
//删除用户重置密码,多次错误逻辑
if
(
needImageVlidate
(
verificationIPCountKey
,
deviceId
,
phoneNo
)){
if
(
isApp
&&
needImageVlidate
(
verificationIPCountKey
,
deviceId
,
phoneNo
)){
return
JsonResult
.
buildSuccessResult
(
"发送成功"
,
uniqueId
,
0003
L
);
}
LOGGER
.
info
(
"sendVerificationCode2New获取短信成功:phone:{},deviceId:{},ip:{}"
,
phoneNo
,
deviceId
,
getIp
());
...
...
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