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
186f9b15
Commit
186f9b15
authored
Dec 06, 2017
by
技术部-任文超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码重构
parent
025c1465
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
23 deletions
+20
-23
Constants.java
src/main/java/cn/quantgroup/xyqb/Constants.java
+0
-8
IpValidateAdvisor.java
.../quantgroup/xyqb/aspect/accessable/IpValidateAdvisor.java
+5
-5
SessionServiceImpl.java
...ntgroup/xyqb/service/session/impl/SessionServiceImpl.java
+15
-10
No files found.
src/main/java/cn/quantgroup/xyqb/Constants.java
View file @
186f9b15
...
...
@@ -87,14 +87,6 @@ public interface Constants {
String
AVATAR_DEFAULT
=
"https://avatar.xyqb.com/default_avatar.png"
;
}
interface
Sms
{
String
VERIFICATION_CODE
=
"尊敬的用户,您本次的验证码为:%s,有效期10分钟。"
;
// 随机验证码
String
BINDCARD_SMS
=
"用户您好,您已绑卡成功,将会在1-5个工作日内收到借款,请耐心等待。如有疑问,请致电400-002-0061,感谢您对我们的支持"
;
//绑卡成功后的短信文案
String
REPAY_SMS
=
"用户您好,您在信用钱包的本期账单已还款成功,保持良好的信用可升级为VIP用户,享更多特权,感谢您对信用钱包的支持"
;
}
String
AES_KEY
=
"ScnmRBhuQpo9kBdn"
;
}
src/main/java/cn/quantgroup/xyqb/aspect/accessable/IpValidateAdvisor.java
View file @
186f9b15
...
...
@@ -21,6 +21,7 @@ import org.springframework.web.context.request.ServletRequestAttributes;
import
javax.servlet.http.HttpServletRequest
;
import
javax.xml.crypto.dsig.keyinfo.PGPData
;
import
java.util.Objects
;
/**
* IP白名单检验
...
...
@@ -44,9 +45,9 @@ public class IpValidateAdvisor {
private
void
whiteIpMatch
()
{
}
@
Before
(
"whiteIpMatch()"
)
@
Around
(
"whiteIpMatch()"
)
private
Object
doWhiteIpMatch
(
ProceedingJoinPoint
pjp
)
throws
Throwable
{
if
(
isDebug
!=
0
){
if
(
Objects
.
equals
(
isDebug
,
0
)
){
return
pjp
.
proceed
();
}
HttpServletRequest
request
=
((
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
()).
getRequest
();
...
...
@@ -69,8 +70,7 @@ public class IpValidateAdvisor {
private
void
needIpValidate
()
{
}
@Around
(
"needIpValidate()"
)
private
Object
doCapchaValidate
(
ProceedingJoinPoint
pjp
)
throws
Throwable
{
return
pjp
.
proceed
();
@Before
(
"needIpValidate()"
)
private
void
doCapchaValidate
()
throws
Throwable
{
}
}
src/main/java/cn/quantgroup/xyqb/service/session/impl/SessionServiceImpl.java
View file @
186f9b15
...
...
@@ -153,9 +153,10 @@ public class SessionServiceImpl implements ISessionService {
*/
private
void
setUserIdTokenKeys
(
long
userId
,
String
key
)
{
if
(
0L
!=
userId
)
{
String
setKey
=
getUserSessionSetKey
(
userId
);
try
{
stringRedisTemplate
.
opsForSet
().
add
(
Constants
.
Session
.
USER_SESSION_KEY_SET
+
userId
,
key
);
stringRedisTemplate
.
expire
(
Constants
.
Session
.
USER_SESSION_KEY_SET
+
userId
,
Constants
.
Session
.
ONE_DAY
,
TimeUnit
.
SECONDS
);
stringRedisTemplate
.
opsForSet
().
add
(
setKey
,
key
);
stringRedisTemplate
.
expire
(
setKey
,
Constants
.
Session
.
ONE_DAY
,
TimeUnit
.
SECONDS
);
}
catch
(
Exception
e
)
{
log
.
error
(
"存储用户注销件失败,userId:{},Exception:{}"
,
userId
,
e
);
}
...
...
@@ -189,21 +190,16 @@ public class SessionServiceImpl implements ISessionService {
@CacheEvict
(
value
=
"userextinfocache"
,
key
=
"'extinfo' + #userId"
,
cacheManager
=
"cacheManager"
)
public
void
deleteByUserId
(
long
userId
)
{
//1.删除session关联
Set
useIdKeys
=
stringRedisTemplate
.
opsForSet
().
members
(
Constants
.
Session
.
USER_SESSION_KEY_SET
+
userId
);
String
setKey
=
getUserSessionSetKey
(
userId
);
Set
useIdKeys
=
stringRedisTemplate
.
opsForSet
().
members
(
setKey
);
if
(!
CollectionUtils
.
isEmpty
(
useIdKeys
))
{
useIdKeys
.
forEach
(
key
->
{
log
.
info
(
"删除用户userId={}的缓存信息"
,
userId
);
stringRedisTemplate
.
delete
(
String
.
valueOf
(
key
));
});
//2.删除session缓存健
stringRedisTemplate
.
delete
(
Constants
.
Session
.
USER_SESSION_KEY_SET
+
userId
);
stringRedisTemplate
.
delete
(
setKey
);
}
}
/**
...
...
@@ -221,4 +217,13 @@ public class SessionServiceImpl implements ISessionService {
public
void
deleteUserCatch
(
User
user
)
{
}
/**
* 获取用户的会话缓存Set的Redis-Key
* @param userId - 用户主键
* @return
*/
private
String
getUserSessionSetKey
(
long
userId
)
{
return
Constants
.
Session
.
USER_SESSION_KEY_SET
+
userId
;
}
}
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