Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
8
8timerapiv200
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
8timerv2
8timerapiv200
Commits
cff62489
Commit
cff62489
authored
Jun 14, 2023
by
陶湘宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
恢复session登录,默认存储redis
parent
8d9c11f9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
36 additions
and
61 deletions
+36
-61
pom.xml
+7
-7
src/main/java/cn/timer/api/aspect/LogAspect.java
+1
-1
src/main/java/cn/timer/api/aspect/RoleAspect.java
+1
-1
src/main/java/cn/timer/api/config/interceptor/RedisSessionInterceptor.java
+4
-20
src/main/java/cn/timer/api/config/interceptor/UserMethodArgumentResolver.java
+5
-10
src/main/java/cn/timer/api/controller/LoginController.java
+2
-4
src/main/java/cn/timer/api/controller/qyzx/QyzxController.java
+1
-2
src/main/java/cn/timer/api/controller/superadmin/SuperLoginController.java
+4
-8
src/main/resources/application-pro.yml
+11
-8
No files found.
pom.xml
View file @
cff62489
...
@@ -222,18 +222,18 @@
...
@@ -222,18 +222,18 @@
</dependency> -->
</dependency> -->
<!-- redis starter spring boot 与redis应用基本环境配置 -->
<!-- redis starter spring boot 与redis应用基本环境配置 -->
<
!-- <dependency>
<
dependency>
<groupId>
org.springframework.boot
</groupId>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-redis
</artifactId>
<artifactId>
spring-boot-starter-data-redis
</artifactId>
</dependency>
-->
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.session/spring-session-data-redis -->
<!-- https://mvnrepository.com/artifact/org.springframework.session/spring-session-data-redis -->
<!--spring session 与redis应用基本环境配置,需要开启redis后才可以使用,不然启动Spring boot会报错 -->
<!--spring session 与redis应用基本环境配置,需要开启redis后才可以使用,不然启动Spring boot会报错 -->
<
!-- <dependency>
<
dependency>
<groupId>org.springframework.session</groupId>
<groupId>
org.springframework.session
</groupId>
<artifactId>spring-session-data-redis</artifactId>
<artifactId>
spring-session-data-redis
</artifactId>
</dependency>
-->
</dependency>
<!--jedis -->
<!--jedis -->
<!-- <dependency>
<!-- <dependency>
<groupId>redis.clients</groupId>
<groupId>redis.clients</groupId>
...
...
src/main/java/cn/timer/api/aspect/LogAspect.java
View file @
cff62489
...
@@ -99,7 +99,7 @@ public class LogAspect
...
@@ -99,7 +99,7 @@ public class LogAspect
// 获取当前的用户
// 获取当前的用户
// LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
// LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
QyzxEmpLogin
eld
=
(
QyzxEmpLogin
)
redisUtil
.
getAttribute
(
session
.
getId
(),
"ui"
);
QyzxEmpLogin
eld
=
(
QyzxEmpLogin
)
session
.
getAttribute
(
"ui"
);
// if (eld == null && controllerLog.businessType() == BusinessType.SEND_CODE) {
// if (eld == null && controllerLog.businessType() == BusinessType.SEND_CODE) {
// Object[] objs = joinPoint.getArgs();
// Object[] objs = joinPoint.getArgs();
...
...
src/main/java/cn/timer/api/aspect/RoleAspect.java
View file @
cff62489
...
@@ -70,7 +70,7 @@ public class RoleAspect {
...
@@ -70,7 +70,7 @@ public class RoleAspect {
sysRoleType
.
add
(
t
.
getType
());
sysRoleType
.
add
(
t
.
getType
());
}
}
QyzxEmpLogin
eld
=
BeanUtil
.
toBean
(
redisUtil
.
getAttribute
(
session
.
getId
(),
"ui"
),
QyzxEmpLogin
.
class
);
QyzxEmpLogin
eld
=
BeanUtil
.
toBean
(
session
.
getAttribute
(
"ui"
),
QyzxEmpLogin
.
class
);
Integer
orgCode
=
eld
.
getOrgId
();
Integer
orgCode
=
eld
.
getOrgId
();
Integer
count
=
new
LambdaQueryChainWrapper
<
QyzxEmpEntAsso
>(
qyzxEmpEntAssoMapper
)
Integer
count
=
new
LambdaQueryChainWrapper
<
QyzxEmpEntAsso
>(
qyzxEmpEntAssoMapper
)
...
...
src/main/java/cn/timer/api/config/interceptor/RedisSessionInterceptor.java
View file @
cff62489
...
@@ -51,33 +51,17 @@ public class RedisSessionInterceptor implements HandlerInterceptor {
...
@@ -51,33 +51,17 @@ public class RedisSessionInterceptor implements HandlerInterceptor {
*/
*/
// 无论访问的地址是不是正确的,都进行登录验证,登录成功后的访问再进行分发,404的访问自然会进入到错误控制器中
// 无论访问的地址是不是正确的,都进行登录验证,登录成功后的访问再进行分发,404的访问自然会进入到错误控制器中
HttpSession
session
=
request
.
getSession
();
HttpSession
session
=
request
.
getSession
();
//String Sid
Object
ai
=
session
.
getAttribute
(
"ai"
);
System
.
out
.
println
(
"RSID==------=="
+
session
.
getId
());
Object
ui
=
session
.
getAttribute
(
"ui"
);
System
.
out
.
println
(
"ROSID=-----==="
+
request
.
getRequestedSessionId
());
if
(
session
.
getAttribute
(
"ui"
)==
null
&&
session
.
getAttribute
(
"ai"
)==
null
)
{
/**
* 新ID替换旧ID完成登陆
*/
if
(
session
.
getId
()!=
request
.
getRequestedSessionId
()&&
redisUtil
.
hasKey
(
request
.
getRequestedSessionId
())&&
redisUtil
.
getAttribute
(
session
.
getId
(),
"ai"
)==
null
){
try
{
redisUtil
.
reNmae
(
request
.
getRequestedSessionId
(),
session
.
getId
());
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
}
Object
nai
=
redisUtil
.
getAttribute
(
session
.
getId
(),
"ai"
);
Object
nui
=
redisUtil
.
getAttribute
(
session
.
getId
(),
"ui"
);
Object
ai
=
nai
!=
null
?
nai:
redisUtil
.
getAttribute
(
request
.
getRequestedSessionId
(),
"ai"
);
Object
ui
=
nui
!=
null
?
nui:
redisUtil
.
getAttribute
(
request
.
getRequestedSessionId
(),
"ui"
);
if
(
ui
==
null
&&
ai
==
null
)
{
response401
(
response
);
response401
(
response
);
return
false
;
return
false
;
}
}
try
{
try
{
QyzxEmpLogin
eld
=
BeanUtil
.
toBean
(
ui
,
QyzxEmpLogin
.
class
);
QyzxEmpLogin
eld
=
BeanUtil
.
toBean
(
session
.
getAttribute
(
"ui"
)
,
QyzxEmpLogin
.
class
);
if
(
redisUtil
.
get
(
"BlockUser"
+
eld
.
getId
())!=
null
){
if
(
redisUtil
.
get
(
"BlockUser"
+
eld
.
getId
())!=
null
){
redisUtil
.
del
(
"BlockUser"
+
eld
.
getId
());
redisUtil
.
del
(
"BlockUser"
+
eld
.
getId
());
session
.
removeAttribute
(
"ui"
);
session
.
removeAttribute
(
"ui"
);
redisUtil
.
del
(
session
.
getId
());
response302
(
response
);
response302
(
response
);
return
false
;
return
false
;
}
}
...
...
src/main/java/cn/timer/api/config/interceptor/UserMethodArgumentResolver.java
View file @
cff62489
...
@@ -3,7 +3,6 @@ package cn.timer.api.config.interceptor;
...
@@ -3,7 +3,6 @@ package cn.timer.api.config.interceptor;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpSession
;
import
javax.servlet.http.HttpSession
;
import
cn.timer.api.utils.redis.RedisUtil
;
import
org.springframework.core.MethodParameter
;
import
org.springframework.core.MethodParameter
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.bind.support.WebDataBinderFactory
;
import
org.springframework.web.bind.support.WebDataBinderFactory
;
...
@@ -24,8 +23,6 @@ public class UserMethodArgumentResolver implements HandlerMethodArgumentResolver
...
@@ -24,8 +23,6 @@ public class UserMethodArgumentResolver implements HandlerMethodArgumentResolver
@Resource
@Resource
private
HttpSession
session
;
private
HttpSession
session
;
@Resource
private
RedisUtil
redisUtil
;
public
UserMethodArgumentResolver
()
{
public
UserMethodArgumentResolver
()
{
}
}
...
@@ -43,19 +40,17 @@ public class UserMethodArgumentResolver implements HandlerMethodArgumentResolver
...
@@ -43,19 +40,17 @@ public class UserMethodArgumentResolver implements HandlerMethodArgumentResolver
public
UserBean
resolveArgument
(
MethodParameter
parameter
,
ModelAndViewContainer
mavContainer
,
public
UserBean
resolveArgument
(
MethodParameter
parameter
,
ModelAndViewContainer
mavContainer
,
NativeWebRequest
webRequest
,
WebDataBinderFactory
binderFactory
)
throws
Exception
{
NativeWebRequest
webRequest
,
WebDataBinderFactory
binderFactory
)
throws
Exception
{
// String webRequestid = webRequest.getSessionId();
// String webRequestid = webRequest.getSessionId();
// String sessionid = session.getId();
QyzxEmpLogin
eld
=
BeanUtil
.
toBean
(
session
.
getAttribute
(
"ui"
),
QyzxEmpLogin
.
class
);
QyzxEmpLogin
eld
=
BeanUtil
.
toBean
(
redisUtil
.
getAttribute
(
session
.
getId
(),
"ui"
),
QyzxEmpLogin
.
class
);
String
token
=
BeanUtil
.
toBean
(
session
.
getAttribute
(
CacheKeyConstant
.
TOKEN
),
String
.
class
);
String
token
=
BeanUtil
.
toBean
(
session
.
getAttribute
(
CacheKeyConstant
.
TOKEN
),
String
.
class
);
System
.
out
.
println
(
"token+++++===="
+
token
);
String
refreshToken
=
BeanUtil
.
toBean
(
session
.
getAttribute
(
CacheKeyConstant
.
REFRESH_TOKEN
),
String
.
class
);
String
refreshToken
=
BeanUtil
.
toBean
(
session
.
getAttribute
(
CacheKeyConstant
.
REFRESH_TOKEN
),
String
.
class
);
// Object phone = webRequest.getAttribute(currentUserAnnotation.id(),
// Object phone = webRequest.getAttribute(currentUserAnnotation.id(),
// NativeWebRequest.SCOPE_SESSION);
// NativeWebRequest.SCOPE_SESSION);
YgglMainEmp
mE
=
eld
.
getYgglMainEmp
();
YgglMainEmp
mE
=
eld
.
getYgglMainEmp
();
UserInfo
userInfo
=
UserInfo
.
builder
().
name
(
mE
.
getName
()).
phone
(
mE
.
getPhone
()).
bmgwId
(
mE
.
getBmgwId
()).
build
();
UserInfo
userInfo
=
UserInfo
.
builder
().
name
(
mE
.
getName
()).
phone
(
mE
.
getPhone
()).
bmgwId
(
mE
.
getBmgwId
()).
build
();
return
UserBean
.
builder
().
token
(
token
).
refreshToken
(
refreshToken
).
empNum
(
eld
.
getId
())
return
UserBean
.
builder
().
token
(
token
).
refreshToken
(
refreshToken
).
empNum
(
eld
.
getId
())
.
orgCode
(
eld
.
getOrgId
()).
userInfo
(
userInfo
).
qyzxEmpLogin
(
eld
).
build
();
.
orgCode
(
eld
.
getOrgId
()).
userInfo
(
userInfo
).
qyzxEmpLogin
(
eld
).
build
();
}
}
...
...
src/main/java/cn/timer/api/controller/LoginController.java
View file @
cff62489
...
@@ -919,10 +919,8 @@ public class LoginController {
...
@@ -919,10 +919,8 @@ public class LoginController {
// 需要更新最后一次登陆信息
// 需要更新最后一次登陆信息
// 用户信息缓存
// 用户信息缓存
//session.setAttribute("ui", qyzxEmpLogin1);
session
.
setAttribute
(
"ui"
,
qyzxEmpLogin1
);
redisUtil
.
setAttribute
(
session
.
getId
(),
"ui"
,
qyzxEmpLogin1
);
System
.
err
.
println
(
"redis=>>session"
+
session
.
getId
());
Object
ui
=
redisUtil
.
getAttribute
(
session
.
getId
(),
"ui"
);
return
ResultUtil
.
data
(
qyzxEmpLogin1
);
return
ResultUtil
.
data
(
qyzxEmpLogin1
);
}
}
...
...
src/main/java/cn/timer/api/controller/qyzx/QyzxController.java
View file @
cff62489
...
@@ -355,8 +355,7 @@ public class QyzxController {
...
@@ -355,8 +355,7 @@ public class QyzxController {
}
}
}
}
emp
.
setOrgId
(
orgCode
);
emp
.
setOrgId
(
orgCode
);
//session.setAttribute("ui", emp);
session
.
setAttribute
(
"ui"
,
emp
);
redisUtil
.
setAttribute
(
session
.
getId
(),
"ui"
,
emp
);
qyzxEmpLoginMapper
.
updateById
(
emp
);
qyzxEmpLoginMapper
.
updateById
(
emp
);
return
ResultUtil
.
data
(
menus
,
"切换企业成功"
);
return
ResultUtil
.
data
(
menus
,
"切换企业成功"
);
}
else
{
}
else
{
...
...
src/main/java/cn/timer/api/controller/superadmin/SuperLoginController.java
View file @
cff62489
...
@@ -34,8 +34,6 @@ import javax.servlet.http.HttpSession;
...
@@ -34,8 +34,6 @@ import javax.servlet.http.HttpSession;
public
class
SuperLoginController
{
public
class
SuperLoginController
{
@Autowired
@Autowired
private
HttpSession
session
;
private
HttpSession
session
;
@Autowired
private
RedisUtil
redisUtil
;
@PostMapping
(
value
=
"/adminLogin"
)
@PostMapping
(
value
=
"/adminLogin"
)
@ApiOperation
(
value
=
"运营后台登录"
,
httpMethod
=
"POST"
,
notes
=
"接口发布说明"
)
@ApiOperation
(
value
=
"运营后台登录"
,
httpMethod
=
"POST"
,
notes
=
"接口发布说明"
)
public
Result
<
Object
>
adminLogin
(
@RequestBody
EntRegisterDto
entRegisterDto
,
HttpServletRequest
request
){
public
Result
<
Object
>
adminLogin
(
@RequestBody
EntRegisterDto
entRegisterDto
,
HttpServletRequest
request
){
...
@@ -47,17 +45,15 @@ public class SuperLoginController {
...
@@ -47,17 +45,15 @@ public class SuperLoginController {
if
(
adminAccount
==
null
){
if
(
adminAccount
==
null
){
return
ResultUtil
.
error
(
"用户不存在或密码错误"
);
return
ResultUtil
.
error
(
"用户不存在或密码错误"
);
}
}
// session=request.getSession();
session
=
request
.
getSession
();
redisUtil
.
setAttribute
(
session
.
getId
(),
"ai"
,
adminAccount
);
session
.
setAttribute
(
"ai"
,
adminAccount
);
System
.
err
.
println
(
session
.
getId
());
return
ResultUtil
.
data
(
adminAccount
);
return
ResultUtil
.
data
(
adminAccount
);
};
};
@PostMapping
(
value
=
"/adminOutLogin"
)
@PostMapping
(
value
=
"/adminOutLogin"
)
@ApiOperation
(
value
=
"运营后台退出"
,
httpMethod
=
"POST"
,
notes
=
"接口发布说明"
)
@ApiOperation
(
value
=
"运营后台退出"
,
httpMethod
=
"POST"
,
notes
=
"接口发布说明"
)
public
Result
<
String
>
adminOutLogin
(
HttpServletRequest
request
){
public
Result
<
String
>
adminOutLogin
(
HttpServletRequest
request
){
//session= request.getSession();
session
=
request
.
getSession
();
// session.removeAttribute("ai");
session
.
removeAttribute
(
"ai"
);
redisUtil
.
del
(
session
.
getId
());
return
ResultUtil
.
data
(
"退出成功"
);
return
ResultUtil
.
data
(
"退出成功"
);
}
}
}
}
src/main/resources/application-pro.yml
View file @
cff62489
...
@@ -116,7 +116,7 @@ spring:
...
@@ -116,7 +116,7 @@ spring:
port
:
465
port
:
465
class
:
javax.net.ssl.SSLSocketFactory
class
:
javax.net.ssl.SSLSocketFactory
redis
:
redis
:
database
:
3
5
# Redis数据库索引(默认为0),如果设置为1,那么存入的key-value都存放在select 1中
database
:
3
6
# Redis数据库索引(默认为0),如果设置为1,那么存入的key-value都存放在select 1中
host
:
r-wz9p8pve7uem63b10upd.redis.rds.aliyuncs.com
host
:
r-wz9p8pve7uem63b10upd.redis.rds.aliyuncs.com
port
:
6379
port
:
6379
password
:
(!0YouLingRcRedis0!)
password
:
(!0YouLingRcRedis0!)
...
@@ -271,26 +271,29 @@ insure:
...
@@ -271,26 +271,29 @@ insure:
insuredUrl
:
'
https://portal.unistar-ins.com/mall/Home/Index/createQuotePolicy'
insuredUrl
:
'
https://portal.unistar-ins.com/mall/Home/Index/createQuotePolicy'
#投保请求出单
#投保请求出单
getPolicyUrl
:
'
https://portal.unistar-ins.com/issuing/Home/Index/index'
getPolicyUrl
:
'
https://portal.unistar-ins.com/issuing/Home/Index/index'
#查询保单信息
policyDetail
:
'
https://portal.unistar-ins.com/issuing/Home/Index/policy'
#申请保单
#申请保单
createQuote
:
'
https://portal.unistar-ins.com/mall/Home/Index/createQuote'
createQuote
:
'
https://portal.unistar-ins.com/mall/Home/Index/createQuote
Policy
'
#投保支付
#投保支付
toPayUrl
:
'
https://portal.unistar-ins.com/mall/Home/Pay/toPay'
toPayUrl
:
'
https://portal.unistar-ins.com/mall/Home/Pay/toPay'
#保全支付
#保全支付
batchToPayUrl
:
'
https://portal.unistar-ins.com/fuli/Home/ImportPay/set_import_pay'
batchToPayUrl
:
'
https://portal.unistar-ins.com/fuli/Home/ImportPay/set_import_pay'
#查询保单信息
#预付款出单接口
policyDetail
:
'
https://portal.unistar-ins.com/issuing/Home/Index/policy'
issue
:
'
https://portal.unistar-ins.com/cps/Labor/Policy/issue'
#保全appid
#保全appid
appidq
:
'
10007
11000604326196
'
appidq
:
'
10007
06050307154062
'
#保全 secret
#保全 secret
secretq
:
'
a2da17a2797c63dff9172df50af9da65
'
secretq
:
'
c1e2e8dcf231c0d0dfc883c09cd42c5b
'
#保全上传文件
#保全上传文件
uploadUrlq
:
'
https://portal.unistar-ins.com/fuli/Home/Index/file_upload'
uploadUrlq
:
'
https://portal.unistar-ins.com/fuli/Home/Index/file_upload'
#保全申请
#保全申请
batchUrl
:
'
https://portal.unistar-ins.com/fuli/Home/WelfareProduct/batch_declare'
batchUrl
:
'
https://portal.unistar-ins.com/fuli/Home/WelfareProduct/batch_declare'
#保全取消支付
#保全取消支付
cancelPayment
:
'
https://portal.unistar-ins.com/fuli/Home/OrderImport/order_import_set'
cancelPayment
:
'
https://portal.unistar-ins.com/fuli/Home/OrderImport/order_import_set'
#预付款提交接口
order_import_set
:
'
https://portal.unistar-ins.com/cps/Labor/OrderImport/order_import_set'
youling
:
youling
:
serverUrl
:
'
https://www.youlingrc.com'
serverUrl
:
'
https://www.youlingrc.com'
...
...
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