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
fbf6fe41
Commit
fbf6fe41
authored
Sep 06, 2017
by
Java—红包—徐 然
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改每天次数
parent
9cde4e28
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
6 deletions
+9
-6
SmsController.java
...uantgroup/xyqb/controller/internal/sms/SmsController.java
+9
-6
No files found.
src/main/java/cn/quantgroup/xyqb/controller/internal/sms/SmsController.java
View file @
fbf6fe41
...
...
@@ -45,6 +45,9 @@ public class SmsController implements IBaseController {
private
static
final
String
IMAGE_PHONE_COUNT
=
"image:phone"
;
private
static
final
String
IMAGE_DEVICEID_COUNT
=
"image:deviceId:"
;
private
static
final
Long
IP_MAX_PER_DAY
=
30L
;
private
static
final
Long
PHONE_MAX_PER_DAY
=
20L
;
private
static
final
Long
DEVICE_MAX_PER_DAY
=
20L
;
/**
* 短信验证码: for H5
* 使用 @FPLock 注解并加入自定义限制参数, 做针对手机号的发送次数限制
...
...
@@ -220,14 +223,14 @@ public class SmsController implements IBaseController {
}
String
verificationPhoneCountKey
=
Constants
.
REDIS_SMS_CODE_COUNT
+
phoneNo
;
Long
getPhoneVerificationCount
=
redisTemplate
.
opsForHash
().
increment
(
verificationPhoneCountKey
,
Constants
.
REDIS_SMS_CODE_COUNT
,
1
);
if
(
getPhoneVerificationCount
>
20
)
{
if
(
getPhoneVerificationCount
>
PHONE_MAX_PER_DAY
)
{
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
>
5000
)
{
if
(
getIPVerificationCount
>
IP_MAX_PER_DAY
)
{
return
JsonResult
.
buildErrorStateResult
(
"您当前ip已经达到获取今天验证码上限"
,
null
);
}
}
...
...
@@ -235,7 +238,7 @@ public class SmsController implements IBaseController {
if
(!
StringUtils
.
isEmpty
(
deviceId
))
{
String
verificationDeviceCountKey
=
Constants
.
REDIS_SMS_DEVICE_COUNT
+
deviceId
;
Long
getDeviceVerificationCount
=
redisTemplate
.
opsForHash
().
increment
(
verificationDeviceCountKey
,
Constants
.
REDIS_SMS_DEVICE_COUNT
,
1
);
if
(
getDeviceVerificationCount
>
20
)
{
if
(
getDeviceVerificationCount
>
DEVICE_MAX_PER_DAY
)
{
return
JsonResult
.
buildErrorStateResult
(
"您设备已经达到获取今天短信验证码上限"
,
null
);
}
}
...
...
@@ -275,14 +278,14 @@ public class SmsController implements IBaseController {
String
verificationCountKey
=
Constants
.
REDIS_VOICE_CODE_COUNT
+
phoneNo
;
Long
getVerificationCount
=
redisTemplate
.
opsForHash
().
increment
(
verificationCountKey
,
usage
.
toString
(),
1
);
if
(
getVerificationCount
>
5
)
{
if
(
getVerificationCount
>
PHONE_MAX_PER_DAY
)
{
return
JsonResult
.
buildErrorStateResult
(
"今天已获取5次语音验证码,请使用短信验证码或明天再试"
,
null
);
}
String
verificationIPCountKey
=
getIp
();
if
(!
StringUtils
.
isEmpty
(
verificationIPCountKey
))
{
verificationIPCountKey
=
Constants
.
REDIS_VOICE_IP_COUNT
+
verificationIPCountKey
;
Long
getIPVerificationCount
=
redisTemplate
.
opsForHash
().
increment
(
verificationIPCountKey
,
Constants
.
REDIS_VOICE_IP_COUNT
,
1
);
if
(
getIPVerificationCount
>
5000
)
{
if
(
getIPVerificationCount
>
IP_MAX_PER_DAY
)
{
return
JsonResult
.
buildErrorStateResult
(
"您当前ip已经达到获取今天语音验证码上限"
,
null
);
}
}
...
...
@@ -290,7 +293,7 @@ public class SmsController implements IBaseController {
if
(!
StringUtils
.
isEmpty
(
deviceId
))
{
String
verificationDeviceCountKey
=
Constants
.
REDIS_SMS_DEVICE_COUNT
+
deviceId
;
Long
getDeviceVerificationCount
=
redisTemplate
.
opsForHash
().
increment
(
verificationDeviceCountKey
,
Constants
.
REDIS_VOICE_DEVICE_COUNT
,
1
);
if
(
getDeviceVerificationCount
>
20
)
{
if
(
getDeviceVerificationCount
>
DEVICE_MAX_PER_DAY
)
{
return
JsonResult
.
buildErrorStateResult
(
"您设备已经达到获取今天语音验证码上限"
,
null
);
}
}
...
...
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