修正配置

This commit is contained in:
syruan 2025-12-04 10:01:26 +08:00
parent d3f13e7cd8
commit 5076b8b010
4 changed files with 26 additions and 8 deletions

View File

@ -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;
}
}
}

View File

@ -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("异常401token信息:" + 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("异常401token信息:" + jwtToken + ",地址" + uri);
@ -79,4 +89,4 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter {
//放行
filterChain.doFilter(request, response);
}
}
}

View File

@ -49,6 +49,7 @@ file:
upload_path:
windows: D://files/zg_gqj
linux: /home/zg_gqj/files
other: /Users/syruan/files

View File

@ -1,4 +1,4 @@
# 环境配置
spring:
profiles:
active: local
active: saas