wuheng 1 年之前
父節點
當前提交
f991ed777d

+ 19 - 3
service/src/main/java/com/koobietech/eas/service/impl/EasSysStudentLoginServiceImpl.java

@@ -1,6 +1,7 @@
 package com.koobietech.eas.service.impl;
 
 import com.alibaba.fastjson2.JSON;
+import com.google.common.io.Resources;
 import com.koobietech.eas.common.exception.EasException;
 import com.koobietech.eas.common.pojo.JwtUserPojo;
 import com.koobietech.eas.common.utils.FileManager;
@@ -25,10 +26,12 @@ import org.springframework.security.crypto.password.PasswordEncoder;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
 import java.io.IOException;
-import java.io.InputStream;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.net.URL;
 import java.util.List;
 import java.util.Objects;
 import java.util.Optional;
@@ -89,13 +92,26 @@ public class EasSysStudentLoginServiceImpl implements EasSysStudentLoginService
         //String absolutePath = new File(jsonFilePath).getAbsolutePath();
         //FileInputStream archiveFile = fileManager.getArchiveFile(absolutePath);
         String absolutePath = "temp/authority.json";
-        InputStream archiveFile = this.getClass().getClassLoader().getResourceAsStream(absolutePath);
+        URL resource = Resources.getResource(absolutePath);
+        FileInputStream archiveFile = null;
         String jsonStr = "";
         try {
+            archiveFile = new FileInputStream(resource.getFile());
             jsonStr = IOUtils.toString(archiveFile, "UTF-8");
-        } catch (IOException ignored) {} finally {
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
             IOUtils.closeQuietly(archiveFile);
         }
+        //InputStream archiveFile = this.getClass().getClassLoader().getResourceAsStream(absolutePath);
+
+//        try {
+//            jsonStr = IOUtils.toString(archiveFile, "UTF-8");
+//        } catch (IOException ignored) {} finally {
+//            IOUtils.closeQuietly(archiveFile);
+//        }
 
         EasAuthorityConfig easAuthorityConfig = JSON.parseObject(jsonStr, EasAuthorityConfig.class);
         if (easAuthorityConfig == null) {