From 7ec4578eb3d39fbaf7a70d4f78b73fc1279ba886 Mon Sep 17 00:00:00 2001 From: tiansh Date: Thu, 25 Mar 2021 09:23:51 +0800 Subject: [PATCH] =?UTF-8?q?2021-03-25=E6=9B=B4=E6=96=B0=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=89=93=E5=8D=B0=E7=9B=B8=E5=85=B3=E6=97=A5=E5=BF=97=20?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8=E6=B3=A8=E9=87=8A=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/hellohao/config/WebMvcConfigurer.java | 4 +-- .../hellohao/controller/GroupController.java | 13 +-------- .../interceptor/InterceptorConfig.java | 28 +------------------ .../cn/hellohao/interceptor/WebAppConfig.java | 2 -- 4 files changed, 3 insertions(+), 44 deletions(-) diff --git a/src/main/java/cn/hellohao/config/WebMvcConfigurer.java b/src/main/java/cn/hellohao/config/WebMvcConfigurer.java index f6fa29e..da698b6 100644 --- a/src/main/java/cn/hellohao/config/WebMvcConfigurer.java +++ b/src/main/java/cn/hellohao/config/WebMvcConfigurer.java @@ -12,9 +12,7 @@ public class WebMvcConfigurer extends WebMvcConfigurerAdapter { @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { String filePath =File.separator + "HellohaoData" + File.separator; - //和页面有关的静态目录都放在项目的static目录下 - //registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/"); - //上传的图片在D盘下的OTA目录下,访问路径如:http://localhost:8081/OTA/d3cf0281-bb7f-40e0-ab77-406db95ccf2c.jpg + System.out.println(filePath); //其中OTA表示访问的前缀。"file:D:/OTA/"是文件真实的存储路径 //registry.addResourceHandler("/test/**").addResourceLocations("file:C:/test/"); registry.addResourceHandler("/links/**").addResourceLocations("file:"+filePath); diff --git a/src/main/java/cn/hellohao/controller/GroupController.java b/src/main/java/cn/hellohao/controller/GroupController.java index a679790..6ee3fab 100644 --- a/src/main/java/cn/hellohao/controller/GroupController.java +++ b/src/main/java/cn/hellohao/controller/GroupController.java @@ -72,19 +72,8 @@ public class GroupController { @RequestMapping(value = "/addisgroup") @ResponseBody public Integer addisgroup(Group group) { - //boolean b =false; - //if(group.getKeyid()==5){ - // b =true; - //}else{ - //Keys key = keysService.selectKeys(group.getKeyid()); - //b = StringUtils.doNull(group.getKeyid(),key); - //} Integer ret = 0; - //if(b){ - ret = groupService.addgroup(group); - //}else{ - // ret = -1; - //} + ret = groupService.addgroup(group); return ret; } @RequestMapping(value = "/delegroup") diff --git a/src/main/java/cn/hellohao/interceptor/InterceptorConfig.java b/src/main/java/cn/hellohao/interceptor/InterceptorConfig.java index 04453f1..bde5d08 100644 --- a/src/main/java/cn/hellohao/interceptor/InterceptorConfig.java +++ b/src/main/java/cn/hellohao/interceptor/InterceptorConfig.java @@ -25,7 +25,6 @@ import org.springframework.web.servlet.ModelAndView; @Component public class InterceptorConfig implements HandlerInterceptor { - //private static final Logger log = LoggerFactory.getLogger(InterceptorConfig.class); /** * 进入controller层之前拦截请求 @@ -33,32 +32,7 @@ public class InterceptorConfig implements HandlerInterceptor { //这个方法是在访问接口之前执行的,我们只需要在这里写验证登陆状态的业务逻辑,就可以在用户调用指定接口之前验证登陆状态了 public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { UserServiceImpl userService = SpringContextHolder.getBean(UserServiceImpl.class); - HttpSession session = request.getSession(); - //这里的User是登陆时放入session的 -// User user = (User) session.getAttribute("user"); -// if(user==null){ -// Cookie[] cookies = request.getCookies(); -// String Hellohao_UniqueUserKey = ""; -// for (Cookie cookie : cookies) { -// if(cookie.getName().equals("Hellohao_UniqueUserKey") && Hellohao_UniqueUserKey.equals("")){ -// Hellohao_UniqueUserKey = URLDecoder.decode(cookie.getValue(), "GBK"); -// } -// } -// -// if(Hellohao_UniqueUserKey!=null && !Hellohao_UniqueUserKey.equals("")){ -// //String basepass = Base64Encryption.encryptBASE64(pass.getBytes()); -// Integer ret = userService.login(null, null,Hellohao_UniqueUserKey); -// if (ret > 0) { -// User u = userService.getUsersMail(Hellohao_UniqueUserKey); -// if (u.getIsok() == 1) { -// session.setAttribute("user", u); -// session.setAttribute("email", u.getEmail()); -// //request.getRequestDispatcher("/admin/goadmin").forward(request, response); -// } -// } -// } -// -// } + HttpSession session = request.getSession(); User suser = (User) session.getAttribute("user"); String email = null; Integer level = 0; diff --git a/src/main/java/cn/hellohao/interceptor/WebAppConfig.java b/src/main/java/cn/hellohao/interceptor/WebAppConfig.java index 8375495..f736539 100644 --- a/src/main/java/cn/hellohao/interceptor/WebAppConfig.java +++ b/src/main/java/cn/hellohao/interceptor/WebAppConfig.java @@ -6,8 +6,6 @@ import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; @Configuration