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
2fa19a3e
Commit
2fa19a3e
authored
Nov 07, 2017
by
Java—红包—徐 然
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加过期时间
parent
70cfcbef
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
1 deletion
+7
-1
Constants.java
src/main/java/cn/quantgroup/xyqb/Constants.java
+1
-0
SmsController.java
...uantgroup/xyqb/controller/internal/sms/SmsController.java
+6
-1
No files found.
src/main/java/cn/quantgroup/xyqb/Constants.java
View file @
2fa19a3e
...
@@ -41,6 +41,7 @@ public interface Constants {
...
@@ -41,6 +41,7 @@ public interface Constants {
* redis中token的key值前缀
* redis中token的key值前缀
*/
*/
String
SESSION_PREFIX
=
"spring:session:sessions:"
;
String
SESSION_PREFIX
=
"spring:session:sessions:"
;
Long
ONE_DAY
=
24
*
60
*
60L
;
interface
Channel
{
interface
Channel
{
long
LKB
=
1
;
// 量化派
long
LKB
=
1
;
// 量化派
...
...
src/main/java/cn/quantgroup/xyqb/controller/internal/sms/SmsController.java
View file @
2fa19a3e
...
@@ -224,6 +224,8 @@ public class SmsController implements IBaseController {
...
@@ -224,6 +224,8 @@ public class SmsController implements IBaseController {
}
}
String
verificationPhoneCountKey
=
Constants
.
REDIS_SMS_CODE_COUNT
+
phoneNo
;
String
verificationPhoneCountKey
=
Constants
.
REDIS_SMS_CODE_COUNT
+
phoneNo
;
Long
getPhoneVerificationCount
=
redisTemplate
.
opsForHash
().
increment
(
verificationPhoneCountKey
,
Constants
.
REDIS_SMS_CODE_COUNT
,
1
);
Long
getPhoneVerificationCount
=
redisTemplate
.
opsForHash
().
increment
(
verificationPhoneCountKey
,
Constants
.
REDIS_SMS_CODE_COUNT
,
1
);
redisTemplate
.
expire
(
verificationPhoneCountKey
,
Constants
.
ONE_DAY
,
TimeUnit
.
SECONDS
);
if
(
getPhoneVerificationCount
>
PHONE_MAX_PER_DAY
)
{
if
(
getPhoneVerificationCount
>
PHONE_MAX_PER_DAY
)
{
return
JsonResult
.
buildErrorStateResult
(
"今天已获取20次短信验证码,请使用语音验证码或明天再试"
,
null
);
return
JsonResult
.
buildErrorStateResult
(
"今天已获取20次短信验证码,请使用语音验证码或明天再试"
,
null
);
}
}
...
@@ -239,6 +241,7 @@ public class SmsController implements IBaseController {
...
@@ -239,6 +241,7 @@ public class SmsController implements IBaseController {
if
(!
StringUtils
.
isEmpty
(
deviceId
))
{
if
(!
StringUtils
.
isEmpty
(
deviceId
))
{
String
verificationDeviceCountKey
=
Constants
.
REDIS_SMS_DEVICE_COUNT
+
deviceId
;
String
verificationDeviceCountKey
=
Constants
.
REDIS_SMS_DEVICE_COUNT
+
deviceId
;
Long
getDeviceVerificationCount
=
redisTemplate
.
opsForHash
().
increment
(
verificationDeviceCountKey
,
Constants
.
REDIS_SMS_DEVICE_COUNT
,
1
);
Long
getDeviceVerificationCount
=
redisTemplate
.
opsForHash
().
increment
(
verificationDeviceCountKey
,
Constants
.
REDIS_SMS_DEVICE_COUNT
,
1
);
redisTemplate
.
expire
(
verificationDeviceCountKey
,
Constants
.
ONE_DAY
,
TimeUnit
.
SECONDS
);
if
(
getDeviceVerificationCount
>
DEVICE_MAX_PER_DAY
)
{
if
(
getDeviceVerificationCount
>
DEVICE_MAX_PER_DAY
)
{
return
JsonResult
.
buildErrorStateResult
(
"您设备已经达到获取今天短信验证码上限"
,
null
);
return
JsonResult
.
buildErrorStateResult
(
"您设备已经达到获取今天短信验证码上限"
,
null
);
}
}
...
@@ -279,6 +282,7 @@ public class SmsController implements IBaseController {
...
@@ -279,6 +282,7 @@ public class SmsController implements IBaseController {
String
verificationCountKey
=
Constants
.
REDIS_VOICE_CODE_COUNT
+
phoneNo
;
String
verificationCountKey
=
Constants
.
REDIS_VOICE_CODE_COUNT
+
phoneNo
;
Long
getVerificationCount
=
redisTemplate
.
opsForHash
().
increment
(
verificationCountKey
,
usage
.
toString
(),
1
);
Long
getVerificationCount
=
redisTemplate
.
opsForHash
().
increment
(
verificationCountKey
,
usage
.
toString
(),
1
);
redisTemplate
.
expire
(
verificationCountKey
,
DateUtils
.
getSeconds
(),
TimeUnit
.
SECONDS
);
if
(
getVerificationCount
>
PHONE_VOICE_MAX_PER_DAY
)
{
if
(
getVerificationCount
>
PHONE_VOICE_MAX_PER_DAY
)
{
return
JsonResult
.
buildErrorStateResult
(
"今天已获取5次语音验证码,请使用短信验证码或明天再试"
,
null
);
return
JsonResult
.
buildErrorStateResult
(
"今天已获取5次语音验证码,请使用短信验证码或明天再试"
,
null
);
}
}
...
@@ -294,12 +298,13 @@ public class SmsController implements IBaseController {
...
@@ -294,12 +298,13 @@ public class SmsController implements IBaseController {
if
(!
StringUtils
.
isEmpty
(
deviceId
))
{
if
(!
StringUtils
.
isEmpty
(
deviceId
))
{
String
verificationDeviceCountKey
=
Constants
.
REDIS_VOICE_DEVICE_COUNT
+
deviceId
;
String
verificationDeviceCountKey
=
Constants
.
REDIS_VOICE_DEVICE_COUNT
+
deviceId
;
Long
getDeviceVerificationCount
=
redisTemplate
.
opsForHash
().
increment
(
verificationDeviceCountKey
,
Constants
.
REDIS_VOICE_DEVICE_COUNT
,
1
);
Long
getDeviceVerificationCount
=
redisTemplate
.
opsForHash
().
increment
(
verificationDeviceCountKey
,
Constants
.
REDIS_VOICE_DEVICE_COUNT
,
1
);
redisTemplate
.
expire
(
verificationDeviceCountKey
,
Constants
.
ONE_DAY
,
TimeUnit
.
SECONDS
);
if
(
getDeviceVerificationCount
>
DEVICE_MAX_PER_DAY
)
{
if
(
getDeviceVerificationCount
>
DEVICE_MAX_PER_DAY
)
{
return
JsonResult
.
buildErrorStateResult
(
"您设备已经达到获取今天语音验证码上限"
,
null
);
return
JsonResult
.
buildErrorStateResult
(
"您设备已经达到获取今天语音验证码上限"
,
null
);
}
}
}
}
redisTemplate
.
expire
(
verificationCountKey
,
DateUtils
.
getSeconds
(),
TimeUnit
.
SECONDS
);
if
(!
ValidationUtil
.
validatePhoneNo
(
phoneNo
))
{
if
(!
ValidationUtil
.
validatePhoneNo
(
phoneNo
))
{
return
JsonResult
.
buildErrorStateResult
(
"手机号格式有误"
,
null
);
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