Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
api
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
首航-临时账号
api
Commits
91096a14
Commit
91096a14
authored
Sep 24, 2019
by
java-李谡
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加redis方法
parent
c4499914
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
10 deletions
+20
-10
redis.properties
resources/redis.properties
+6
-3
UserController.java
src/com/ejweb/modules/user/api/UserController.java
+14
-7
No files found.
resources/redis.properties
View file @
91096a14
...
...
@@ -8,5 +8,8 @@ redis.maxWaitMillis=10000
redis.testOnBorrow
=
true
redis.testOnReturn
=
true
redis.dbIndex
=
3
ipWithinSeconds
=
60
ipLimitTimes
=
10
\ No newline at end of file
redis.ipWithinSeconds
=
60
redis.ipLimitTimes
=
10
redis.usernameWithinSeconds
=
60
redis.usernameLimitTimes
=
10
redis.blackUsernameTime
=
60
\ No newline at end of file
src/com/ejweb/modules/user/api/UserController.java
View file @
91096a14
...
...
@@ -49,6 +49,16 @@ public class UserController {
private
MobileVerifyService
mobileVerifyService
;
@Value
(
"${redis.dbIndex}"
)
private
int
indexDb
;
@Value
(
"${redis.ipWithinSeconds}"
)
private
int
ipWithinSeconds
;
@Value
(
"${redis.ipLimitTimes}"
)
private
int
ipLimitTimes
;
@Value
(
"${redis.usernameWithinSeconds}"
)
private
int
usernameWithinSeconds
;
@Value
(
"${redis.usernameLimitTimes}"
)
private
int
usernameLimitTimes
;
@Value
(
"${redis.blackUsernameTime}"
)
private
int
blackUsernameTime
;
@Autowired
private
RedisUtils
redisUtils
;
@Autowired
...
...
@@ -147,9 +157,9 @@ public class UserController {
}
String
blackUsername
=
redisUtils
.
get
(
"black_username:"
+
loginBean
.
getLoginName
(),
indexDb
);
boolean
sealup
=
false
;
if
(
null
!=
redisUsername
&&
Integer
.
parseInt
(
redisUsername
)
>=
5
&&
StringUtils
.
isEmpty
(
blackUsername
))
{
if
(
null
!=
redisUsername
&&
Integer
.
parseInt
(
redisUsername
)
>=
usernameLimitTimes
&&
StringUtils
.
isEmpty
(
blackUsername
))
{
redisUtils
.
set
(
"black_username:"
+
loginBean
.
getLoginName
(),
1
,
indexDb
);
redisUtils
.
expire
(
"black_username:"
+
loginBean
.
getLoginName
(),
60
,
indexDb
);
redisUtils
.
expire
(
"black_username:"
+
loginBean
.
getLoginName
(),
blackUsernameTime
,
indexDb
);
sealup
=
true
;
}
else
if
(
blackUsername
!=
null
)
{
sealup
=
true
;
...
...
@@ -168,7 +178,7 @@ public class UserController {
// 用户信息redis初始时间 增加value值
if
(
StringUtils
.
isEmpty
(
redisUsername
))
{
redisUtils
.
set
(
loginBean
.
getLoginName
(),
1
,
indexDb
);
redisUtils
.
expire
(
loginBean
.
getLoginName
(),
60
,
indexDb
);
redisUtils
.
expire
(
loginBean
.
getLoginName
(),
usernameWithinSeconds
,
indexDb
);
}
else
{
redisUtils
.
incrNotResetExpireTime
(
loginBean
.
getLoginName
(),
indexDb
);
}
...
...
@@ -217,7 +227,7 @@ public class UserController {
// 用户信息redis初始时间 增加value值
if
(
StringUtils
.
isEmpty
(
redisUsername
))
{
redisUtils
.
set
(
loginBean
.
getLoginName
(),
1
,
indexDb
);
redisUtils
.
expire
(
loginBean
.
getLoginName
(),
60
,
indexDb
);
redisUtils
.
expire
(
loginBean
.
getLoginName
(),
usernameWithinSeconds
,
indexDb
);
}
else
{
redisUtils
.
incrNotResetExpireTime
(
loginBean
.
getLoginName
(),
indexDb
);
}
...
...
@@ -1031,9 +1041,6 @@ public class UserController {
private
void
checkIpLimit
(
String
userIp
)
{
//ip受限时间与次数
int
ipWithinSeconds
=
Integer
.
valueOf
(
PropertiesUtils
.
getProperties
().
get
(
"ipWithinSeconds"
).
toString
());
int
ipLimitTimes
=
Integer
.
valueOf
(
PropertiesUtils
.
getProperties
().
get
(
"ipLimitTimes"
).
toString
());
//如果redis没有key
if
(
redisUtils
.
get
(
userIp
,
indexDb
)
==
null
)
{
redisUtils
.
set
(
userIp
,
1
,
indexDb
);
...
...
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