wuheng 1 year ago
parent
commit
ceea5c5139

+ 6 - 4
service/src/main/java/com/koobietech/eas/service/impl/EasSysAdminLoginServiceImpl.java

@@ -31,9 +31,8 @@ import org.springframework.stereotype.Service;
 import org.springframework.util.ObjectUtils;
 
 import javax.annotation.Resource;
-import java.io.File;
-import java.io.FileInputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.List;
@@ -88,8 +87,11 @@ public class EasSysAdminLoginServiceImpl implements EasSysAdminLoginService {
         List<DepartmentPojo> departments = userDetailPojoInRedis.getDepartments();
 
         //权限配置文件
-        String absolutePath = new File(jsonFilePath).getAbsolutePath();
-        FileInputStream archiveFile = fileManager.getArchiveFile(absolutePath);
+//        String absolutePath = new File(jsonFilePath).getAbsolutePath();
+//        FileInputStream archiveFile = fileManager.getArchiveFile(absolutePath);
+        String absolutePath = "temp/authority.json";
+        InputStream archiveFile = getClass().getClassLoader().getResourceAsStream(absolutePath);
+
         String jsonStr = "";
         try {
             jsonStr = IOUtils.toString(archiveFile, "UTF-8");

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

@@ -1,7 +1,6 @@
 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;
@@ -26,12 +25,10 @@ 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;
@@ -91,36 +88,15 @@ public class EasSysStudentLoginServiceImpl implements EasSysStudentLoginService
         //权限配置文件
         //String absolutePath = new File(jsonFilePath).getAbsolutePath();
         //FileInputStream archiveFile = fileManager.getArchiveFile(absolutePath);
-
-
         String absolutePath = "temp/authority.json";
-        URL resource = Resources.getResource(absolutePath);
-
-
+        InputStream archiveFile = getClass().getClassLoader().getResourceAsStream(absolutePath);
 
-        FileInputStream archiveFile = null;
         String jsonStr = "";
         try {
-            archiveFile = new FileInputStream(resource.getFile());
-
-            System.out.println( "archiveFile" );
-            System.out.println( archiveFile );
-
             jsonStr = IOUtils.toString(archiveFile, "UTF-8");
-        } catch (FileNotFoundException e) {
-            e.printStackTrace();
-        } catch (IOException e) {
-            e.printStackTrace();
-        } finally {
+        } catch (IOException ignored) {} 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) {