diff --git a/src/main/java/com/bonus/gzgqj/business/utils/SystemUtils.java b/src/main/java/com/bonus/gzgqj/business/utils/SystemUtils.java index c94b318..829670b 100644 --- a/src/main/java/com/bonus/gzgqj/business/utils/SystemUtils.java +++ b/src/main/java/com/bonus/gzgqj/business/utils/SystemUtils.java @@ -12,6 +12,7 @@ public class SystemUtils { public static String windowsPath; + public static String otherPath; public static String linuxPath; @@ -25,6 +26,11 @@ public class SystemUtils { SystemUtils.windowsPath = windowsPath; } + @Value("${file.upload_path.other}") + public void setOtherPath(String otherPath) { + SystemUtils.otherPath = otherPath; + } + /** * 自动注入 * @@ -65,10 +71,11 @@ public class SystemUtils { } else if ("linux".equals(os)) { return linuxPath; } else { - return windowsPath; + return otherPath; } } } + diff --git a/src/main/java/com/bonus/gzgqj/manager/security/jwt/JwtAuthenticationTokenFilter.java b/src/main/java/com/bonus/gzgqj/manager/security/jwt/JwtAuthenticationTokenFilter.java index 02f7553..8812096 100644 --- a/src/main/java/com/bonus/gzgqj/manager/security/jwt/JwtAuthenticationTokenFilter.java +++ b/src/main/java/com/bonus/gzgqj/manager/security/jwt/JwtAuthenticationTokenFilter.java @@ -9,6 +9,7 @@ import com.bonus.gzgqj.manager.constant.SecurityConstants; import com.bonus.gzgqj.manager.security.entity.SelfUserEntity; import io.jsonwebtoken.Claims; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Component; @@ -27,14 +28,21 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter { @Autowired private JWTTokenService tokenService; + @Value("${server.servlet.context-path}") + public String path; + @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException, IOException, ServletException { //获取token String jwtToken = SecurityUtils.getToken(request); String uri=request.getRequestURI(); - System.err.println(uri); + System.err.println(uri); - if("/login/userLogin".equals(uri)){ + if((path + "/login/userLogin").equals(uri)){ + filterChain.doFilter(request, response); + return; + } + if((path +"/login/appUserLogin").equals(uri)){ filterChain.doFilter(request, response); return; } @@ -47,7 +55,9 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter { return; } if(StringUtils.isEmpty(jwtToken)){ - ResultUtil.responseJson(response,ResultUtil.resultCode(401,"请先登录")); + System.err.println("----------------->"); + ResultUtil.responseJson(response,ResultUtil.resultCode(401,"登录过期,请先登录")); + System.err.println("异常401,token信息:" + jwtToken + ",地址" + uri); return; } //解析token @@ -59,10 +69,10 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter { } catch (Exception e) { e.printStackTrace(); - ResultUtil.responseJson(response,ResultUtil.resultCode(401,"请先登录")); + ResultUtil.responseJson(response,ResultUtil.resultCode(401,"登录过期,请先登录")); return; } - SelfUserEntity loginUser = tokenService.getLoginUser(request); + SelfUserEntity loginUser = tokenService.getLoginUser(request); if(Objects.isNull(loginUser)){ ResultUtil.responseJson(response,ResultUtil.resultCode(401,"登录过期,请重新登录")); System.err.println("异常401,token信息:" + jwtToken + ",地址" + uri); @@ -79,4 +89,4 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter { //放行 filterChain.doFilter(request, response); } -} \ No newline at end of file +} diff --git a/src/main/resources/application-saas.yml b/src/main/resources/application-saas.yml index c41b2c3..e4d0901 100644 --- a/src/main/resources/application-saas.yml +++ b/src/main/resources/application-saas.yml @@ -49,6 +49,7 @@ file: upload_path: windows: D://files/zg_gqj linux: /home/zg_gqj/files + other: /Users/syruan/files diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index f4a8757..060565a 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,4 +1,4 @@ # 环境配置 spring: profiles: - active: local \ No newline at end of file + active: saas \ No newline at end of file