From 27656ef3f1b0f46b1a76e3a9a6e00175c6d1c8a7 Mon Sep 17 00:00:00 2001 From: zjj <3272660260@qq.com> Date: 星期一, 04 十一月 2024 13:30:43 +0800 Subject: [PATCH] # --- src/main/java/com/zy/common/config/AdminInterceptor.java | 42 +++++++++++++++++++++++++++++++++++------- 1 files changed, 35 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/zy/common/config/AdminInterceptor.java b/src/main/java/com/zy/common/config/AdminInterceptor.java index 37a863d..547ba96 100644 --- a/src/main/java/com/zy/common/config/AdminInterceptor.java +++ b/src/main/java/com/zy/common/config/AdminInterceptor.java @@ -2,9 +2,11 @@ import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.core.annotations.AppAuth; import com.core.annotations.ManagerAuth; import com.core.common.BaseRes; import com.core.common.Cools; +import com.zy.common.properties.SystemProperties; import com.zy.common.utils.Http; import com.zy.system.entity.*; import com.zy.system.service.*; @@ -63,10 +65,21 @@ } } } + // 鐧藉悕鍗� +// if (IpTools.gainRealIp(request).equals("127.0.0.1")) { +// request.setAttribute("userId", 9527); +// return true; +// } // 璺ㄥ煙璁剧疆 // response.setHeader("Access-Control-Allow-Origin", "*"); HandlerMethod handlerMethod = (HandlerMethod) handler; Method method = handlerMethod.getMethod(); + if (method.isAnnotationPresent(AppAuth.class)){ + AppAuth annotation = method.getAnnotation(AppAuth.class); + if (annotation.value().equals(AppAuth.Auth.CHECK)){ + request.setAttribute("appAuth", annotation.memo()); + } + } if (method.isAnnotationPresent(ManagerAuth.class)){ ManagerAuth annotation = method.getAnnotation(ManagerAuth.class); if (annotation.value().equals(ManagerAuth.Auth.CHECK)){ @@ -86,9 +99,18 @@ } } + @Override + public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, @Nullable Exception ex) throws Exception { +// Object r = request.getAttribute("cool-response"); + } + private boolean check(HttpServletRequest request, HttpServletResponse response, String memo) { try { - String token = request.getHeader("token"); + String token = new String(); + token = request.getHeader("token"); + if (Cools.isEmpty(token)){ + return true; + } UserLogin userLogin = userLoginService.selectOne(new EntityWrapper<UserLogin>().eq("token", token)); if (null == userLogin){ Http.response(response, BaseRes.DENIED); @@ -114,12 +136,18 @@ userLoginService.updateById(userLogin); // 鎿嶄綔鏃ュ織 if (!Cools.isEmpty(memo)) { - OperateLog operateLog = new OperateLog(); - operateLog.setAction(Cools.isEmpty(memo)?request.getRequestURI():memo); - operateLog.setIp(request.getRemoteAddr()); - operateLog.setUserId(user.getId()); - operateLog.setRequest(JSON.toJSONString(request.getParameterMap())); - request.setAttribute("operateLog", operateLog); + // 杩涜婵�娲诲垽鏂� + if (!SystemProperties.SYSTEM_ACTIVATION) { + Http.response(response, BaseRes.NO_ACTIVATION); + return false; + } +// // 璁板綍鎿嶄綔鏃ュ織 +// OperateLog operateLog = new OperateLog(); +// operateLog.setAction(Cools.isEmpty(memo)?request.getRequestURI():memo); +// operateLog.setIp(request.getRemoteAddr()); +// operateLog.setUserId(user.getId()); +// operateLog.setRequest(JSON.toJSONString(request.getParameterMap())); +// request.setAttribute("operateLog", operateLog); } return true; } catch (Exception e){ -- Gitblit v1.9.1