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
86b13e14
Commit
86b13e14
authored
Jul 12, 2023
by
唐峰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
用户资料和用户token操作相关改造2
parent
ff3adc54
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
1 deletion
+14
-1
IBaseController.java
...n/java/cn/quantgroup/xyqb/controller/IBaseController.java
+12
-0
SessionServiceImpl.java
...ntgroup/xyqb/service/session/impl/SessionServiceImpl.java
+1
-1
UserServiceImpl.java
...cn/quantgroup/xyqb/service/user/impl/UserServiceImpl.java
+1
-0
No files found.
src/main/java/cn/quantgroup/xyqb/controller/IBaseController.java
View file @
86b13e14
package
cn
.
quantgroup
.
xyqb
.
controller
;
package
cn
.
quantgroup
.
xyqb
.
controller
;
import
cn.quantgroup.xyqb.Constants
;
import
cn.quantgroup.xyqb.constant.UserConstant
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.model.session.SessionStruct
;
import
cn.quantgroup.xyqb.model.session.SessionStruct
;
import
cn.quantgroup.xyqb.util.IpUtil
;
import
cn.quantgroup.xyqb.util.IpUtil
;
...
@@ -20,6 +22,8 @@ import static cn.quantgroup.xyqb.session.XyqbSessionContextHolder.*;
...
@@ -20,6 +22,8 @@ import static cn.quantgroup.xyqb.session.XyqbSessionContextHolder.*;
*/
*/
public
interface
IBaseController
{
public
interface
IBaseController
{
@Deprecated
@Deprecated
default
User
getCurrentUser
()
{
default
User
getCurrentUser
()
{
SessionStruct
session
=
getXSession
();
SessionStruct
session
=
getXSession
();
...
@@ -50,6 +54,14 @@ public interface IBaseController {
...
@@ -50,6 +54,14 @@ public interface IBaseController {
return
tenantId
;
return
tenantId
;
}
}
default
Integer
getTenantId
()
{
String
tenantIdStr
=
getRequest
().
getHeader
(
Constants
.
X_AUTH_TENANT
);
if
(
StringUtils
.
isEmpty
(
tenantIdStr
))
{
tenantIdStr
=
UserConstant
.
defaultTenantIdString
;
}
return
Integer
.
parseInt
(
tenantIdStr
);
}
default
SessionStruct
getCurrentSessionFromRedis
()
{
default
SessionStruct
getCurrentSessionFromRedis
()
{
return
getXSessionFromRedis
();
return
getXSessionFromRedis
();
}
}
...
...
src/main/java/cn/quantgroup/xyqb/service/session/impl/SessionServiceImpl.java
View file @
86b13e14
...
@@ -247,7 +247,7 @@ public class SessionServiceImpl implements ISessionService {
...
@@ -247,7 +247,7 @@ public class SessionServiceImpl implements ISessionService {
}
}
@Override
@Override
@CacheEvict
(
value
=
"userextinfocache"
,
key
=
"'extinfo' + #userId"
,
cacheManager
=
"cacheManager"
)
@CacheEvict
(
value
=
"userextinfocache"
,
key
=
"'extinfo' + #userId
+ '-' + #tenantId
"
,
cacheManager
=
"cacheManager"
)
public
void
deleteByUserId
(
long
userId
,
Integer
tenantId
)
{
public
void
deleteByUserId
(
long
userId
,
Integer
tenantId
)
{
//1.删除session关联
//1.删除session关联
String
setKey
=
getUserSessionSetKey
(
userId
,
tenantId
);
String
setKey
=
getUserSessionSetKey
(
userId
,
tenantId
);
...
...
src/main/java/cn/quantgroup/xyqb/service/user/impl/UserServiceImpl.java
View file @
86b13e14
...
@@ -244,6 +244,7 @@ public class UserServiceImpl implements IUserService, IBaseController {
...
@@ -244,6 +244,7 @@ public class UserServiceImpl implements IUserService, IBaseController {
// user.setPassword(PasswordUtil.MD5WithSalt(password));
// user.setPassword(PasswordUtil.MD5WithSalt(password));
user
.
setCipherPassword
(
BctyptPasswordUtil
.
BCryptWithSalt
(
password
));
user
.
setCipherPassword
(
BctyptPasswordUtil
.
BCryptWithSalt
(
password
));
user
=
userRepository
.
save
(
user
);
user
=
userRepository
.
save
(
user
);
//cacheManager 配置的默认过期时间为3600s, 此处设置为1ms,是为了不缓存立刻过期 ?
stringRedisTemplate
.
expire
(
"usercache:xyqbuser"
+
phoneNo
,
1L
,
TimeUnit
.
MILLISECONDS
);
stringRedisTemplate
.
expire
(
"usercache:xyqbuser"
+
phoneNo
,
1L
,
TimeUnit
.
MILLISECONDS
);
sessionService
.
deleteByUserId
(
user
.
getId
(),
tenantId
);
sessionService
.
deleteByUserId
(
user
.
getId
(),
tenantId
);
return
BctyptPasswordUtil
.
BCryptCheckPw
(
password
,
user
.
getCipherPassword
());
return
BctyptPasswordUtil
.
BCryptCheckPw
(
password
,
user
.
getCipherPassword
());
...
...
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