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
bc5d1a76
Commit
bc5d1a76
authored
Nov 22, 2017
by
技术部-任文超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化改进:短信验证码计数器/账密计数器 的生命期,从每次递增24小时 --变更未-->当日有效(自然日)
parent
3d2a4744
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
7 deletions
+8
-7
Constants.java
src/main/java/cn/quantgroup/xyqb/Constants.java
+0
-1
SmsController.java
...uantgroup/xyqb/controller/internal/sms/SmsController.java
+3
-3
UserController.java
...ntgroup/xyqb/controller/internal/user/UserController.java
+2
-1
DateUtils.java
src/main/java/cn/quantgroup/xyqb/util/DateUtils.java
+3
-2
No files found.
src/main/java/cn/quantgroup/xyqb/Constants.java
View file @
bc5d1a76
...
...
@@ -45,7 +45,6 @@ public interface Constants {
* redis中token的key值前缀
*/
String
SESSION_PREFIX
=
"spring:session:sessions:"
;
Long
ONE_DAY
=
24
*
60
*
60L
;
interface
Channel
{
long
LKB
=
1
;
// 量化派
...
...
src/main/java/cn/quantgroup/xyqb/controller/internal/sms/SmsController.java
View file @
bc5d1a76
...
...
@@ -234,7 +234,7 @@ 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
);
redisTemplate
.
expire
(
verificationPhoneCountKey
,
Constants
.
ONE_DAY
,
TimeUnit
.
SECONDS
);
redisTemplate
.
expire
(
verificationPhoneCountKey
,
DateUtils
.
getSeconds
(),
TimeUnit
.
SECONDS
);
if
(
getPhoneVerificationCount
>
PHONE_MAX_PER_DAY
)
{
LOGGER
.
info
(
"您手机号已经达到获取今天短信验证码上限:phoneNo:{},deviceId:{},ip:{}"
,
phoneNo
,
deviceId
,
getIp
());
...
...
@@ -255,7 +255,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
);
redisTemplate
.
expire
(
verificationDeviceCountKey
,
Constants
.
ONE_DAY
,
TimeUnit
.
SECONDS
);
redisTemplate
.
expire
(
verificationDeviceCountKey
,
DateUtils
.
getSeconds
(),
TimeUnit
.
SECONDS
);
if
(
getDeviceVerificationCount
>
DEVICE_MAX_PER_DAY
)
{
LOGGER
.
info
(
"您设备已经达到获取今天短信验证码上限:phoneNo:{},deviceId:{},ip:{}"
,
phoneNo
,
verificationDeviceCountKey
,
getIp
());
return
JsonResult
.
buildErrorStateResult
(
"您设备已经达到获取今天短信验证码上限"
,
null
);
...
...
@@ -311,7 +311,7 @@ public class SmsController implements IBaseController {
if
(!
StringUtils
.
isEmpty
(
deviceId
))
{
String
verificationDeviceCountKey
=
Constants
.
REDIS_VOICE_DEVICE_COUNT
+
deviceId
;
Long
getDeviceVerificationCount
=
redisTemplate
.
opsForHash
().
increment
(
verificationDeviceCountKey
,
Constants
.
REDIS_VOICE_DEVICE_COUNT
,
1
);
redisTemplate
.
expire
(
verificationDeviceCountKey
,
Constants
.
ONE_DAY
,
TimeUnit
.
SECONDS
);
redisTemplate
.
expire
(
verificationDeviceCountKey
,
DateUtils
.
getSeconds
(),
TimeUnit
.
SECONDS
);
if
(
getDeviceVerificationCount
>
DEVICE_MAX_PER_DAY
)
{
return
JsonResult
.
buildErrorStateResult
(
"您设备已经达到获取今天语音验证码上限"
,
null
);
}
...
...
src/main/java/cn/quantgroup/xyqb/controller/internal/user/UserController.java
View file @
bc5d1a76
...
...
@@ -21,6 +21,7 @@ import cn.quantgroup.xyqb.service.sms.ISmsService;
import
cn.quantgroup.xyqb.service.user.IUserDetailService
;
import
cn.quantgroup.xyqb.service.user.IUserService
;
import
cn.quantgroup.xyqb.service.wechat.IWechatService
;
import
cn.quantgroup.xyqb.util.DateUtils
;
import
cn.quantgroup.xyqb.util.MqUtils
;
import
cn.quantgroup.xyqb.util.PasswordUtil
;
import
cn.quantgroup.xyqb.util.ValidationUtil
;
...
...
@@ -543,7 +544,7 @@ public class UserController implements IBaseController {
// 密码错误时,给该账号添加计数器
String
key
=
Constants
.
REDIS_PASSWORD_ERROR_COUNT
+
userName
;
if
(!
stringRedisTemplate
.
hasKey
(
key
))
{
stringRedisTemplate
.
opsForValue
().
set
(
key
,
String
.
valueOf
(
0
),
Constants
.
ONE_DAY
,
TimeUnit
.
SECONDS
);
stringRedisTemplate
.
opsForValue
().
set
(
key
,
String
.
valueOf
(
0
),
DateUtils
.
getSeconds
()
,
TimeUnit
.
SECONDS
);
}
// 密码错误计数
Long
errorCount
=
stringRedisTemplate
.
opsForValue
().
increment
(
key
,
1L
);
...
...
src/main/java/cn/quantgroup/xyqb/util/DateUtils.java
View file @
bc5d1a76
...
...
@@ -7,7 +7,7 @@ import java.util.Calendar;
*/
public
class
DateUtils
{
/**
* 计算当前时间到当天
23:59:59
时间差,
* 计算当前时间到当天
23:59:59.999
时间差,
* 返回时间差(单位秒)
* @return
*/
...
...
@@ -16,9 +16,10 @@ public class DateUtils {
endOfDay
.
set
(
Calendar
.
HOUR_OF_DAY
,
23
);
endOfDay
.
set
(
Calendar
.
MINUTE
,
59
);
endOfDay
.
set
(
Calendar
.
SECOND
,
59
);
endOfDay
.
set
(
Calendar
.
MILLISECOND
,
999
);
long
timeStamp
=
endOfDay
.
getTimeInMillis
();
Calendar
current
=
Calendar
.
getInstance
();
long
now
=
current
.
getTimeIn
Millis
();
long
now
=
System
.
currentTime
Millis
();
long
during
=
(
timeStamp
-
now
)
/
1000
;
return
during
;
}
...
...
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