Browse Source

更新小程序接口

chenyi406 3 years ago
parent
commit
8741788d0b

+ 6 - 5
src/main/java/com/zy/bms/config/InterceptorCfg.java

@@ -1,7 +1,7 @@
 package com.zy.bms.config;
 
 import com.zy.bms.config.interceptor.OperateAuthInterceptor;
-import com.zy.bms.config.interceptor.UbiAppAuthInterceptor;
+import com.zy.bms.config.interceptor.WxAppAuthInterceptor;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Profile;
 import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
@@ -22,7 +22,7 @@ import java.util.List;
 public class InterceptorCfg implements WebMvcConfigurer {
 
     @Resource
-    private UbiAppAuthInterceptor ubiAppAuthInterceptor;
+    private WxAppAuthInterceptor wxAppAuthInterceptor;
     @Resource
     private OperateAuthInterceptor operateAuthInterceptor;
     // 白名单
@@ -30,7 +30,7 @@ public class InterceptorCfg implements WebMvcConfigurer {
 
     static {
         whiteList.add("/bms/api/operate/admin/login.do");
-        whiteList.add("/bms/api/operate/user/login.do");
+        whiteList.add("/bms/api/wx_app/login.do");
     }
 
     /**
@@ -38,8 +38,9 @@ public class InterceptorCfg implements WebMvcConfigurer {
      */
     @Override
     public void addInterceptors(InterceptorRegistry registry) {
-        registry.addInterceptor(ubiAppAuthInterceptor)
-                .addPathPatterns("/bms/api/wx_app/**");
+        registry.addInterceptor(wxAppAuthInterceptor)
+                .addPathPatterns("/bms/api/wx_app/**")
+                .excludePathPatterns(whiteList);
 
         registry.addInterceptor(operateAuthInterceptor)
                 .addPathPatterns("/bms/api/operate/**")

+ 2 - 2
src/main/java/com/zy/bms/config/interceptor/UbiAppAuthInterceptor.java → src/main/java/com/zy/bms/config/interceptor/WxAppAuthInterceptor.java

@@ -14,12 +14,12 @@ import javax.servlet.http.HttpServletResponse;
  * Create on 2019/10/10
  */
 @Component
-public class UbiAppAuthInterceptor extends HandlerInterceptorAdapter {
+public class WxAppAuthInterceptor extends HandlerInterceptorAdapter {
 
     @Override
     public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
         String channel = request.getHeader("channel");
-        if (channel.equals("wx-app") && request.getHeader("app_user") != null) return true;
+        if (channel.equals("wx-app") && request.getHeader("appUser") != null) return true;
         request.getRequestDispatcher("/bms/api/common/author.do").forward(request, response);
         return false;
     }

+ 3 - 4
src/main/java/com/zy/bms/controller/BaseController.java

@@ -34,9 +34,8 @@ public class BaseController {
      * 获取微信小程序登录User
      */
     public Integer userId() {
-//        String userId = AesUtil.decrypt(request.getHeader("app_user"));
-//        if (userId == null) throw new ApiRuntimeException("用户ID解析失败!");
-//        return Integer.parseInt(userId);
-        return 1;
+        String userId = AesUtil.decrypt(request.getHeader("appUser"));
+        if (userId == null) throw new ApiRuntimeException("用户ID解析失败!");
+        return Integer.parseInt(userId);
     }
 }

+ 1 - 0
src/main/java/com/zy/bms/controller/UbiLpWxController.java

@@ -61,6 +61,7 @@ public class UbiLpWxController extends BaseController {
             user = new User();
             user.setOpenId(openId);
             user.setRandomCode(RandomCode.UUID_8());
+            user.setAdmin(0);
             userService.save(user);
         }
         Map<String, String> res = new HashMap<>();