Explorar o código

改成redis 缓存

tianwu.sun hai 9 meses
pai
achega
e4771039ea

+ 5 - 5
pom.xml

@@ -177,11 +177,11 @@
             <groupId>org.springframework</groupId>
             <artifactId>spring-context-support</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-devtools</artifactId>
-            <optional>true</optional>
-        </dependency>
+<!--        <dependency>-->
+<!--            <groupId>org.springframework.boot</groupId>-->
+<!--            <artifactId>spring-boot-devtools</artifactId>-->
+<!--            <optional>true</optional>-->
+<!--        </dependency>-->
         <!--activiti-->
         <dependency>
             <groupId>org.activiti</groupId>

+ 2 - 2
src/main/java/com/bootdo/common/aspect/LogAspect.java

@@ -101,8 +101,8 @@ public class LogAspect {
                 sysLog.setUsername("获取用户信息为空");
             }
         } else {
-            sysLog.setUserId(ShiroUtils.getUserId());
-            sysLog.setUsername(ShiroUtils.getUser().getUsername());
+            sysLog.setUserId(currUser.getUserId());
+            sysLog.setUsername(currUser.getUsername());
         }
         sysLog.setTime((int) time);
         // 系统当前时间

+ 0 - 61
src/main/java/com/bootdo/common/aspect/WebLogAspect.java

@@ -1,61 +0,0 @@
-package com.bootdo.common.aspect;
-
-import com.bootdo.common.utils.HttpContextUtils;
-import org.aspectj.lang.JoinPoint;
-import org.aspectj.lang.ProceedingJoinPoint;
-import org.aspectj.lang.annotation.*;
-import org.aspectj.lang.reflect.MethodSignature;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Component;
-import org.springframework.web.context.request.RequestContextHolder;
-import org.springframework.web.context.request.ServletRequestAttributes;
-import sun.net.util.IPAddressUtil;
-
-import javax.servlet.http.HttpServletRequest;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-
-@Aspect
-@Component
-public class WebLogAspect {
-
-    private static final Logger logger = LoggerFactory.getLogger(WebLogAspect.class);
-
-    @Pointcut("execution( * com.bootdo..controller.*.*(..))")//两个..代表所有子目录,最后括号里的两个..代表所有参数
-    public void logPointCut() {
-    }
-
-
-    @Before("logPointCut()")
-    public void doBefore(JoinPoint joinPoint) throws Throwable {
-        // 接收到请求,记录请求内容
-        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
-        HttpServletRequest request = attributes.getRequest();
-
-        // 记录下请求内容
-        //logger.info("请求地址 : " + request.getRequestURL().toString());
-        //logger.info("HTTP METHOD : " + request.getMethod());
-        // 获取真实的ip地址
-        //logger.info("IP : " + IPAddressUtil.getClientIpAddress(request));
-        logger.info("CLASS_METHOD : " + joinPoint.getSignature().getDeclaringTypeName() + "."
-                + joinPoint.getSignature().getName());
-        logger.info("参数 : " + Arrays.toString(joinPoint.getArgs()));
-//        loggger.info("参数 : " + joinPoint.getArgs());
-
-    }
-
-    @AfterReturning(returning = "ret", pointcut = "logPointCut()")// returning的值和doAfterReturning的参数名一致
-    public void doAfterReturning(Object ret) throws Throwable {
-        // 处理完请求,返回内容(返回值太复杂时,打印的是物理存储空间的地址)
-        //logger.debug("返回值 : " + ret);
-    }
-
-    @Around("logPointCut()")
-    public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
-        long startTime = System.currentTimeMillis();
-        Object ob = pjp.proceed();// ob 为方法的返回值
-        //logger.info("耗时 : " + (System.currentTimeMillis() - startTime));
-        return ob;
-    }
-}

+ 2 - 4
src/main/java/com/bootdo/common/utils/ShiroUtils.java

@@ -1,7 +1,6 @@
 package com.bootdo.common.utils;
 
-import com.bootdo.system.domain.UserToken;
-import org.apache.commons.beanutils.BeanUtils;
+
 import org.apache.shiro.SecurityUtils;
 import org.apache.shiro.session.Session;
 import org.apache.shiro.session.mgt.eis.SessionDAO;
@@ -10,7 +9,6 @@ import org.apache.shiro.subject.Subject;
 import com.bootdo.system.domain.UserDO;
 import org.springframework.beans.factory.annotation.Autowired;
 
-import java.lang.reflect.InvocationTargetException;
 import java.security.Principal;
 import java.util.Collection;
 import java.util.List;
@@ -24,7 +22,7 @@ public class ShiroUtils {
     }
     public static UserDO getUser() {
         Object object = getSubjct().getPrincipal();
-        return (UserDO)object;
+        return (UserDO) object;
     }
     public static Long getUserId() {
         return getUser().getUserId();

+ 1 - 1
src/main/java/com/bootdo/system/config/ShiroConfig.java

@@ -122,7 +122,7 @@ public class ShiroConfig {
         // url过滤规则
         LinkedHashMap<String, String> filterChainDefinitionMap = new LinkedHashMap<>();
         filterChainDefinitionMap.put("/login", "anon");
-        filterChainDefinitionMap.put("/loginWithToken", "anon");
+        filterChainDefinitionMap.put("/ssoLogin", "anon");
         filterChainDefinitionMap.put("/code", "anon");
         filterChainDefinitionMap.put("/sso/**", "anon");
         filterChainDefinitionMap.put("/getVerify", "anon");

+ 1 - 1
src/main/java/com/bootdo/system/service/impl/SessionServiceImpl.java

@@ -48,7 +48,7 @@ public class SessionServiceImpl implements SessionService {
             userOnline.setHost(session.getHost());
             userOnline.setStartTimestamp(session.getStartTimestamp());
             userOnline.setLastAccessTime(session.getLastAccessTime());
-            userOnline.setTimeout(session.getTimeout());
+            userOnline.setTimeout(session.getTimeout() / (1000L * 60L));
             list.add(userOnline);
         }
         return list;

+ 1 - 3
src/main/resources/application.yml

@@ -32,9 +32,7 @@ spring:
     restart:
       enabled: true
   cache:
-    type: ehcache
-    ehcache:
-      config: classpath:config/ehcache.xml
+    type: redis
 mybatis:
   configuration:
     map-underscore-to-camel-case: true