| | |
| | | |
| | | 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; |
| | |
| | | // 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)){ |
| | |
| | | } |
| | | } |
| | | |
| | | @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"); |
| | | UserLogin userLogin = userLoginService.selectOne(new EntityWrapper<UserLogin>().eq("token", token)); |
| | | UserLogin userLogin = userLoginService.selectOne(new EntityWrapper<UserLogin>().eq("token", token).eq("system", "WMS")); |
| | | if (null == userLogin){ |
| | | Http.response(response, BaseRes.DENIED); |
| | | return false; |
| | |
| | | // String deToken = Cools.deTokn(token, user.getPassword()); |
| | | // long timestamp = Long.parseLong(deToken.substring(0, 13)); |
| | | // 15分钟后过期 |
| | | if (System.currentTimeMillis() - userLogin.getCreateTime().getTime() > 900000){ |
| | | if (System.currentTimeMillis() - userLogin.getCreateTime().getTime() > 86400000){ |
| | | Http.response(response, BaseRes.DENIED); |
| | | return false; |
| | | } |