Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
V
volunteer_service
Project
Project
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
licc
volunteer_service
Commits
9815f182
Commit
9815f182
authored
Apr 09, 2021
by
cy
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
03a0d007
97402e78
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
150 additions
and
81 deletions
+150
-81
RedisConfig.java
...src/main/java/cn/wisenergy/common/config/RedisConfig.java
+2
-2
SerializeUtils.java
.../main/java/cn/wisenergy/common/config/SerializeUtils.java
+82
-0
UserLoginServiceImpl.java
...a/cn/wisenergy/service/app/impl/UserLoginServiceImpl.java
+4
-2
KickoutSessionControlFilter.java
...ergy/service/shir/filter/KickoutSessionControlFilter.java
+62
-77
No files found.
wisenergy-common/src/main/java/cn/wisenergy/common/config/RedisConfig.java
View file @
9815f182
...
...
@@ -21,8 +21,8 @@ public class RedisConfig {
RedisTemplate
<
String
,
Object
>
redisTemplate
=
new
RedisTemplate
<>();
redisTemplate
.
setKeySerializer
(
new
StringRedisSerializer
());
redisTemplate
.
setHashKeySerializer
(
new
StringRedisSerializer
());
redisTemplate
.
setHashValueSerializer
(
new
S
tringRedisSerializer
());
redisTemplate
.
setValueSerializer
(
new
S
tringRedisSerializer
());
redisTemplate
.
setHashValueSerializer
(
new
S
erializeUtils
());
redisTemplate
.
setValueSerializer
(
new
S
erializeUtils
());
redisTemplate
.
setConnectionFactory
(
factory
);
return
redisTemplate
;
}
...
...
wisenergy-common/src/main/java/cn/wisenergy/common/config/SerializeUtils.java
0 → 100644
View file @
9815f182
package
cn
.
wisenergy
.
common
.
config
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.data.redis.serializer.RedisSerializer
;
import
org.springframework.data.redis.serializer.SerializationException
;
import
java.io.*
;
/**
* @author: nh
* @date: 2021/04/08
* @description: redis的value序列化工具
*/
public
class
SerializeUtils
implements
RedisSerializer
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
SerializeUtils
.
class
);
public
static
boolean
isEmpty
(
byte
[]
data
)
{
return
(
data
==
null
||
data
.
length
==
0
);
}
/**
* 序列化
*
* @param object
* @return
* @throws SerializationException
*/
@Override
public
byte
[]
serialize
(
Object
object
)
throws
SerializationException
{
byte
[]
result
=
null
;
if
(
object
==
null
)
{
return
new
byte
[
0
];
}
try
(
ByteArrayOutputStream
byteStream
=
new
ByteArrayOutputStream
(
128
);
ObjectOutputStream
objectOutputStream
=
new
ObjectOutputStream
(
byteStream
)
)
{
if
(!(
object
instanceof
Serializable
))
{
throw
new
IllegalArgumentException
(
SerializeUtils
.
class
.
getSimpleName
()
+
" requires a Serializable payload "
+
"but received an object of type ["
+
object
.
getClass
().
getName
()
+
"]"
);
}
objectOutputStream
.
writeObject
(
object
);
objectOutputStream
.
flush
();
result
=
byteStream
.
toByteArray
();
}
catch
(
Exception
ex
)
{
logger
.
error
(
"Failed to serialize"
,
ex
);
}
return
result
;
}
/**
* 反序列化
*
* @param bytes
* @return
* @throws SerializationException
*/
@Override
public
Object
deserialize
(
byte
[]
bytes
)
throws
SerializationException
{
Object
result
=
null
;
if
(
isEmpty
(
bytes
))
{
return
null
;
}
try
(
ByteArrayInputStream
byteStream
=
new
ByteArrayInputStream
(
bytes
);
ObjectInputStream
objectInputStream
=
new
ObjectInputStream
(
byteStream
)
)
{
result
=
objectInputStream
.
readObject
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"Failed to deserialize"
,
e
);
}
return
result
;
}
}
\ No newline at end of file
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/UserLoginServiceImpl.java
View file @
9815f182
...
...
@@ -63,6 +63,9 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, User> impleme
@Autowired
private
RedisService
redisService
;
@Autowired
private
KickoutSessionControlFilter
kickoutSessionControlFilter
;
//VIP客户初始密码
private
static
final
String
PASSWORD
=
"123456"
;
...
...
@@ -206,8 +209,7 @@ public class UserLoginServiceImpl extends ServiceImpl<UsersMapper, User> impleme
UserToken
userToken
=
new
UserToken
(
userVo
.
getPhone
(),
credentialsSalt
,
USER_LOGIN_TYPE
);
try
{
subject
.
login
(
userToken
);
KickoutSessionControlFilter
kitOut
=
new
KickoutSessionControlFilter
();
kitOut
.
changeSession
(
1
);
kickoutSessionControlFilter
.
changeSession
(
1
);
//3、构造返回参数
UserInfoVo
userInfoVo
=
new
UserInfoVo
();
userInfoVo
.
setUserId
(
user
.
getId
());
...
...
wisenergy-service/src/main/java/cn/wisenergy/service/shir/filter/KickoutSessionControlFilter.java
View file @
9815f182
This diff is collapsed.
Click to expand it.
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