Commit cff62489 by 陶湘宇

恢复session登录,默认存储redis

parent 8d9c11f9
......@@ -222,17 +222,17 @@
</dependency> -->
<!-- redis starter spring boot 与redis应用基本环境配置 -->
<!-- <dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency> -->
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.session/spring-session-data-redis -->
<!--spring session 与redis应用基本环境配置,需要开启redis后才可以使用,不然启动Spring boot会报错 -->
<!-- <dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>
</dependency> -->
</dependency>
<!--jedis -->
<!-- <dependency>
......
......@@ -99,7 +99,7 @@ public class LogAspect
// 获取当前的用户
// 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) {
// Object[] objs = joinPoint.getArgs();
......
......@@ -70,7 +70,7 @@ public class RoleAspect {
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 count = new LambdaQueryChainWrapper<QyzxEmpEntAsso>(qyzxEmpEntAssoMapper)
......
......@@ -51,33 +51,17 @@ public class RedisSessionInterceptor implements HandlerInterceptor {
*/
// 无论访问的地址是不是正确的,都进行登录验证,登录成功后的访问再进行分发,404的访问自然会进入到错误控制器中
HttpSession session = request.getSession();
//String Sid
System.out.println("RSID==------=="+session.getId());
System.out.println("ROSID=-----==="+request.getRequestedSessionId());
/**
* 新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) {
Object ai = session.getAttribute("ai");
Object ui = session.getAttribute("ui");
if(session.getAttribute("ui")==null&&session.getAttribute("ai")==null) {
response401(response);
return false;
}
try {
QyzxEmpLogin eld = BeanUtil.toBean(ui, QyzxEmpLogin.class);
QyzxEmpLogin eld = BeanUtil.toBean(session.getAttribute("ui"), QyzxEmpLogin.class);
if(redisUtil.get("BlockUser"+eld.getId())!=null){
redisUtil.del("BlockUser"+eld.getId());
session.removeAttribute("ui");
redisUtil.del(session.getId());
response302(response);
return false;
}
......
......@@ -3,7 +3,6 @@ package cn.timer.api.config.interceptor;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import cn.timer.api.utils.redis.RedisUtil;
import org.springframework.core.MethodParameter;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.support.WebDataBinderFactory;
......@@ -24,8 +23,6 @@ public class UserMethodArgumentResolver implements HandlerMethodArgumentResolver
@Resource
private HttpSession session;
@Resource
private RedisUtil redisUtil;
public UserMethodArgumentResolver() {
}
......@@ -43,11 +40,9 @@ public class UserMethodArgumentResolver implements HandlerMethodArgumentResolver
public UserBean resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
// String webRequestid = webRequest.getSessionId();
// String sessionid = session.getId();
QyzxEmpLogin eld = BeanUtil.toBean(redisUtil.getAttribute(session.getId(),"ui"), QyzxEmpLogin.class);
QyzxEmpLogin eld = BeanUtil.toBean(session.getAttribute("ui"), QyzxEmpLogin.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);
// Object phone = webRequest.getAttribute(currentUserAnnotation.id(),
......
......@@ -919,10 +919,8 @@ public class LoginController {
// 需要更新最后一次登陆信息
// 用户信息缓存
//session.setAttribute("ui", qyzxEmpLogin1);
redisUtil.setAttribute(session.getId(),"ui",qyzxEmpLogin1);
System.err.println("redis=>>session"+session.getId());
Object ui = redisUtil.getAttribute(session.getId(),"ui");
session.setAttribute("ui", qyzxEmpLogin1);
return ResultUtil.data(qyzxEmpLogin1);
}
......
......@@ -355,8 +355,7 @@ public class QyzxController {
}
}
emp.setOrgId(orgCode);
//session.setAttribute("ui", emp);
redisUtil.setAttribute(session.getId(),"ui", emp);
session.setAttribute("ui", emp);
qyzxEmpLoginMapper.updateById(emp);
return ResultUtil.data(menus, "切换企业成功");
} else {
......
......@@ -34,8 +34,6 @@ import javax.servlet.http.HttpSession;
public class SuperLoginController {
@Autowired
private HttpSession session;
@Autowired
private RedisUtil redisUtil;
@PostMapping(value = "/adminLogin")
@ApiOperation(value = "运营后台登录", httpMethod = "POST", notes = "接口发布说明")
public Result<Object> adminLogin(@RequestBody EntRegisterDto entRegisterDto, HttpServletRequest request){
......@@ -47,17 +45,15 @@ public class SuperLoginController {
if(adminAccount==null){
return ResultUtil.error("用户不存在或密码错误");
}
// session=request.getSession();
redisUtil.setAttribute(session.getId(),"ai", adminAccount);
System.err.println(session.getId());
session=request.getSession();
session.setAttribute("ai", adminAccount);
return ResultUtil.data(adminAccount);
};
@PostMapping(value = "/adminOutLogin")
@ApiOperation(value = "运营后台退出", httpMethod = "POST", notes = "接口发布说明")
public Result<String> adminOutLogin(HttpServletRequest request){
//session= request.getSession();
// session.removeAttribute("ai");
redisUtil.del(session.getId());
session= request.getSession();
session.removeAttribute("ai");
return ResultUtil.data("退出成功");
}
}
......@@ -116,7 +116,7 @@ spring:
port: 465
class: javax.net.ssl.SSLSocketFactory
redis:
database: 35 # Redis数据库索引(默认为0),如果设置为1,那么存入的key-value都存放在select 1中
database: 36 # Redis数据库索引(默认为0),如果设置为1,那么存入的key-value都存放在select 1中
host: r-wz9p8pve7uem63b10upd.redis.rds.aliyuncs.com
port: 6379
password: (!0YouLingRcRedis0!)
......@@ -271,26 +271,29 @@ insure:
insuredUrl: 'https://portal.unistar-ins.com/mall/Home/Index/createQuotePolicy'
#投保请求出单
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/createQuotePolicy'
#投保支付
toPayUrl: 'https://portal.unistar-ins.com/mall/Home/Pay/toPay'
#保全支付
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
appidq: '1000711000604326196'
appidq: '1000706050307154062'
#保全 secret
secretq: 'a2da17a2797c63dff9172df50af9da65'
secretq: 'c1e2e8dcf231c0d0dfc883c09cd42c5b'
#保全上传文件
uploadUrlq: 'https://portal.unistar-ins.com/fuli/Home/Index/file_upload'
#保全申请
batchUrl: 'https://portal.unistar-ins.com/fuli/Home/WelfareProduct/batch_declare'
#保全取消支付
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:
serverUrl: 'https://www.youlingrc.com'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment