Преглед на файлове

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/controller/CaptchaController.java
#	huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/entity/MobileUnit.java
523096025 преди 4 години
родител
ревизия
0b8f9f78b8

+ 20 - 10
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/interceptor/JWTInterceptor.java

@@ -1,8 +1,10 @@
 package com.huimv.manager.interceptor;
 
+import com.alibaba.fastjson.JSONObject;
 import com.huimv.manager.enums.AdminTypeEnum;
 import com.huimv.manager.modular.entity.MobileUser;
 import com.huimv.manager.modular.service.MobileUserService;
+import com.huimv.manager.result.R;
 import com.huimv.manager.util.JwtUtils;
 import io.jsonwebtoken.Claims;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -34,41 +36,49 @@ public class JWTInterceptor implements HandlerInterceptor {
             return true;
         }
 
+        response.setContentType("application/json;charset=utf-8");
         // 获取token
         String token = request.getHeader("token");
         if (StringUtils.isEmpty(token)) {
-            response.sendError(419,"无token,请先登录!");
+
+            response.getWriter().write(JSONObject.toJSONString(R.error(419,"无token,请先登录!")));
+//            response.sendError(419,"无token,请先登录!");
             return false;
         }
 
         Claims claims = JwtUtils.getClaims(token);
         Integer id = claims.get("id", Integer.class);
         if (mobileUserService == null) {
-            response.sendError(500,"服务器发送错误!");
+
+            response.getWriter().write(JSONObject.toJSONString(R.error(500,"服务器发送错误!")));
+//            response.sendError(500,"服务器发送错误!");
             return false;
         }
 
         MobileUser mobileUser = mobileUserService.findById(id);
         if (mobileUser == null) {
-            response.sendError(401,"用户不存在,请先注册!");
+            response.getWriter().write(JSONObject.toJSONString(R.error(401,"用户不存在,请先注册!")));
+//            response.sendError(401,"用户不存在,请先注册!");
             return false;
         }
 
         if (!mobileUser.getGrantClass().equals(AdminTypeEnum.ADMIN.getCode())) {
-            response.sendError(401,"你不是管理员,不能进行该操作!");
+            response.getWriter().write(JSONObject.toJSONString(R.error(401,"你不是管理员,不能进行该操作!")));
+//            response.sendError(401,"你不是管理员,不能进行该操作!");
             return false;
         }
 
         int result = JwtUtils.verifyToken(claims);
         if (result >= 1) {
-            response.sendError(419,"token已失效,请重新登录!");
+            response.getWriter().write(JSONObject.toJSONString(R.error(419,"token已失效,请重新登录!")));
+//            response.sendError(419,"token已失效,请重新登录!");
             return false;
         }
-        if (result == -1) {
-            String jwtToken = JwtUtils.getJwtToken(id);
-            request.setAttribute("token",jwtToken);
-            return true;
-        }
+//        if (result == -1) {
+//            String jwtToken = JwtUtils.getJwtToken(id);
+////            response.getWriter().write(JSONObject.toJSONString(R.ok("token需要刷新").put("code",30000).put("token",jwtToken)));
+//            return true;
+//        }
         return true;
     }
 

+ 6 - 10
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/controller/CaptchaController.java

@@ -31,15 +31,11 @@ public class CaptchaController {
     @Autowired
     private RedisTemplate<String, String> redisTemplate;
 
-    //    @GetMapping("/send")
-//    @SendCode
-    public void getCaptcha(HttpServletRequest request) {
-
-
-//        log.info(code);
-        String remoteHost = request.getRemoteHost();
-    }
-
+    /**
+     * 获取验证码
+     * @param request
+     * @param response
+     */
     @GetMapping("/send")
     public void createImg(HttpServletRequest request, HttpServletResponse response)  {
         try {
@@ -61,4 +57,4 @@ public class CaptchaController {
             throw new RRException("获取验证码失败!");
         }
     }
-}
+}

+ 0 - 1
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/controller/MobileUserManageController.java

@@ -21,7 +21,6 @@ import org.springframework.web.bind.annotation.RestController;
 @RequestMapping("/UserManage")
 public class MobileUserManageController {
 
-
     @Autowired
     private MobileUserService service;
 

+ 2 - 1
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/entity/MobileUnit.java

@@ -42,8 +42,9 @@ public class MobileUnit implements Serializable {
     /**
      * 接口名称
      */
-    @ApiModelProperty("接口名称")
     @Column(name = "api")
+    @ApiModelProperty("接口名称")
     private String api;
 
+
 }

+ 1 - 0
huimv-mobile-video/huimv-manager/src/main/java/com/huimv/manager/modular/service/impl/MobileUnitServiceImpl.java

@@ -46,6 +46,7 @@ public class MobileUnitServiceImpl implements MobileUnitService {
         entity.setFullName(mobileUnit.getFullName());
         entity.setShortName(mobileUnit.getShortName());
         entity.setRemark(mobileUnit.getRemark());
+        entity.setApi(mobileUnit.getApi());
 
         if (isAdd) {
             mobileUnitRepository.saveAndFlush(entity);