wangliang@qmth.com.cn 5 éve
szülő
commit
5d9ac4234c

+ 8 - 8
themis-backend/src/main/java/com/qmth/themis/backend/interceptor/AuthInterceptor.java

@@ -57,14 +57,6 @@ public class AuthInterceptor implements HandlerInterceptor {
         log.info("backend HandlerInterceptor preHandle is come in");
         String url = request.getServletPath();
         String method = request.getMethod();
-        Platform platform = Platform.valueOf(ServletUtil.getRequestPlatform());
-        String deviceId = ServletUtil.getRequestDeviceId();
-        if (Objects.isNull(platform) || Objects.equals(platform, "")) {
-            throw new BusinessException(ExceptionResultEnum.PLATFORM_INVALID);
-        }
-        if (Objects.isNull(deviceId) || Objects.equals(deviceId, "")) {
-            throw new BusinessException(ExceptionResultEnum.DEVICE_ID_INVALID);
-        }
         if (url.equalsIgnoreCase(SystemConstant.ERROR)) {
             if (response.getStatus() == HttpStatus.HTTP_NOT_FOUND) {
                 throw new BusinessException(ExceptionResultEnum.NOT_FOUND);
@@ -74,6 +66,14 @@ public class AuthInterceptor implements HandlerInterceptor {
                 throw new BusinessException(ExceptionResultEnum.EXCEPTION_ERROR);
             }
         }
+        Platform platform = Platform.valueOf(ServletUtil.getRequestPlatform());
+        String deviceId = ServletUtil.getRequestDeviceId();
+        if (Objects.isNull(platform) || Objects.equals(platform, "")) {
+            throw new BusinessException(ExceptionResultEnum.PLATFORM_INVALID);
+        }
+        if (Objects.isNull(deviceId) || Objects.equals(deviceId, "")) {
+            throw new BusinessException(ExceptionResultEnum.DEVICE_ID_INVALID);
+        }
         Long userId = null;
 //        Long timestamp = Long.parseLong(ServletUtil.getRequestTime(request));
 //        if (!SystemConstant.expire(timestamp.longValue())) {

+ 2 - 0
themis-business/src/main/java/com/qmth/themis/business/constant/SystemConstant.java

@@ -68,6 +68,8 @@ public class SystemConstant {
     public static final String USER_DIR = "user.dir";
     public static final int MAX_IMPORT_SIZE = 500;
     public static final int MAX_EXPORT_SIZE = 500;
+    public static final String EXCEL_PREFIX = ".xlsx";
+    public static final String TXT_PREFIX = ".txt";
     /**
      * session过期时间
      */

+ 2 - 2
themis-business/src/main/java/com/qmth/themis/business/templete/TaskExportCommon.java

@@ -84,7 +84,7 @@ public class TaskExportCommon {
                 .add(File.separator).add(String.valueOf(nowTime.getMonthValue()))
                 .add(File.separator).add(String.valueOf(nowTime.getDayOfMonth()));
         File file = new File(stringJoiner.add(File.separator).add(String.valueOf(UUID.randomUUID()).replaceAll("-", ""))
-                .add(".xlsx").toString());
+                .add(SystemConstant.EXCEL_PREFIX).toString());
         if (!file.exists()) {
             file.getParentFile().mkdirs();
             file.createNewFile();
@@ -131,7 +131,7 @@ public class TaskExportCommon {
         FileWriter fileWriter = null;
         try {
             path = path.substring(0, path.lastIndexOf(File.separator) + 1);
-            File file = new File(path + String.valueOf(UUID.randomUUID()).replaceAll("-", "") + ".txt");
+            File file = new File(path + String.valueOf(UUID.randomUUID()).replaceAll("-", "") + SystemConstant.TXT_PREFIX);
             if (!file.exists()) {
                 file.getParentFile().mkdirs();
                 file.createNewFile();

+ 1 - 1
themis-business/src/main/java/com/qmth/themis/business/templete/TaskImportCommon.java

@@ -109,7 +109,7 @@ public class TaskImportCommon {
         FileWriter fileWriter = null;
         try {
             this.path = this.path.substring(0, this.path.lastIndexOf(File.separator) + 1);
-            File file = new File(this.path + String.valueOf(UUID.randomUUID()).replaceAll("-", "") + ".txt");
+            File file = new File(this.path + String.valueOf(UUID.randomUUID()).replaceAll("-", "") + SystemConstant.TXT_PREFIX);
             if (!file.exists()) {
                 file.createNewFile();
             }

+ 8 - 8
themis-exam/src/main/java/com/qmth/themis/exam/interceptor/AuthInterceptor.java

@@ -59,14 +59,6 @@ public class AuthInterceptor implements HandlerInterceptor {
         log.info("exam HandlerInterceptor preHandle is come in");
         String url = request.getServletPath();
         String method = request.getMethod();
-        Platform platform = Platform.valueOf(ServletUtil.getRequestPlatform());
-        String deviceId = ServletUtil.getRequestDeviceId();
-        if (Objects.isNull(platform) || Objects.equals(platform, "")) {
-            throw new BusinessException(ExceptionResultEnum.PLATFORM_INVALID);
-        }
-        if (Objects.isNull(deviceId) || Objects.equals(deviceId, "")) {
-            throw new BusinessException(ExceptionResultEnum.DEVICE_ID_INVALID);
-        }
         if (url.equalsIgnoreCase(SystemConstant.ERROR)) {
             if (response.getStatus() == HttpStatus.HTTP_NOT_FOUND) {
                 throw new BusinessException(ExceptionResultEnum.NOT_FOUND);
@@ -76,6 +68,14 @@ public class AuthInterceptor implements HandlerInterceptor {
                 throw new BusinessException(ExceptionResultEnum.EXCEPTION_ERROR);
             }
         }
+        Platform platform = Platform.valueOf(ServletUtil.getRequestPlatform());
+        String deviceId = ServletUtil.getRequestDeviceId();
+        if (Objects.isNull(platform) || Objects.equals(platform, "")) {
+            throw new BusinessException(ExceptionResultEnum.PLATFORM_INVALID);
+        }
+        if (Objects.isNull(deviceId) || Objects.equals(deviceId, "")) {
+            throw new BusinessException(ExceptionResultEnum.DEVICE_ID_INVALID);
+        }
         Long userId = null;
 //        Long timestamp = Long.parseLong(ServletUtil.getRequestTime(request));
 //        if (!SystemConstant.expire(timestamp.longValue())) {

+ 2 - 2
themis-exam/src/main/java/com/qmth/themis/exam/websocket/WebSocketServer.java

@@ -20,7 +20,7 @@ import java.util.concurrent.ConcurrentHashMap;
  * @Author: wangliang
  * @Date: 2020/7/10
  */
-@ServerEndpoint("/imserver/{userId}")
+@ServerEndpoint("/oe/{platform}/{deviceId}/{Authorization}/{time}")
 @Component
 public class WebSocketServer
 //        implements MessageListenerConcurrently
@@ -47,7 +47,7 @@ public class WebSocketServer
      * 连接建立成功调用的方法
      */
     @OnOpen
-    public void onOpen(Session session, @PathParam("userId") String userId) {
+    public void onOpen(Session session, @PathParam("platform") String platform, @PathParam("deviceId") String deviceI, @PathParam("Authorization") String Authorization, @PathParam("time") Long time) {
         this.session = session;
         this.userId = userId;
         if (webSocketMap.containsKey(userId)) {