|
@@ -1,9 +1,11 @@
|
|
|
package com.koobietech.eas.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson2.JSON;
|
|
|
import com.anji.captcha.model.common.ResponseModel;
|
|
|
import com.koobietech.eas.common.exception.EasException;
|
|
|
import com.koobietech.eas.common.pojo.JwtUserPojo;
|
|
|
import com.koobietech.eas.common.result.JsonResult;
|
|
|
+import com.koobietech.eas.common.utils.FileManager;
|
|
|
import com.koobietech.eas.common.utils.JwtManager;
|
|
|
import com.koobietech.eas.common.utils.PasswordManager;
|
|
|
import com.koobietech.eas.dao.constant.UserType;
|
|
@@ -18,10 +20,15 @@ import com.koobietech.eas.mbg.model.EasSysUserinfoExample;
|
|
|
import com.koobietech.eas.service.EasSysAdminLoginService;
|
|
|
import com.koobietech.eas.service.EasSysUserLoginRedisService;
|
|
|
import com.koobietech.eas.service.config.EasAuthorityConfig;
|
|
|
+import org.apache.commons.io.IOUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileInputStream;
|
|
|
+import java.io.IOException;
|
|
|
import java.lang.reflect.InvocationTargetException;
|
|
|
import java.lang.reflect.Method;
|
|
|
import java.util.List;
|
|
@@ -41,9 +48,12 @@ public class EasSysAdminLoginServiceImpl implements EasSysAdminLoginService {
|
|
|
@Resource
|
|
|
private EasSysUserLoginRedisService loginRedisService;
|
|
|
@Resource
|
|
|
- private EasAuthorityConfig easAuthorityConfig;
|
|
|
- @Resource
|
|
|
private JwtManager jwtManager;
|
|
|
+ @Resource
|
|
|
+ FileManager fileManager;
|
|
|
+
|
|
|
+ @Value("${authority.path}")
|
|
|
+ String jsonFilePath;
|
|
|
|
|
|
// token过期时间 单位:s
|
|
|
private final Integer token_expires = 24 * 60 * 60;
|
|
@@ -66,6 +76,19 @@ public class EasSysAdminLoginServiceImpl implements EasSysAdminLoginService {
|
|
|
|
|
|
userDetailPojoInRedis.setDepartments(adminLoginMapper.getUserDepartmentsById(id));
|
|
|
List<DepartmentPojo> departments = userDetailPojoInRedis.getDepartments();
|
|
|
+
|
|
|
+ //权限配置文件
|
|
|
+ String absolutePath = new File(jsonFilePath).getAbsolutePath();
|
|
|
+ FileInputStream archiveFile = fileManager.getArchiveFile(absolutePath);
|
|
|
+ String jsonStr = "";
|
|
|
+ try {
|
|
|
+ jsonStr = IOUtils.toString(archiveFile, "UTF-8");
|
|
|
+ } catch (IOException ignored) {}
|
|
|
+
|
|
|
+ EasAuthorityConfig easAuthorityConfig = JSON.parseObject(jsonStr, EasAuthorityConfig.class);
|
|
|
+ if (easAuthorityConfig == null) {
|
|
|
+ throw new EasException("权限配置文件不存在", 412);
|
|
|
+ }
|
|
|
departments.forEach(departmentPojo -> {
|
|
|
try {
|
|
|
String authority = departmentPojo.getAuthority();
|