diff --git a/magic-boot/pom.xml b/magic-boot/pom.xml
index c1dc6b7..76ed6a7 100644
--- a/magic-boot/pom.xml
+++ b/magic-boot/pom.xml
@@ -5,20 +5,21 @@
org.ssssssss
magic-boot-parent
- 0.0.1
+ 0.0.2
org.ssssssss
magic-boot
- 0.0.1
+ 0.0.2
magic-boot
magic-boot
- 1.8
+ 17
2.0.2
1.1.10
5.7.22
- 1.26.0
+ 1.34.0
4.1.2
+ 8.0.32
@@ -37,6 +38,7 @@
mysql
mysql-connector-java
+ ${mysql.connector.version}
com.alibaba
@@ -50,7 +52,7 @@
cn.dev33
- sa-token-spring-boot-starter
+ sa-token-spring-boot3-starter
${sa-token.version}
diff --git a/magic-boot/src/main/java/org/ssssssss/magicboot/extension/ResponseFunctionExtension.java b/magic-boot/src/main/java/org/ssssssss/magicboot/extension/ResponseFunctionExtension.java
index fbbf370..f7c68f0 100644
--- a/magic-boot/src/main/java/org/ssssssss/magicboot/extension/ResponseFunctionExtension.java
+++ b/magic-boot/src/main/java/org/ssssssss/magicboot/extension/ResponseFunctionExtension.java
@@ -1,17 +1,17 @@
package org.ssssssss.magicboot.extension;
+import jakarta.servlet.ServletException;
+import jakarta.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.ssssssss.magicapi.core.context.RequestContext;
+import org.ssssssss.magicapi.core.servlet.MagicHttpServletRequest;
import org.ssssssss.magicapi.modules.servlet.ResponseModule;
import org.ssssssss.script.annotation.Comment;
import org.ssssssss.script.functions.ExtensionMethod;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@Component
@@ -32,8 +32,8 @@ public class ResponseFunctionExtension implements ExtensionMethod {
@Comment("转发")
public ResponseModule.NullValue dispatcher(ResponseModule responseModule, String url) throws ServletException, IOException {
- HttpServletRequest request = RequestContext.getHttpServletRequest();
- request.getRequestDispatcher(url).forward(request, getResponse());
+ MagicHttpServletRequest request = RequestContext.getHttpServletRequest();
+// request.getRequestDispatcher(url).forward(request, getResponse());
return responseModule.end();
}
diff --git a/magic-boot/src/main/java/org/ssssssss/magicboot/interceptor/PermissionInterceptor.java b/magic-boot/src/main/java/org/ssssssss/magicboot/interceptor/PermissionInterceptor.java
index 70c8a11..a809e71 100644
--- a/magic-boot/src/main/java/org/ssssssss/magicboot/interceptor/PermissionInterceptor.java
+++ b/magic-boot/src/main/java/org/ssssssss/magicboot/interceptor/PermissionInterceptor.java
@@ -1,7 +1,10 @@
package org.ssssssss.magicboot.interceptor;
import cn.dev33.satoken.stp.StpUtil;
+import cn.hutool.core.util.ArrayUtil;
import cn.hutool.extra.servlet.ServletUtil;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
@@ -14,12 +17,12 @@ import org.ssssssss.magicapi.core.model.ApiInfo;
import org.ssssssss.magicapi.core.model.Options;
import org.ssssssss.magicapi.core.service.MagicAPIService;
import org.ssssssss.magicapi.core.service.MagicResourceService;
+import org.ssssssss.magicapi.core.servlet.MagicHttpServletRequest;
+import org.ssssssss.magicapi.core.servlet.MagicHttpServletResponse;
import org.ssssssss.magicapi.utils.PathUtils;
import org.ssssssss.magicboot.model.StatusCode;
import org.ssssssss.script.MagicScriptContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@@ -38,11 +41,12 @@ public class PermissionInterceptor implements RequestInterceptor, HandlerInterce
@Autowired
private JdbcTemplate template;
+
/*
* 当返回对象时,直接将此对象返回到页面,返回null时,继续执行后续操作
*/
@Override
- public Object preHandle(ApiInfo info, MagicScriptContext context, HttpServletRequest request, HttpServletResponse response) {
+ public Object preHandle(ApiInfo info, MagicScriptContext context, MagicHttpServletRequest request, MagicHttpServletResponse response) throws Exception {
String requireLogin = Objects.toString(info.getOptionValue(Options.REQUIRE_LOGIN), "");
if(requireLogin.equals("false")){
return null;
@@ -60,11 +64,12 @@ public class PermissionInterceptor implements RequestInterceptor, HandlerInterce
return null;
}
+
@Override
public Object postHandle(RequestEntity requestEntity, Object returnValue) throws Exception {
if(StpUtil.isLogin()){
try {
- HttpServletRequest request = requestEntity.getRequest();
+ MagicHttpServletRequest request = requestEntity.getRequest();
ApiInfo info = requestEntity.getApiInfo();
template.update("insert into sys_oper_log(api_name, api_path, api_method, cost_time, create_by, create_date, user_agent, user_ip) values(?,?,?,?,?,?,?,?)",
// PathUtils.replaceSlash(groupServiceProvider.getFullName(info.getGroupId()) + "/" + info.getName()).replace("/","-"),
@@ -75,7 +80,7 @@ public class PermissionInterceptor implements RequestInterceptor, HandlerInterce
StpUtil.getLoginId(),
new Date(requestEntity.getRequestTime()),
request.getHeader("User-Agent"),
- ServletUtil.getClientIP(request));
+ request.getRemoteAddr());
} catch (Exception ignored){
ignored.printStackTrace();
}
diff --git a/magic-boot/src/main/java/org/ssssssss/magicboot/provider/ExceptionResultProvider.java b/magic-boot/src/main/java/org/ssssssss/magicboot/provider/ExceptionResultProvider.java
index f5f17f2..567bd8f 100644
--- a/magic-boot/src/main/java/org/ssssssss/magicboot/provider/ExceptionResultProvider.java
+++ b/magic-boot/src/main/java/org/ssssssss/magicboot/provider/ExceptionResultProvider.java
@@ -1,6 +1,6 @@
package org.ssssssss.magicboot.provider;
-import cn.dev33.satoken.exception.DisableLoginException;
+import cn.dev33.satoken.exception.DisableServiceException;
import org.springframework.stereotype.Component;
import org.ssssssss.magicapi.core.context.RequestEntity;
import org.ssssssss.magicapi.core.interceptor.ResultProvider;
@@ -17,7 +17,7 @@ public class ExceptionResultProvider implements ResultProvider {
@Override
public Object buildException(RequestEntity requestEntity, Throwable throwable) {
- if(throwable.getCause() instanceof DisableLoginException){
+ if(throwable.getCause() instanceof DisableServiceException){
return buildResult(requestEntity, 500, "此账号已被临时封禁,请联系管理员");
}
return buildResult(requestEntity, 500, "系统内部出现错误");
diff --git a/magic-boot/src/main/java/org/ssssssss/magicboot/utils/WebUtils.java b/magic-boot/src/main/java/org/ssssssss/magicboot/utils/WebUtils.java
index 7e98059..73829f3 100644
--- a/magic-boot/src/main/java/org/ssssssss/magicboot/utils/WebUtils.java
+++ b/magic-boot/src/main/java/org/ssssssss/magicboot/utils/WebUtils.java
@@ -1,10 +1,10 @@
package org.ssssssss.magicboot.utils;
+import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.ssssssss.magicboot.model.Global;
-import javax.servlet.http.HttpServletRequest;
public class WebUtils {
diff --git a/pom.xml b/pom.xml
index 338bcaf..fd90c38 100644
--- a/pom.xml
+++ b/pom.xml
@@ -11,13 +11,13 @@
org.springframework.boot
spring-boot-starter-parent
- 2.4.5
+ 3.0.4
org.ssssssss
magic-boot-parent
- 0.0.1
+ 0.0.2
magic-boot-parent
magic-boot-parent