Browse Source

优化-去掉redis

xiaof 2 years ago
parent
commit
8241415f67
35 changed files with 215 additions and 1679 deletions
  1. 1 2
      paper-library-business/src/main/java/com/qmth/paper/library/business/bean/result/CustomPrivilegeResult.java
  2. 1 17
      paper-library-business/src/main/java/com/qmth/paper/library/business/bean/result/TSchoolPrivilegeResult.java
  3. 0 7
      paper-library-business/src/main/java/com/qmth/paper/library/business/service/impl/PaperLibraryCommonServiceImpl.java
  4. 3 4
      paper-library-business/src/main/java/com/qmth/paper/library/business/templete/export/AsyncExportTaskTemplate.java
  5. 4 4
      paper-library-business/src/main/java/com/qmth/paper/library/business/templete/importData/AsyncImportTaskTemplate.java
  6. 9 4
      paper-library-common/pom.xml
  7. 7 45
      paper-library-common/src/main/java/com/qmth/paper/library/common/contant/SystemConstant.java
  8. 2 0
      paper-library-common/src/main/java/com/qmth/paper/library/common/service/BasicSchoolService.java
  9. 10 253
      paper-library-common/src/main/java/com/qmth/paper/library/common/service/CommonCacheService.java
  10. 4 17
      paper-library-common/src/main/java/com/qmth/paper/library/common/service/LibraryCommonService.java
  11. 2 23
      paper-library-common/src/main/java/com/qmth/paper/library/common/service/SysPrivilegeService.java
  12. 0 1
      paper-library-common/src/main/java/com/qmth/paper/library/common/service/TBSessionService.java
  13. 4 10
      paper-library-common/src/main/java/com/qmth/paper/library/common/service/impl/AuthInfoServiceImpl.java
  14. 8 0
      paper-library-common/src/main/java/com/qmth/paper/library/common/service/impl/BasicSchoolServiceImpl.java
  15. 13 400
      paper-library-common/src/main/java/com/qmth/paper/library/common/service/impl/CommonCacheServiceImpl.java
  16. 35 53
      paper-library-common/src/main/java/com/qmth/paper/library/common/service/impl/LibraryCommonServiceImpl.java
  17. 0 10
      paper-library-common/src/main/java/com/qmth/paper/library/common/service/impl/SysOrgServiceImpl.java
  18. 17 80
      paper-library-common/src/main/java/com/qmth/paper/library/common/service/impl/SysPrivilegeServiceImpl.java
  19. 4 31
      paper-library-common/src/main/java/com/qmth/paper/library/common/service/impl/SysRoleServiceImpl.java
  20. 3 3
      paper-library-common/src/main/java/com/qmth/paper/library/common/service/impl/SysUserRoleServiceImpl.java
  21. 2 24
      paper-library-common/src/main/java/com/qmth/paper/library/common/service/impl/SysUserServiceImpl.java
  22. 0 1
      paper-library-common/src/main/java/com/qmth/paper/library/common/service/impl/TBSessionServiceImpl.java
  23. 0 136
      paper-library-common/src/main/java/com/qmth/paper/library/common/util/AuthThirdUtil.java
  24. 2 171
      paper-library-common/src/main/java/com/qmth/paper/library/common/util/AuthUtil.java
  25. 1 41
      paper-library-common/src/main/java/com/qmth/paper/library/common/util/ConvertUtil.java
  26. 0 266
      paper-library-common/src/main/java/com/qmth/paper/library/common/util/RedisUtil.java
  27. 1 1
      paper-library/src/main/java/com/qmth/paper/library/PaperLibraryApplication.java
  28. 3 3
      paper-library/src/main/java/com/qmth/paper/library/api/ClientController.java
  29. 5 29
      paper-library/src/main/java/com/qmth/paper/library/api/MenuCustomController.java
  30. 11 15
      paper-library/src/main/java/com/qmth/paper/library/api/SysController.java
  31. 14 13
      paper-library/src/main/java/com/qmth/paper/library/auth/PaperLibraryAuthenticationService.java
  32. 3 3
      paper-library/src/main/java/com/qmth/paper/library/auth/PaperLibrarySession.java
  33. 1 7
      paper-library/src/main/resources/application-dev.properties
  34. 45 0
      paper-library/src/main/resources/static/ehcache.xml
  35. 0 5
      pom.xml

+ 1 - 2
paper-library-business/src/main/java/com/qmth/paper/library/business/bean/result/CustomPrivilegeResult.java

@@ -25,9 +25,8 @@ public class CustomPrivilegeResult implements Serializable {
 
     }
 
-    public CustomPrivilegeResult(List<PrivilegeDto> customPrivilegeList, List<String> sysPdfSize) {
+    public CustomPrivilegeResult(List<PrivilegeDto> customPrivilegeList) {
         this.customPrivilegeList = customPrivilegeList;
-        this.sysPdfSize = sysPdfSize;
     }
 
     public List<PrivilegeDto> getCustomPrivilegeList() {

+ 1 - 17
paper-library-business/src/main/java/com/qmth/paper/library/business/bean/result/TSchoolPrivilegeResult.java

@@ -23,22 +23,13 @@ public class TSchoolPrivilegeResult implements Serializable {
     @ApiModelProperty(value = "自定义菜单id")
     List<String> privilegeIdList;
 
-    @ApiModelProperty(value = "pdf格式")
-    List<String> pdfSize;
-
     public TSchoolPrivilegeResult() {
 
     }
 
-    public TSchoolPrivilegeResult(List<String> privilegeIdList, List<String> pdfSize) {
-        this.privilegeIdList = privilegeIdList;
-        this.pdfSize = pdfSize;
-    }
-
-    public TSchoolPrivilegeResult(Long schoolId, List<String> privilegeIdList, List<String> pdfSize) {
+    public TSchoolPrivilegeResult(Long schoolId, List<String> privilegeIdList) {
         this.schoolId = schoolId;
         this.privilegeIdList = privilegeIdList;
-        this.pdfSize = pdfSize;
     }
 
     public List<String> getPrivilegeIdList() {
@@ -57,11 +48,4 @@ public class TSchoolPrivilegeResult implements Serializable {
         this.schoolId = schoolId;
     }
 
-    public List<String> getPdfSize() {
-        return pdfSize;
-    }
-
-    public void setPdfSize(List<String> pdfSize) {
-        this.pdfSize = pdfSize;
-    }
 }

+ 0 - 7
paper-library-business/src/main/java/com/qmth/paper/library/business/service/impl/PaperLibraryCommonServiceImpl.java

@@ -21,7 +21,6 @@ import com.qmth.paper.library.common.enums.TaskTypeEnum;
 import com.qmth.paper.library.common.enums.UploadFileEnum;
 import com.qmth.paper.library.common.service.*;
 import com.qmth.paper.library.common.util.FileStoreUtil;
-import com.qmth.paper.library.common.util.RedisUtil;
 import com.qmth.paper.library.common.util.ResultUtil;
 import com.qmth.paper.library.common.util.ServletUtil;
 import org.apache.commons.codec.digest.DigestUtils;
@@ -77,9 +76,6 @@ public class PaperLibraryCommonServiceImpl implements PaperLibraryCommonService
     @Autowired
     BasicSchoolService basicSchoolService;
 
-    @Resource
-    CommonCacheService commonCacheService;
-
 
     /**
      * 保存附件公用
@@ -230,9 +226,6 @@ public class PaperLibraryCommonServiceImpl implements PaperLibraryCommonService
             validateOrg(idLong);
             sysOrgService.removeById(idLong);
         }
-        Long schoolId = SystemConstant.convertIdToLong(String.valueOf(ServletUtil.getRequestHeaderSchoolId()));
-        commonCacheService.removeOrgCollegeLevelCache(schoolId);
-
         return true;
     }
 

+ 3 - 4
paper-library-business/src/main/java/com/qmth/paper/library/business/templete/export/AsyncExportTaskTemplate.java

@@ -13,7 +13,6 @@ import com.qmth.paper.library.common.enums.LocalCatalogEnum;
 import com.qmth.paper.library.common.enums.TaskResultEnum;
 import com.qmth.paper.library.common.enums.TaskStatusEnum;
 import com.qmth.paper.library.common.enums.UploadFileEnum;
-import com.qmth.paper.library.common.service.CommonCacheService;
 import com.qmth.paper.library.common.service.SysConfigService;
 import com.qmth.paper.library.common.service.TBTaskService;
 import com.qmth.paper.library.common.util.FileStoreUtil;
@@ -100,9 +99,9 @@ public abstract class AsyncExportTaskTemplate {
             String type = (String) jsonObject.get(SystemConstant.TYPE);
 
             String charset = SystemConstant.CHARSET_GBK;
-            CommonCacheService commonCacheService = SpringContextHolder.getBean(CommonCacheService.class);
-            if (commonCacheService != null) {
-                SysConfig sysConfig = commonCacheService.addSysConfigCache(SystemConstant.SYS_CONFIG_KEY_CHARSETS);
+            SysConfigService sysConfigService = SpringContextHolder.getBean(SysConfigService.class);
+            if (sysConfigService != null) {
+                SysConfig sysConfig = sysConfigService.getByKey(SystemConstant.SYS_CONFIG_KEY_CHARSETS);
                 if (sysConfig != null && StringUtils.isNotBlank(sysConfig.getConfigValue())) {
                     charset = sysConfig.getConfigValue();
                 }

+ 4 - 4
paper-library-business/src/main/java/com/qmth/paper/library/business/templete/importData/AsyncImportTaskTemplate.java

@@ -11,7 +11,7 @@ import com.qmth.paper.library.common.enums.LocalCatalogEnum;
 import com.qmth.paper.library.common.enums.TaskResultEnum;
 import com.qmth.paper.library.common.enums.TaskStatusEnum;
 import com.qmth.paper.library.common.enums.UploadFileEnum;
-import com.qmth.paper.library.common.service.CommonCacheService;
+import com.qmth.paper.library.common.service.SysConfigService;
 import com.qmth.paper.library.common.service.TBTaskService;
 import com.qmth.paper.library.common.util.FileStoreUtil;
 import com.qmth.paper.library.common.util.Result;
@@ -109,9 +109,9 @@ public abstract class AsyncImportTaskTemplate {
             String type = (String) jsonObject.get(SystemConstant.TYPE);
 
             String charset = SystemConstant.CHARSET_GBK;
-            CommonCacheService commonCacheService = SpringContextHolder.getBean(CommonCacheService.class);
-            if (commonCacheService != null) {
-                SysConfig sysConfig = commonCacheService.addSysConfigCache(SystemConstant.SYS_CONFIG_KEY_CHARSETS);
+            SysConfigService sysConfigService = SpringContextHolder.getBean(SysConfigService.class);
+            if (sysConfigService != null) {
+                SysConfig sysConfig = sysConfigService.getByKey(SystemConstant.SYS_CONFIG_KEY_CHARSETS);
                 if (sysConfig != null && StringUtils.isNotBlank(sysConfig.getConfigValue())) {
                     charset = sysConfig.getConfigValue();
                 }

+ 9 - 4
paper-library-common/pom.xml

@@ -18,10 +18,6 @@
             <groupId>com.qmth.boot</groupId>
             <artifactId>starter-api</artifactId>
         </dependency>
-        <dependency>
-            <groupId>com.qmth.boot</groupId>
-            <artifactId>data-redis</artifactId>
-        </dependency>
         <dependency>
             <groupId>com.qmth.boot</groupId>
             <artifactId>core-fss</artifactId>
@@ -46,6 +42,10 @@
             <groupId>com.qmth.boot</groupId>
             <artifactId>core-retrofit</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.qmth.boot</groupId>
+            <artifactId>core-uid</artifactId>
+        </dependency>
         <dependency>
             <groupId>io.netty</groupId>
             <artifactId>netty-all</artifactId>
@@ -167,5 +167,10 @@
             <groupId>net.coobird</groupId>
             <artifactId>thumbnailator</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.aspectj</groupId>
+            <artifactId>aspectjweaver</artifactId>
+            <version>1.9.7</version>
+        </dependency>
     </dependencies>
 </project>

+ 7 - 45
paper-library-common/src/main/java/com/qmth/paper/library/common/contant/SystemConstant.java

@@ -3,27 +3,23 @@ package com.qmth.paper.library.common.contant;
 import com.qmth.boot.core.uid.service.UidService;
 import com.qmth.paper.library.common.annotation.DBVerify;
 import com.qmth.paper.library.common.bean.result.DBVerifyResult;
-import com.qmth.paper.library.common.config.DictionaryConfig;
+import com.qmth.paper.library.common.entity.BasicSchool;
+import com.qmth.paper.library.common.entity.SysUser;
 import com.qmth.paper.library.common.enums.ExceptionResultEnum;
-import com.qmth.paper.library.common.service.CommonCacheService;
+import com.qmth.paper.library.common.service.BasicSchoolService;
 import com.qmth.paper.library.common.util.Base64Util;
 import com.qmth.paper.library.common.util.ServletUtil;
-import com.qmth.paper.library.common.entity.BasicSchool;
-import com.qmth.paper.library.common.entity.SysUser;
 import org.apache.commons.io.IOUtils;
 import org.springframework.cglib.beans.BeanMap;
 
-import javax.annotation.Resource;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.UnsupportedEncodingException;
 import java.lang.reflect.Field;
-import java.math.BigDecimal;
 import java.net.URLEncoder;
 import java.nio.charset.Charset;
 import java.util.*;
-import java.util.stream.Collectors;
 
 /**
  * @Description: 系统常量
@@ -96,28 +92,11 @@ public class SystemConstant {
     public static final String REGULAR_EXPRESSION_OF_NUMBER = "^\\d{n}$";
     public static final String REGULAR_EXPRESSION_OF_NUMBER_LETTER = "^\\w+$";
 
-    /**
-     * oss url过期时间
-     */
-//    public static final int OSS_URL_EXPIRE = 5 * 60 * 1000;//过期时间5分钟
-
     /**
      * 缓存配置
      */
-    public static final String USER_OAUTH_CACHE = "user:oauth:cache";
-    public static final String USER_ACCOUNT_CACHE = "user:account:cache";
-    public static final String USER_MENU_CACHE = "user:menu:cache";
-    public static final String SCHOOL_CACHE = "school:cache";
-    public static final String SCHOOL_CODE_CACHE = "school:code:cache";
-    public static final String ORG_CACHE = "org:cache";
-    public static final String PRIVILEGE_URL_CACHE = "privilege:url:cache";
-    public static final String ROLE_PRIVILEGE_CACHE = "role:privilege:cache";
-    public static final String USER_ROLE_PRIVILEGE_CACHE = "user:role:privilege:cache";
-    public static final String ROLE_CACHE = "role:cache";
-    public static final String AUTH_INFO_CACHE = "auth:info:cache";
-    public static final String SYS_CONFIG_CACHE = "sys:config:cache";
-    public static final String CUSTOM_PRIVILEGE_CACHE = "custom:privilege:cache";
-    public static final String ORG_COLLEGE_LEVEL_CACHE = "org:college:level:cache";
+    public static final String CACHE_NAME = "paperLibraryCache";
+    public static final String USER_SESSION = "user:session:cache";
 
     /**
      * 鉴权
@@ -436,27 +415,10 @@ public class SystemConstant {
      * @return
      */
     public static String getLocalFileHost(String hostUrl) {
-        CommonCacheService commonCacheService = SpringContextHolder.getBean(CommonCacheService.class);
+        BasicSchoolService basicSchoolService = SpringContextHolder.getBean(BasicSchoolService.class);
         if (hostUrl.contains("*")) {
             SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
-            BasicSchool basicSchool = commonCacheService.schoolCache(sysUser.getSchoolId());
-            hostUrl = hostUrl.replace("*", basicSchool.getCode());
-        }
-        return hostUrl;
-    }
-
-    /**
-     * 获取本地文件host
-     *
-     * @param hostUrl
-     * @param userId
-     * @return
-     */
-    public static String getLocalFileHostByUserId(String hostUrl, Long userId) {
-        CommonCacheService commonCacheService = SpringContextHolder.getBean(CommonCacheService.class);
-        if (hostUrl.contains("*")) {
-            SysUser sysUser = commonCacheService.userCache(userId);
-            BasicSchool basicSchool = commonCacheService.schoolCache(sysUser.getSchoolId());
+            BasicSchool basicSchool = basicSchoolService.getById(sysUser.getSchoolId());
             hostUrl = hostUrl.replace("*", basicSchool.getCode());
         }
         return hostUrl;

+ 2 - 0
paper-library-common/src/main/java/com/qmth/paper/library/common/service/BasicSchoolService.java

@@ -17,4 +17,6 @@ import java.util.List;
 public interface BasicSchoolService extends IService<BasicSchool> {
 
     List<SchoolDto> listSchool();
+
+    BasicSchool getBySchoolCode(String schoolCode);
 }

+ 10 - 253
paper-library-common/src/main/java/com/qmth/paper/library/common/service/CommonCacheService.java

@@ -1,272 +1,29 @@
 package com.qmth.paper.library.common.service;
 
-import com.qmth.paper.library.common.bean.auth.AuthBean;
-import com.qmth.paper.library.common.bean.dto.AuthOrgInfoDto;
-import com.qmth.paper.library.common.bean.result.MenuResult;
-import com.qmth.paper.library.common.entity.*;
-import com.qmth.paper.library.common.enums.PrivilegePropertyEnum;
-import com.qmth.paper.library.common.entity.*;
+import com.qmth.paper.library.common.entity.TBSession;
 
-import java.util.List;
-import java.util.Set;
-
-/**
- * @Description: 缓存操作service
- * @Param:
- * @return:
- * @Author: wangliang
- * @Date: 2021/3/25
- */
 public interface CommonCacheService {
 
     /**
-     * 添加角色缓存
-     *
-     * @param roleId
-     * @return
-     */
-    public SysRole roleCache(Long roleId);
-
-    /**
-     * 修改角色缓存
-     *
-     * @param roleId
-     * @return
-     */
-    public SysRole updateRoleCache(Long roleId);
-
-    /**
-     * 删除角色缓存
-     *
-     * @param roleId
-     */
-    public void removeRoleCache(Long roleId);
-
-    /**
-     * 添加用户菜单缓存
-     *
-     * @param userId
-     * @return
-     */
-    public MenuResult userMenuCache(Long userId);
-
-    /**
-     * 修改用户菜单缓存
-     *
-     * @param userId
-     * @return
-     */
-    public MenuResult updateUserMenuCache(Long userId);
-
-    /**
-     * 删除用户菜单缓存
-     *
-     * @param userId
-     */
-    public void removeUserMenuCache(Long userId);
-
-    /**
-     * 添加用户缓存
-     *
-     * @param userId
-     * @return
-     */
-    public SysUser userCache(Long userId);
-
-    /**
-     * 修改用户缓存
-     *
-     * @param userId
-     * @return
-     */
-    public SysUser updateUserCache(Long userId);
-
-    /**
-     * 删除用户缓存
-     *
-     * @param userId
-     */
-    public void removeUserCache(Long userId);
-
-    /**
-     * 添加用户鉴权缓存
-     *
-     * @param userId
-     * @return
-     */
-    public AuthBean userAuthCache(Long userId);
-
-    /**
-     * 修改用户鉴权缓存
-     *
-     * @param userId
-     * @return
-     */
-    public AuthBean updateUserAuthCache(Long userId);
-
-    /**
-     * 删除用户鉴权缓存
-     *
-     * @param userId
-     */
-    public void removeUserAuthCache(Long userId);
-
-    /**
-     * 添加学校缓存
-     *
-     * @param schoolId
-     * @return
-     */
-    public BasicSchool schoolCache(Long schoolId);
-
-    /**
-     * 添加学校缓存
-     *
-     * @param code
-     * @return
-     */
-    public BasicSchool schoolCache(String code);
-
-    /**
-     * 删除学校缓存
-     */
-    public void removeSchoolIdCache();
-
-    /**
-     * 删除学校缓存
-     */
-    public void removeSchoolCodeCache();
-
-    /**
-     * 添加机构缓存
-     *
-     * @param orgId
-     * @return
-     */
-    public SysOrg orgCache(Long orgId);
-
-
-    /**
-     * 删除机构缓存
-     */
-    public void removeOrgCache();
-
-    /**
-     * 获取鉴权url
+     * 保存session
      *
-     * @param privilegePropertyEnum
-     * @return
+     * @param sessionId
      */
-    public Set<String> privilegeUrlCache(PrivilegePropertyEnum privilegePropertyEnum);
+    TBSession saveTbSession(String sessionId, TBSession tbSession);
 
     /**
-     * 获取鉴权url
+     * 查询
      *
-     * @param privilegePropertyEnum
-     * @param schoolId
+     * @param sessionId
      * @return
      */
-    public Set<String> privilegeUrlCache(PrivilegePropertyEnum privilegePropertyEnum, Long schoolId);
-
+    TBSession getTbSession(String sessionId);
 
     /**
-     * 添加角色权限缓存
+     * 删除
      *
-     * @param roleId
+     * @param sessionId
      * @return
      */
-    public List<SysRolePrivilege> rolePrivilegeCache(Long roleId);
-
-    /**
-     * 修改角色权限缓存
-     *
-     * @param roleId
-     * @return
-     */
-    public List<SysRolePrivilege> updateRolePrivilegeCache(Long roleId);
-
-    /**
-     * 删除角色权限缓存
-     *
-     * @param roleId
-     */
-    public void removeRolePrivilegeCache(Long roleId);
-
-    /**
-     * 添加用户角色权限缓存
-     *
-     * @param userId
-     * @return
-     */
-    public List<SysUserRole> userRolePrivilegeCache(Long userId);
-
-    /**
-     * 删除用户角色权限缓存
-     *
-     * @param userId
-     */
-    public void removeUserRolePrivilegeCache(Long userId);
-
-    /**
-     * 添加鉴权缓存
-     *
-     * @param code
-     * @return
-     */
-    public AuthOrgInfoDto authInfoCache(String code);
-
-    /**
-     * 修改鉴权缓存
-     *
-     * @param code
-     * @return
-     */
-    public AuthOrgInfoDto updateAuthInfoCache(String code);
-
-    /**
-     * 删除鉴权缓存
-     *
-     * @param code
-     */
-    public void removeAuthInfoCache(String code);
-
-    /**
-     * 添加系统参数缓存
-     *
-     * @param key
-     * @return
-     */
-    public SysConfig addSysConfigCache(String key);
-
-    /**
-     * 添加系统参数缓存
-     *
-     * @param schoolId
-     * @param key
-     * @return
-     */
-    public SysConfig addSysConfigCache(Long schoolId, String key);
-
-    /**
-     * 删除系统参数缓存
-     *
-     * @param schoolId
-     * @param key
-     */
-    public void removeSysConfigCache(Long schoolId, String key);
-
-    /**
-     * 修改学院级别机构缓存
-     *
-     * @param schoolId 学校id
-     * @return 学院级别机构集合
-     */
-    List<SysOrg> updateOrgCollegeLevelCache(Long schoolId);
-
-    /**
-     * 删除学院级别机构缓存
-     *
-     * @param schoolId 学校id
-     */
-    void removeOrgCollegeLevelCache(Long schoolId);
+    String removeTbSession(String sessionId);
 }

+ 4 - 17
paper-library-common/src/main/java/com/qmth/paper/library/common/service/LibraryCommonService.java

@@ -1,21 +1,20 @@
 package com.qmth.paper.library.common.service;
 
 import com.qmth.paper.library.common.bean.auth.AuthBean;
+import com.qmth.paper.library.common.bean.dto.AuthOrgInfoDto;
 import com.qmth.paper.library.common.bean.result.LoginResult;
 import com.qmth.paper.library.common.bean.result.MenuResult;
-import com.qmth.paper.library.common.enums.AppSourceEnum;
-import com.qmth.paper.library.common.enums.PrivilegePropertyEnum;
-import com.qmth.paper.library.common.enums.SystemCodeEnum;
 import com.qmth.paper.library.common.entity.BasicAttachment;
 import com.qmth.paper.library.common.entity.SysRolePrivilege;
 import com.qmth.paper.library.common.entity.SysUser;
 import com.qmth.paper.library.common.entity.SysUserRole;
+import com.qmth.paper.library.common.enums.AppSourceEnum;
+import com.qmth.paper.library.common.enums.PrivilegePropertyEnum;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.File;
 import java.security.NoSuchAlgorithmException;
 import java.util.List;
-import java.util.Map;
 import java.util.Set;
 
 /**
@@ -186,17 +185,5 @@ public interface LibraryCommonService {
      */
     public LoginResult login(String password, SysUser sysUser, AppSourceEnum appSource) throws NoSuchAlgorithmException;
 
-    /**
-     * 根据编码类型获取系统编码
-     * @param type 编码类型
-     * @return 系统编码
-     */
-    /**
-     * 根据编码类型获取系统编码
-     *
-     * @param type        编码类型
-     * @param requestUser 请求的用户
-     * @return 系统编码
-     */
-    public String getSysIncrCode(SystemCodeEnum type, SysUser requestUser);
+    public AuthOrgInfoDto authInfoCache(String code);
 }

+ 2 - 23
paper-library-common/src/main/java/com/qmth/paper/library/common/service/SysPrivilegeService.java

@@ -17,8 +17,6 @@ import java.util.List;
  */
 public interface SysPrivilegeService extends IService<SysPrivilege> {
 
-    List<PrivilegeDto> listPrivilegeTree();
-
     /**
      * 获取所有权限
      *
@@ -28,8 +26,6 @@ public interface SysPrivilegeService extends IService<SysPrivilege> {
 
     Long savePrivilege(SysPrivilege privilege);
 
-    boolean remove(Long id);
-
     List<String> getRolePrivileges(Long roleId);
 
     List<PrivilegeDto> listPrivilegeTreeAuth();
@@ -52,24 +48,7 @@ public interface SysPrivilegeService extends IService<SysPrivilege> {
      */
     Collection<?> getMenuTreeCommon(Collection<?> sysPrivilegeList);
 
-    /**
-     * 获取自定义菜单
-     *
-     * @return
-     */
-    List<PrivilegeDto> addCustomList();
+    List<PrivilegeDto> commonCustomList();
 
-    /**
-     * 更新自定义菜单
-     *
-     * @return
-     */
-    List<PrivilegeDto> updateCustomList();
-
-    /**
-     * 删除自定义菜单
-     *
-     * @return
-     */
-    void removeCustomList();
+    boolean remove(Long id);
 }

+ 0 - 1
paper-library-common/src/main/java/com/qmth/paper/library/common/service/TBSessionService.java

@@ -12,5 +12,4 @@ import com.qmth.paper.library.common.entity.TBSession;
  * @since 2021-03-19
  */
 public interface TBSessionService extends IService<TBSession> {
-
 }

+ 4 - 10
paper-library-common/src/main/java/com/qmth/paper/library/common/service/impl/AuthInfoServiceImpl.java

@@ -55,9 +55,6 @@ public class AuthInfoServiceImpl implements AuthInfoService {
     @Resource
     TSAuthMapper tsAuthMapper;
 
-    @Resource
-    CommonCacheService commonCacheService;
-
     @Resource
     BasicSchoolService basicSchoolService;
 
@@ -79,6 +76,9 @@ public class AuthInfoServiceImpl implements AuthInfoService {
     @Resource
     SysOrgMapper sysOrgMapper;
 
+    @Resource
+    LibraryCommonService libraryCommonService;
+
     /**
      * 授权信息初始化
      *
@@ -125,7 +125,7 @@ public class AuthInfoServiceImpl implements AuthInfoService {
     @Override
     public void appHasExpired(String code) {
         if (Objects.nonNull(code)) {
-            AuthOrgInfoDto authOrgInfoDto = commonCacheService.authInfoCache(code);
+            AuthOrgInfoDto authOrgInfoDto = libraryCommonService.authInfoCache(code);
             if (Objects.isNull(authOrgInfoDto) || (Objects.nonNull(authOrgInfoDto) && authOrgInfoDto.getControl().hasExpired())) {
                 throw ExceptionResultEnum.AUTH_INFO_ERROR.exception();
             }
@@ -195,9 +195,6 @@ public class AuthInfoServiceImpl implements AuthInfoService {
             } else {
                 tsAuthList.add(new TSAuth(o.getId(), solarProperties.getAccessKey(), solarProperties.getAccessSecret(), authEnum, appInfo.getControl().getExpireTime()));
             }
-            if (Objects.isNull(commonCacheService.updateAuthInfoCache(o.getCode()))) {
-                commonCacheService.removeAuthInfoCache(o.getCode());
-            }
 
             QueryWrapper<BasicSchool> basicSchoolQueryWrapper = new QueryWrapper<>();
             basicSchoolQueryWrapper.lambda().eq(BasicSchool::getCode, o.getCode());
@@ -249,13 +246,10 @@ public class AuthInfoServiceImpl implements AuthInfoService {
             tsAuthMapper.insertBatch(tsAuthList);
 
             if (!CollectionUtils.isEmpty(basicSchoolSet)) {
-                commonCacheService.removeSchoolIdCache();
-                commonCacheService.removeSchoolCodeCache();
                 basicSchoolMapper.insertBatch(basicSchoolSet);
             }
 
             if (!CollectionUtils.isEmpty(sysOrgSet)) {
-                commonCacheService.removeOrgCache();
                 sysOrgMapper.insertBatch(sysOrgSet);
             }
         }

+ 8 - 0
paper-library-common/src/main/java/com/qmth/paper/library/common/service/impl/BasicSchoolServiceImpl.java

@@ -1,5 +1,6 @@
 package com.qmth.paper.library.common.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.paper.library.common.bean.dto.SchoolDto;
 import com.qmth.paper.library.common.entity.BasicSchool;
@@ -24,4 +25,11 @@ public class BasicSchoolServiceImpl extends ServiceImpl<BasicSchoolMapper, Basic
     public List<SchoolDto> listSchool() {
         return this.baseMapper.listSchool();
     }
+
+    @Override
+    public BasicSchool getBySchoolCode(String schoolCode) {
+        QueryWrapper<BasicSchool> basicSchoolQueryWrapper = new QueryWrapper<>();
+        basicSchoolQueryWrapper.lambda().eq(BasicSchool::getCode, schoolCode);
+        return this.getOne(basicSchoolQueryWrapper);
+    }
 }

+ 13 - 400
paper-library-common/src/main/java/com/qmth/paper/library/common/service/impl/CommonCacheServiceImpl.java

@@ -1,424 +1,37 @@
 package com.qmth.paper.library.common.service.impl;
 
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.qmth.boot.core.solar.model.AppInfo;
-import com.qmth.boot.core.solar.model.OrgInfo;
-import com.qmth.boot.core.solar.service.SolarService;
-import com.qmth.paper.library.common.bean.auth.AuthBean;
-import com.qmth.paper.library.common.bean.dto.AuthOrgInfoDto;
-import com.qmth.paper.library.common.bean.result.MenuResult;
 import com.qmth.paper.library.common.contant.SystemConstant;
-import com.qmth.paper.library.common.entity.*;
-import com.qmth.paper.library.common.enums.PrivilegePropertyEnum;
-import com.qmth.paper.library.common.service.*;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import com.qmth.paper.library.common.entity.TBSession;
+import com.qmth.paper.library.common.service.CommonCacheService;
+import com.qmth.paper.library.common.service.TBSessionService;
 import org.springframework.cache.annotation.CacheEvict;
 import org.springframework.cache.annotation.CachePut;
 import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.util.List;
-import java.util.Objects;
-import java.util.Set;
-import java.util.stream.Collectors;
 
-/**
- * @Description: 缓存操作serviceImpl 实现类
- * @Param:
- * @return:
- * @Author: wangliang
- * @Date: 2021/3/25
- */
 @Service
 public class CommonCacheServiceImpl implements CommonCacheService {
-    private final static Logger log = LoggerFactory.getLogger(CommonCacheServiceImpl.class);
 
     @Resource
-    SysUserService sysUserService;
+    TBSessionService tbSessionService;
 
-    @Resource
-    BasicSchoolService basicSchoolService;
-
-    @Resource
-    LibraryCommonService commonService;
-
-    @Resource
-    SysOrgService sysOrgService;
-
-    @Resource
-    SysRoleService sysRoleService;
-
-    @Resource
-    SolarService solarService;
-
-    @Resource
-    SysConfigService sysConfigService;
-
-    /**
-     * 添加角色缓存
-     *
-     * @param roleId
-     * @return
-     */
-    @Override
-    @Cacheable(value = SystemConstant.ROLE_CACHE, key = "#p0", unless = "#result == null")
-    public SysRole roleCache(Long roleId) {
-        return sysRoleService.getById(roleId);
-    }
-
-    /**
-     * 修改角色缓存
-     *
-     * @param roleId
-     * @return
-     */
-    @Override
-    @CachePut(value = SystemConstant.ROLE_CACHE, key = "#p0", condition = "#result != null")
-    public SysRole updateRoleCache(Long roleId) {
-        return sysRoleService.getById(roleId);
-    }
-
-    /**
-     * 删除角色缓存
-     *
-     * @param roleId
-     * @return
-     */
-    @Override
-    @CacheEvict(value = SystemConstant.ROLE_CACHE, key = "#p0")
-    public void removeRoleCache(Long roleId) {
-
-    }
-
-    /**
-     * 添加用户菜单缓存
-     *
-     * @param userId
-     * @return
-     */
-    @Override
-    @Cacheable(value = SystemConstant.USER_MENU_CACHE, key = "#p0", unless = "#result == null")
-    public MenuResult userMenuCache(Long userId) {
-        return commonService.getUserMenu(userId);
-    }
-
-    /**
-     * 修改用户菜单缓存
-     *
-     * @param userId
-     * @return
-     */
-    @Override
-    @CachePut(value = SystemConstant.USER_MENU_CACHE, key = "#p0", condition = "#result != null")
-    public MenuResult updateUserMenuCache(Long userId) {
-        return commonService.getUserMenu(userId);
-    }
-
-    /**
-     * 删除用户菜单缓存
-     *
-     * @param userId
-     */
-    @Override
-    @CacheEvict(value = SystemConstant.USER_MENU_CACHE, key = "#p0")
-    public void removeUserMenuCache(Long userId) {
-
-    }
-
-    /**
-     * 添加用户缓存
-     *
-     * @param userId
-     * @return
-     */
-    @Override
-    @Cacheable(value = SystemConstant.USER_ACCOUNT_CACHE, key = "#p0", unless = "#result == null")
-    public SysUser userCache(Long userId) {
-        return sysUserService.getById(userId);
-    }
-
-    /**
-     * 修改用户缓存
-     *
-     * @param userId
-     * @return
-     */
     @Override
-    @CachePut(value = SystemConstant.USER_ACCOUNT_CACHE, key = "#p0", condition = "#result != null")
-    public SysUser updateUserCache(Long userId) {
-        return sysUserService.getById(userId);
+    @CachePut(value = SystemConstant.CACHE_NAME, key = "'tbSession' + #sessionId")
+    public TBSession saveTbSession(String sessionId, TBSession tbSession) {
+        return tbSession;
     }
 
-    /**
-     * 删除用户缓存
-     *
-     * @param userId
-     */
     @Override
-    @CacheEvict(value = SystemConstant.USER_ACCOUNT_CACHE, key = "#p0")
-    public void removeUserCache(Long userId) {
-
+    @Cacheable(value = SystemConstant.CACHE_NAME, key = "'tbSession' + #sessionId")
+    public TBSession getTbSession(String sessionId) {
+        return tbSessionService.getById(sessionId);
     }
 
-    /**
-     * 添加用户鉴权缓存
-     *
-     * @param userId
-     * @return
-     */
     @Override
-    @Cacheable(value = SystemConstant.USER_OAUTH_CACHE, key = "#p0", unless = "#result == null")
-    public AuthBean userAuthCache(Long userId) {
-        return commonService.getUserAuth(userId);
-    }
-
-    /**
-     * 修改用户鉴权缓存
-     *
-     * @param userId
-     * @return
-     */
-    @Override
-    @CachePut(value = SystemConstant.USER_OAUTH_CACHE, key = "#p0", condition = "#result != null")
-    public AuthBean updateUserAuthCache(Long userId) {
-        return commonService.getUserAuth(userId);
-    }
-
-    /**
-     * 删除用户鉴权缓存
-     *
-     * @param userId
-     */
-    @Override
-    @CacheEvict(value = SystemConstant.USER_OAUTH_CACHE, key = "#p0")
-    public void removeUserAuthCache(Long userId) {
-
-    }
-
-    /**
-     * 添加学校缓存
-     *
-     * @param schoolId
-     * @return
-     */
-    @Override
-    @Cacheable(value = SystemConstant.SCHOOL_CACHE, key = "#p0", unless = "#result == null")
-    public BasicSchool schoolCache(Long schoolId) {
-        return basicSchoolService.getById(schoolId);
-    }
-
-    /**
-     * 添加学校缓存
-     *
-     * @param code
-     * @return
-     */
-    @Override
-    @Cacheable(value = SystemConstant.SCHOOL_CODE_CACHE, key = "#p0", unless = "#result == null")
-    public BasicSchool schoolCache(String code) {
-        QueryWrapper<BasicSchool> basicSchoolQueryWrapper = new QueryWrapper<>();
-        basicSchoolQueryWrapper.lambda().eq(BasicSchool::getCode, code);
-        return basicSchoolService.getOne(basicSchoolQueryWrapper);
-    }
-
-    /**
-     * 删除学校缓存
-     */
-    @Override
-    @CacheEvict(value = SystemConstant.SCHOOL_CACHE, allEntries = true)
-    public void removeSchoolIdCache() {
-
-    }
-
-    /**
-     * 删除学校缓存
-     */
-    @Override
-    @CacheEvict(value = SystemConstant.SCHOOL_CODE_CACHE, allEntries = true)
-    public void removeSchoolCodeCache() {
-
-    }
-
-    /**
-     * 添加机构缓存
-     *
-     * @param orgId
-     * @return
-     */
-    @Override
-    @Cacheable(value = SystemConstant.ORG_CACHE, key = "#p0", unless = "#result == null")
-    public SysOrg orgCache(Long orgId) {
-        return sysOrgService.getById(orgId);
-    }
-
-
-    /**
-     * 删除机构缓存
-     */
-    @Override
-    @CacheEvict(value = SystemConstant.ORG_CACHE, allEntries = true)
-    public void removeOrgCache() {
-
-    }
-
-    /**
-     * 获取鉴权url
-     *
-     * @param privilegePropertyEnum
-     * @return
-     */
-    @Override
-    @Cacheable(value = SystemConstant.PRIVILEGE_URL_CACHE, key = "#p0", unless = "#result == null")
-    public Set<String> privilegeUrlCache(PrivilegePropertyEnum privilegePropertyEnum) {
-        return commonService.getPrivilegeUrl(privilegePropertyEnum);
-    }
-
-    @Override
-    @Cacheable(value = SystemConstant.PRIVILEGE_URL_CACHE, key = "#p0 + '-' + #p1", unless = "#result == null")
-    public Set<String> privilegeUrlCache(PrivilegePropertyEnum privilegePropertyEnum, Long schoolId) {
-        return commonService.getPrivilegeUrl(privilegePropertyEnum, schoolId);
-    }
-
-    /**
-     * 获取角色权限缓存
-     *
-     * @param roleId
-     * @return
-     */
-    @Override
-    @Cacheable(value = SystemConstant.ROLE_PRIVILEGE_CACHE, key = "#p0", unless = "#result == null")
-    public List<SysRolePrivilege> rolePrivilegeCache(Long roleId) {
-        return commonService.getRolePrivilege(roleId);
-    }
-
-    /**
-     * 修改角色权限缓存
-     *
-     * @param roleId
-     * @return
-     */
-    @Override
-    @CachePut(value = SystemConstant.ROLE_PRIVILEGE_CACHE, key = "#p0", condition = "#result != null")
-    public List<SysRolePrivilege> updateRolePrivilegeCache(Long roleId) {
-        return commonService.getRolePrivilege(roleId);
-    }
-
-    /**
-     * 删除角色权限缓存
-     *
-     * @param roleId
-     */
-    @Override
-    @CacheEvict(value = SystemConstant.ROLE_PRIVILEGE_CACHE, key = "#p0")
-    public void removeRolePrivilegeCache(Long roleId) {
-
-    }
-
-    /**
-     * 添加用户角色权限缓存
-     *
-     * @param userId
-     * @return
-     */
-    @Override
-    @Cacheable(value = SystemConstant.USER_ROLE_PRIVILEGE_CACHE, key = "#p0", unless = "#result == null")
-    public List<SysUserRole> userRolePrivilegeCache(Long userId) {
-        return commonService.getUserRolePrivilege(userId);
-    }
-
-    /**
-     * 删除用户角色权限缓存
-     *
-     * @param userId
-     */
-    @Override
-    @CacheEvict(value = SystemConstant.USER_ROLE_PRIVILEGE_CACHE, key = "#p0")
-    public void removeUserRolePrivilegeCache(Long userId) {
-
-    }
-
-    @Override
-    @Cacheable(value = SystemConstant.AUTH_INFO_CACHE, key = "#p0", unless = "#result == null")
-    public AuthOrgInfoDto authInfoCache(String code) {
-        AppInfo appInfo = solarService.getAppInfo();
-        AuthOrgInfoDto authOrgInfoDto = null;
-        if (Objects.nonNull(appInfo)) {
-            List<OrgInfo> orgInfoList = solarService.getOrgList().stream().filter(s -> Objects.equals(s.getCode(), code)).collect(Collectors.toList());
-            if (Objects.nonNull(orgInfoList) && orgInfoList.size() > 0) {
-                authOrgInfoDto = new AuthOrgInfoDto(orgInfoList.get(0), appInfo.getControl());
-            }
-        }
-        return authOrgInfoDto;
-    }
-
-    @Override
-    @CachePut(value = SystemConstant.AUTH_INFO_CACHE, key = "#p0", condition = "#result != null")
-    public AuthOrgInfoDto updateAuthInfoCache(String code) {
-        AppInfo appInfo = solarService.getAppInfo();
-        AuthOrgInfoDto authOrgInfoDto = null;
-        if (Objects.nonNull(appInfo)) {
-            List<OrgInfo> orgInfoList = solarService.getOrgList().stream().filter(s -> Objects.equals(s.getCode(), code)).collect(Collectors.toList());
-            if (Objects.nonNull(orgInfoList) && orgInfoList.size() > 0) {
-                authOrgInfoDto = new AuthOrgInfoDto(orgInfoList.get(0), appInfo.getControl());
-            }
-        }
-        return authOrgInfoDto;
-    }
-
-    @Override
-    @CacheEvict(value = SystemConstant.AUTH_INFO_CACHE, key = "#p0")
-    public void removeAuthInfoCache(String code) {
-
-    }
-
-    /**
-     * 添加系统参数缓存
-     *
-     * @param key
-     * @return
-     */
-    @Override
-    @Cacheable(value = SystemConstant.SYS_CONFIG_CACHE, key = "#p0", unless = "#result == null")
-    public SysConfig addSysConfigCache(String key) {
-        return sysConfigService.getOne(new QueryWrapper<SysConfig>().lambda().eq(SysConfig::getConfigKey, key));
-    }
-
-    /**
-     * 添加系统参数缓存
-     *
-     * @param schoolId
-     * @param key
-     * @return
-     */
-    @Override
-    @Cacheable(value = SystemConstant.SYS_CONFIG_CACHE, key = "#p0 + '-' + #p1", unless = "#result == null")
-    public SysConfig addSysConfigCache(Long schoolId, String key) {
-        return sysConfigService.getOne(new QueryWrapper<SysConfig>().lambda().eq(SysConfig::getSchoolId, schoolId).eq(SysConfig::getConfigKey, key));
-    }
-
-    /**
-     * 删除系统参数缓存
-     *
-     * @param schoolId
-     * @param key
-     */
-    @Override
-    @CacheEvict(value = SystemConstant.SYS_CONFIG_CACHE, key = "#p0 + '-' + #p1")
-    public void removeSysConfigCache(Long schoolId, String key) {
-
-    }
-
-    @Override
-    @CachePut(value = SystemConstant.ORG_COLLEGE_LEVEL_CACHE, key = "#p0", condition = "#result != null")
-    public List<SysOrg> updateOrgCollegeLevelCache(Long schoolId) {
-        return sysOrgService.findCollegeLevelOrgList(schoolId);
-    }
-
-    @Override
-    @CacheEvict(value = SystemConstant.ORG_COLLEGE_LEVEL_CACHE, key = "#p0")
-    public void removeOrgCollegeLevelCache(Long schoolId) {
-
+    @CacheEvict(value = SystemConstant.CACHE_NAME, key = "'tbSession' + #sessionId")
+    public String removeTbSession(String sessionId) {
+        return null;
     }
 }

+ 35 - 53
paper-library-common/src/main/java/com/qmth/paper/library/common/service/impl/LibraryCommonServiceImpl.java

@@ -1,20 +1,22 @@
 package com.qmth.paper.library.common.service.impl;
 
-import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.io.FileUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.google.common.reflect.TypeToken;
 import com.google.gson.Gson;
 import com.qmth.boot.core.enums.Platform;
+import com.qmth.boot.core.solar.model.AppInfo;
+import com.qmth.boot.core.solar.model.OrgInfo;
+import com.qmth.boot.core.solar.service.SolarService;
 import com.qmth.paper.library.common.bean.auth.AuthBean;
 import com.qmth.paper.library.common.bean.auth.ExpireTimeBean;
+import com.qmth.paper.library.common.bean.dto.AuthOrgInfoDto;
 import com.qmth.paper.library.common.bean.dto.MenuDto;
 import com.qmth.paper.library.common.bean.dto.MenuPrivilegeDto;
 import com.qmth.paper.library.common.bean.dto.OrgDto;
 import com.qmth.paper.library.common.bean.result.*;
 import com.qmth.paper.library.common.config.DictionaryConfig;
-import com.qmth.paper.library.common.contant.SpringContextHolder;
 import com.qmth.paper.library.common.contant.SystemConstant;
 import com.qmth.paper.library.common.entity.*;
 import com.qmth.paper.library.common.enums.*;
@@ -49,6 +51,9 @@ public class LibraryCommonServiceImpl implements LibraryCommonService {
     @Resource
     CommonCacheService commonCacheService;
 
+    @Resource
+    BasicSchoolService basicSchoolService;
+
     @Resource
     SysUserRoleService sysUserRoleService;
 
@@ -64,24 +69,15 @@ public class LibraryCommonServiceImpl implements LibraryCommonService {
     @Resource
     TBSessionService tbSessionService;
 
-    @Resource
-    RedisUtil redisUtil;
-
     @Resource
     DictionaryConfig dictionaryConfig;
 
-//    @Resource
-//    OssUtil ossUtil;
-
     @Autowired
     private SysOrgService sysOrgService;
 
     @Resource
     LibraryCommonService commonService;
 
-    @Resource
-    BasicAttachmentService basicAttachmentService;
-
     @Resource
     FileStoreUtil fileStoreUtil;
 
@@ -91,6 +87,9 @@ public class LibraryCommonServiceImpl implements LibraryCommonService {
     @Resource
     ConvertUtil convertUtil;
 
+    @Resource
+    SolarService solarService;
+
     /**
      * 获取用户菜单
      *
@@ -99,13 +98,13 @@ public class LibraryCommonServiceImpl implements LibraryCommonService {
      */
     @Override
     public MenuResult getUserMenu(Long userId) {
-        SysUser sysUser = commonCacheService.userCache(userId);
-        List<SysUserRole> sysUserRoleList = commonCacheService.userRolePrivilegeCache(userId);
+        SysUser sysUser = sysUserService.getById(userId);
+        List<SysUserRole> sysUserRoleList = getUserRolePrivilege(userId);
         List<SysRolePrivilege> sysRolePrivilegeList = new ArrayList<>();
         for (SysUserRole s : sysUserRoleList) {
-            SysRole sysRole = commonCacheService.roleCache(s.getRoleId());
+            SysRole sysRole = sysRoleService.getById(s.getRoleId());
             if (Objects.nonNull(sysRole) && sysRole.getEnable()) {
-                sysRolePrivilegeList.addAll(commonCacheService.rolePrivilegeCache(s.getRoleId()));
+                sysRolePrivilegeList.addAll(getRolePrivilege(s.getRoleId()));
             }
         }
         Set<Long> privilegeIds = sysRolePrivilegeList.stream().map(SysRolePrivilege::getPrivilegeId).collect(Collectors.toSet());
@@ -176,7 +175,7 @@ public class LibraryCommonServiceImpl implements LibraryCommonService {
      */
     @Override
     public void addUserRolePrivilege(SysUser sysUser, Long roleId) {
-        List<SysRolePrivilege> sysRolePrivilegeList = commonCacheService.rolePrivilegeCache(roleId);
+        List<SysRolePrivilege> sysRolePrivilegeList = getRolePrivilege(roleId);
         List<SysUserRole> sysUserRoleList = new ArrayList<>();
         sysRolePrivilegeList.forEach(s -> {
             sysUserRoleList.add(new SysUserRole(sysUser.getId(), s.getRoleId(), s.getPrivilegeId()));
@@ -246,18 +245,17 @@ public class LibraryCommonServiceImpl implements LibraryCommonService {
     public AuthBean getUserAuth(Long userId) {
         AuthBean authBean = null;
         try {
-            CommonCacheService commonCacheService = SpringContextHolder.getBean(CommonCacheService.class);
-            SysUser user = commonCacheService.userCache(userId);
+            SysUser user = sysUserService.getById(userId);
             if (Objects.isNull(user)) {
                 throw ExceptionResultEnum.USER_NO_DATA.exception();
             }
             //查询用户角色和权限
-            List<SysUserRole> sysUserRoleList = commonCacheService.userRolePrivilegeCache(user.getId());
+            List<SysUserRole> sysUserRoleList = getUserRolePrivilege(user.getId());
             if (Objects.nonNull(sysUserRoleList) && sysUserRoleList.size() > 0) {
                 Set<Long> roleIds = sysUserRoleList.stream().map(s -> s.getRoleId()).collect(Collectors.toSet());
                 List<SysRolePrivilege> sysRolePrivilegeList = new ArrayList<>();
                 for (Long l : roleIds) {
-                    sysRolePrivilegeList.addAll(commonCacheService.rolePrivilegeCache(l));
+                    sysRolePrivilegeList.addAll(getRolePrivilege(l));
                 }
                 Set<Long> privilegeIds = sysRolePrivilegeList.stream().map(s -> s.getPrivilegeId()).collect(Collectors.toSet());
                 QueryWrapper<SysRole> sysRoleQueryWrapper = new QueryWrapper<>();
@@ -275,8 +273,8 @@ public class LibraryCommonServiceImpl implements LibraryCommonService {
                     List<SysPrivilege> sysPrivilegeList = sysPrivilegeService.list(sysPrivilegeQueryWrapper);
                     authBean = new AuthBean(sysRoleList, sysPrivilegeList.stream().map(s -> s.getUrl()).collect(Collectors.toSet()));
                 } else {
-                    BasicSchool tbSchool = Objects.nonNull(user.getSchoolId()) ? commonCacheService.schoolCache(user.getSchoolId()) : null;
-                    SysOrg org = Objects.nonNull(user.getOrgId()) ? commonCacheService.orgCache(user.getOrgId()) : null;
+                    BasicSchool tbSchool = Objects.nonNull(user.getSchoolId()) ? basicSchoolService.getById(user.getSchoolId()) : null;
+                    SysOrg org = Objects.nonNull(user.getOrgId()) ? sysOrgService.getById(user.getOrgId()) : null;
                     List<SysPrivilege> sysPrivilegeList = new ArrayList<>();
                     if (privilegeIds.size() > 0) {
                         sysPrivilegeQueryWrapper.lambda().in(SysPrivilege::getId, privilegeIds)
@@ -342,7 +340,7 @@ public class LibraryCommonServiceImpl implements LibraryCommonService {
      */
     @Override
     public void removeUserInfo(Long userId, boolean all) throws NoSuchAlgorithmException {
-        AuthBean authBean = commonCacheService.userAuthCache(userId);
+        AuthBean authBean = getUserAuth(userId);
         if (Objects.isNull(authBean)) {
             throw ExceptionResultEnum.NOT_LOGIN.exception();
         }
@@ -354,17 +352,12 @@ public class LibraryCommonServiceImpl implements LibraryCommonService {
                 Collections.sort(roleNames);
                 String sessionId = SessionUtil.digest(userId, Math.abs(roleNames.toString().hashCode()), p.name());
                 tbSessionService.removeById(sessionId);
-                redisUtil.deleteUserSession(sessionId);
+                // todo xf session
             }
         } else {
             TBSession tbSession = (TBSession) ServletUtil.getRequestSession();
             tbSessionService.removeById(tbSession.getId());
-            redisUtil.deleteUserSession(tbSession.getId());
         }
-        commonCacheService.removeUserCache(userId);
-        commonCacheService.removeUserAuthCache(userId);
-        commonCacheService.removeUserMenuCache(userId);
-        commonCacheService.removeUserRolePrivilegeCache(userId);
     }
 
     /**
@@ -409,19 +402,9 @@ public class LibraryCommonServiceImpl implements LibraryCommonService {
                         }
                     }
                     tbSessionService.removeByIds(sessionIdSet);
-                    for (String s : sessionIdSet) {
-                        redisUtil.deleteUserSession(s);
-                    }
                 } else {
                     TBSession tbSession = (TBSession) ServletUtil.getRequestSession();
                     tbSessionService.removeById(tbSession.getId());
-                    redisUtil.deleteUserSession(tbSession.getId());
-                }
-                for (Long l : userIds) {
-                    commonCacheService.removeUserCache(l);
-                    commonCacheService.removeUserAuthCache(l);
-                    commonCacheService.removeUserMenuCache(l);
-                    commonCacheService.removeUserRolePrivilegeCache(l);
                 }
             }).start();
         }
@@ -661,7 +644,6 @@ public class LibraryCommonServiceImpl implements LibraryCommonService {
         }
         //生成token
         String token = SystemConstant.getUuid();
-        commonCacheService.userCache(sysUser.getId());
         //添加用户会话缓存
         Set<String> roleNamesSet = new HashSet<>(), roleTypes = new HashSet<>();
         List<RoleResult> roleSource = new ArrayList<>();
@@ -683,7 +665,7 @@ public class LibraryCommonServiceImpl implements LibraryCommonService {
                 platform.name(), platform.name(), deviceId, ServletUtil.getRequest().getLocalAddr(), token,
                 expireTime.getDate().getTime(), appSource);
         tbSessionService.saveOrUpdate(tbSession);
-        redisUtil.setUserSession(sessionId, tbSession, expireTime.getExpireSeconds());
+        commonCacheService.saveTbSession(sessionId, tbSession);
 
 //        LoginResult loginResult = new LoginResult(sysUser, sessionId, test, Objects.nonNull(roleTypes) && roleTypes.size() > 0 ? roleTypes : roleNamesSet, appSource, roleSource);
         LoginResult loginResult = new LoginResult(sysUser, sessionId, token, Objects.nonNull(roleTypes) && roleTypes.size() > 0 ? roleTypes : roleNamesSet, appSource, roleSource);
@@ -700,18 +682,6 @@ public class LibraryCommonServiceImpl implements LibraryCommonService {
         return loginResult;
     }
 
-    @Override
-    public String getSysIncrCode(SystemCodeEnum type, SysUser requestUser) {
-        Long schoolId = requestUser.getSchoolId();
-        String date = DateUtil.today().replace("-", "");
-        String paperNumber = "";
-        int count = 0;
-        do {
-            paperNumber = convertUtil.getIncre(date, type.getModel() + schoolId, type.getDigit());
-        } while (count > 0);
-        return paperNumber;
-    }
-
     private Set<Long> getOrgIds(Set<Long> stringSet, List<OrgDto> orgDtos, Long parentId) {
         for (OrgDto orgDto : orgDtos) {
             Long tempParentId = orgDto.getParentId();
@@ -757,4 +727,16 @@ public class LibraryCommonServiceImpl implements LibraryCommonService {
             log.error(SystemConstant.LOG_ERROR, e);
         }
     }
+
+    public AuthOrgInfoDto authInfoCache(String code) {
+        AppInfo appInfo = solarService.getAppInfo();
+        AuthOrgInfoDto authOrgInfoDto = null;
+        if (Objects.nonNull(appInfo)) {
+            List<OrgInfo> orgInfoList = solarService.getOrgList().stream().filter(s -> Objects.equals(s.getCode(), code)).collect(Collectors.toList());
+            if (Objects.nonNull(orgInfoList) && orgInfoList.size() > 0) {
+                authOrgInfoDto = new AuthOrgInfoDto(orgInfoList.get(0), appInfo.getControl());
+            }
+        }
+        return authOrgInfoDto;
+    }
 }

+ 0 - 10
paper-library-common/src/main/java/com/qmth/paper/library/common/service/impl/SysOrgServiceImpl.java

@@ -12,9 +12,7 @@ import com.qmth.paper.library.common.enums.ExceptionResultEnum;
 import com.qmth.paper.library.common.enums.FieldUniqueEnum;
 import com.qmth.paper.library.common.enums.OrgTypeEnum;
 import com.qmth.paper.library.common.mapper.SysOrgMapper;
-import com.qmth.paper.library.common.service.CommonCacheService;
 import com.qmth.paper.library.common.service.SysOrgService;
-import com.qmth.paper.library.common.service.SysRoleService;
 import com.qmth.paper.library.common.service.SysUserService;
 import com.qmth.paper.library.common.util.ResultUtil;
 import com.qmth.paper.library.common.util.ServletUtil;
@@ -43,8 +41,6 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
     private SysUserService sysUserService;
     @Resource
     private SysOrgMapper sysOrgMapper;
-    @Resource
-    private CommonCacheService commonCacheService;
 
     @Override
     public List<OrgDto> listOrgTree() {
@@ -102,9 +98,6 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
                 org.updateInfo(sysUser.getId());
                 success = this.updateById(org);
             }
-            if (Objects.isNull(commonCacheService.updateOrgCollegeLevelCache(schoolId))) {
-                commonCacheService.removeOrgCollegeLevelCache(schoolId);
-            }
         } catch (Exception e) {
             if (e instanceof DuplicateKeyException) {
                 String errorColumn = e.getCause().toString();
@@ -307,9 +300,6 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
                 }
             }
         }
-        if (Objects.isNull(commonCacheService.updateOrgCollegeLevelCache(requestUser.getSchoolId()))) {
-            commonCacheService.removeOrgCollegeLevelCache(requestUser.getSchoolId());
-        }
         return map;
     }
 

+ 17 - 80
paper-library-common/src/main/java/com/qmth/paper/library/common/service/impl/SysPrivilegeServiceImpl.java

@@ -7,24 +7,21 @@ import com.google.gson.Gson;
 import com.qmth.paper.library.common.bean.dto.MenuDto;
 import com.qmth.paper.library.common.bean.dto.MenuPrivilegeDto;
 import com.qmth.paper.library.common.bean.dto.PrivilegeDto;
-import com.qmth.paper.library.common.enums.ExceptionResultEnum;
-import com.qmth.paper.library.common.enums.PrivilegeEnum;
-import com.qmth.paper.library.common.enums.PrivilegePropertyEnum;
-import com.qmth.paper.library.common.util.JacksonUtil;
 import com.qmth.paper.library.common.contant.SystemConstant;
 import com.qmth.paper.library.common.entity.SysPrivilege;
 import com.qmth.paper.library.common.entity.SysRolePrivilege;
 import com.qmth.paper.library.common.entity.TSchoolPrivilege;
+import com.qmth.paper.library.common.enums.ExceptionResultEnum;
+import com.qmth.paper.library.common.enums.PrivilegeEnum;
+import com.qmth.paper.library.common.enums.PrivilegePropertyEnum;
 import com.qmth.paper.library.common.mapper.SysPrivilegeMapper;
 import com.qmth.paper.library.common.service.SysPrivilegeService;
 import com.qmth.paper.library.common.service.SysRolePrivilegeService;
 import com.qmth.paper.library.common.service.TSchoolPrivilegeService;
+import com.qmth.paper.library.common.util.JacksonUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.cache.annotation.CacheEvict;
-import org.springframework.cache.annotation.CachePut;
-import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.LinkedMultiValueMap;
@@ -54,39 +51,6 @@ public class SysPrivilegeServiceImpl extends ServiceImpl<SysPrivilegeMapper, Sys
     @Resource
     TSchoolPrivilegeService tSchoolPrivilegeService;
 
-    @Override
-    public List<PrivilegeDto> listPrivilegeTree() {
-        QueryWrapper<SysPrivilege> queryWrapper = new QueryWrapper<>();
-        queryWrapper.lambda().orderByAsc(SysPrivilege::getParentId, SysPrivilege::getSequence)
-                .ne(SysPrivilege::getType, PrivilegeEnum.URL);
-        List<SysPrivilege> orgList = this.list(queryWrapper);
-        Map<Long, PrivilegeDto> map = new LinkedHashMap<>();
-        for (SysPrivilege privilege : orgList) {
-            PrivilegeDto privilegeDto = new PrivilegeDto();
-            privilegeDto.setId(privilege.getId());
-            privilegeDto.setName(privilege.getName());
-            privilegeDto.setUrl(privilege.getUrl());
-            privilegeDto.setType(privilege.getType());
-            privilegeDto.setParentId(privilege.getParentId());
-            privilegeDto.setSequence(privilege.getSequence());
-            map.put(privilege.getId(), privilegeDto);
-        }
-
-        Iterator<Long> iterator = map.keySet().iterator();
-        Set<Long> deleteKeys = new HashSet<>();
-        while (iterator.hasNext()) {
-            Long parentId = iterator.next();
-            if (map.get(parentId).getParentId() != null) {
-                map.get(map.get(parentId).getParentId()).getChildren().add(map.get(parentId));
-                deleteKeys.add(parentId);
-            }
-        }
-        for (Long key : deleteKeys) {
-            map.remove(key);
-        }
-        return new ArrayList<>(map.values());
-    }
-
     /**
      * 获取所有权限
      *
@@ -142,17 +106,6 @@ public class SysPrivilegeServiceImpl extends ServiceImpl<SysPrivilegeMapper, Sys
         return privilege.getId();
     }
 
-    @Override
-    public boolean remove(Long id) {
-        QueryWrapper<SysRolePrivilege> queryWrapper = new QueryWrapper<>();
-        queryWrapper.lambda().eq(SysRolePrivilege::getPrivilegeId, id);
-        List<SysRolePrivilege> sysRolePrivileges = sysRolePrivilegeService.list(queryWrapper);
-        if (sysRolePrivileges != null && sysRolePrivileges.size() > 0) {
-            throw ExceptionResultEnum.ERROR.exception("权限已绑定,不能删除");
-        }
-        return this.removeById(id);
-    }
-
     @Override
     public List<String> getRolePrivileges(Long roleId) {
         QueryWrapper<SysRolePrivilege> queryWrapper = new QueryWrapper<>();
@@ -301,40 +254,13 @@ public class SysPrivilegeServiceImpl extends ServiceImpl<SysPrivilegeMapper, Sys
         return new ArrayList<>(map.values());
     }
 
-    @Override
-    @CacheEvict(value = SystemConstant.CUSTOM_PRIVILEGE_CACHE)
-    public void removeCustomList() {
-
-    }
-
-    /**
-     * 获取自定义菜单
-     *
-     * @return
-     */
-    @Override
-    @Cacheable(value = SystemConstant.CUSTOM_PRIVILEGE_CACHE, unless = "#result == null")
-    public List<PrivilegeDto> addCustomList() {
-        return this.commonCustomList();
-    }
-
-    /**
-     * 更新自定义菜单
-     *
-     * @return
-     */
-    @Override
-    @CachePut(value = SystemConstant.CUSTOM_PRIVILEGE_CACHE, condition = "#result != null")
-    public List<PrivilegeDto> updateCustomList() {
-        return this.commonCustomList();
-    }
-
     /**
      * 自定义菜单公用
      *
      * @return
      */
-    private List<PrivilegeDto> commonCustomList() {
+    @Override
+    public List<PrivilegeDto> commonCustomList() {
         QueryWrapper<SysPrivilege> sysPrivilegeQueryWrapper = new QueryWrapper<>();
         sysPrivilegeQueryWrapper.lambda()
                 .eq(SysPrivilege::getEnable, true)
@@ -363,4 +289,15 @@ public class SysPrivilegeServiceImpl extends ServiceImpl<SysPrivilegeMapper, Sys
         }
         return privilegeDtoList;
     }
+
+    @Override
+    public boolean remove(Long id) {
+        QueryWrapper<SysRolePrivilege> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().eq(SysRolePrivilege::getPrivilegeId, id);
+        List<SysRolePrivilege> sysRolePrivileges = sysRolePrivilegeService.list(queryWrapper);
+        if (sysRolePrivileges != null && sysRolePrivileges.size() > 0) {
+            throw ExceptionResultEnum.ERROR.exception("权限已绑定,不能删除");
+        }
+        return this.removeById(id);
+    }
 }

+ 4 - 31
paper-library-common/src/main/java/com/qmth/paper/library/common/service/impl/SysRoleServiceImpl.java

@@ -19,7 +19,6 @@ import org.slf4j.LoggerFactory;
 import org.springframework.dao.DuplicateKeyException;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.util.CollectionUtils;
 
 import javax.annotation.Resource;
 import java.security.NoSuchAlgorithmException;
@@ -45,7 +44,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
     private SysRolePrivilegeService sysRolePrivilegeService;
 
     @Resource
-    private CommonCacheService commonCacheService;
+    LibraryCommonService libraryCommonService;
 
     @Resource
     SysRoleService sysRoleService;
@@ -102,7 +101,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
                 throw ExceptionResultEnum.ERROR.exception("自定义角色名称不能和系统默认角色【" + roleName + "】同名");
             }
             if (Objects.nonNull(role.getId())) {//编辑
-                List<SysRolePrivilege> sysRolePrivilegeList = commonCacheService.rolePrivilegeCache(role.getId());
+                List<SysRolePrivilege> sysRolePrivilegeList = libraryCommonService.getRolePrivilege(role.getId());
                 QueryWrapper<SysPrivilege> sysPrivilegeQueryWrapper = new QueryWrapper<>();
                 sysPrivilegeQueryWrapper.lambda().in(SysPrivilege::getId, role.getPrivilegeIds());
                 List<SysPrivilege> sysPrivilegeList = sysPrivilegeService.list(sysPrivilegeQueryWrapper);
@@ -122,18 +121,10 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
                 int count = (int) sysRolePrivilegeList.stream().filter(s -> relatedList.contains(s.getPrivilegeId())).count();
                 role.updateInfo(sysUser.getId());
                 sysRoleService.updateById(role);
-                if (Objects.isNull(commonCacheService.updateRoleCache(role.getId()))) {
-                    commonCacheService.removeRoleCache(role.getId());
-                }
+
                 if (count != sysRolePrivilegeList.size() || count != finalRelatedSet.size()) {
                     sysRolePrivilegeService.removeByRoleId(role.getId());
                     sysRolePrivilegeService.saveBatch(role);//角色权限
-                    if (CollectionUtils.isEmpty(commonCacheService.updateRolePrivilegeCache(role.getId()))) {
-                        commonCacheService.removeRolePrivilegeCache(role.getId());
-                    }
-                    //绑定该角色的用户都需要清除鉴权缓存
-                    List<SysUserRole> sysUserRoleList = sysUserRoleService.listByRoleId(role.getId());
-                    commonService.removeUserInfoBatch(sysUserRoleList.stream().map(SysUserRole::getUserId).collect(Collectors.toList()), true);
                 }
             } else {
                 role.insertInfo(sysUser.getId());
@@ -178,7 +169,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
                 throw ExceptionResultEnum.ERROR.exception("自定义角色名称不能和系统默认角色【" + roleName + "】同名");
             }
             if (Objects.nonNull(role.getId())) {//编辑
-                List<SysRolePrivilege> sysRolePrivilegeList = commonCacheService.rolePrivilegeCache(role.getId());
+                List<SysRolePrivilege> sysRolePrivilegeList = libraryCommonService.getRolePrivilege(role.getId());
                 QueryWrapper<SysPrivilege> sysPrivilegeQueryWrapper = new QueryWrapper<>();
                 sysPrivilegeQueryWrapper.lambda().in(SysPrivilege::getId, role.getPrivilegeIds());
                 List<SysPrivilege> sysPrivilegeList = sysPrivilegeService.list(sysPrivilegeQueryWrapper);
@@ -198,16 +189,10 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
                 int count = (int) sysRolePrivilegeList.stream().filter(s -> relatedList.contains(s.getPrivilegeId())).count();
                 role.updateInfo(sysUser.getId());
                 sysRoleService.updateById(role);
-                if (Objects.isNull(commonCacheService.updateRoleCache(role.getId()))) {
-                    commonCacheService.removeRoleCache(role.getId());
-                }
                 if (count != sysRolePrivilegeList.size() || count != finalRelatedSet.size()) {
                     // 删除权限前先更新涉及特殊权限用户 -> 需要重新同步
                     sysRolePrivilegeService.removeByRoleId(role.getId());
                     sysRolePrivilegeService.saveBatch(role);//角色权限
-                    if (CollectionUtils.isEmpty(commonCacheService.updateRolePrivilegeCache(role.getId()))) {
-                        commonCacheService.removeRolePrivilegeCache(role.getId());
-                    }
                     //绑定该角色的用户都需要清除鉴权缓存
                     List<SysUserRole> sysUserRoleList = sysUserRoleService.listByRoleId(role.getId());
                     commonService.removeUserInfoBatch(sysUserRoleList.stream().map(s -> s.getUserId()).collect(Collectors.toList()), true);
@@ -242,9 +227,6 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
                 .set(SysRoleGroupMember::getEnable, role.getEnable());
         sysRoleGroupMemberService.update(sysRoleGroupMemberUpdateWrapper);
 
-        if (Objects.isNull(commonCacheService.updateRoleCache(role.getId()))) {
-            commonCacheService.removeRoleCache(role.getId());
-        }
         //如果状态为禁用,需要踢下线重新登录
         if (!role.getEnable()) {
             List<SysUserRole> sysUserRoleList = sysUserRoleService.listByRoleId(role.getId());
@@ -261,9 +243,6 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
         updateWrapper.lambda().set(SysRole::getEnable, role.getEnable()).eq(SysRole::getId, role.getId());
         this.update(updateWrapper);
 
-        if (Objects.isNull(commonCacheService.updateRoleCache(role.getId()))) {
-            commonCacheService.removeRoleCache(role.getId());
-        }
         //如果状态为禁用,需要踢下线重新登录
         if (!role.getEnable()) {
             List<SysUserRole> sysUserRoleList = sysUserRoleService.listByRoleId(role.getId());
@@ -289,9 +268,6 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
         QueryWrapper<SysRoleGroupMember> sysRoleGroupMemberQueryWrapper = new QueryWrapper<>();
         sysRoleGroupMemberQueryWrapper.lambda().eq(SysRoleGroupMember::getRoleId, id);
         sysRoleGroupMemberService.remove(sysRoleGroupMemberQueryWrapper);
-
-        commonCacheService.removeRoleCache(id);
-        commonCacheService.removeRolePrivilegeCache(id);
         return true;
     }
 
@@ -307,9 +283,6 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
 
             // 删除用户角色
             sysUserRoleService.removeByRoleId(idLong);
-
-            commonCacheService.removeRoleCache(idLong);
-            commonCacheService.removeRolePrivilegeCache(idLong);
         }
         return true;
     }

+ 3 - 3
paper-library-common/src/main/java/com/qmth/paper/library/common/service/impl/SysUserRoleServiceImpl.java

@@ -7,7 +7,7 @@ import com.qmth.paper.library.common.entity.SysRole;
 import com.qmth.paper.library.common.entity.SysUser;
 import com.qmth.paper.library.common.entity.SysUserRole;
 import com.qmth.paper.library.common.mapper.SysUserRoleMapper;
-import com.qmth.paper.library.common.service.CommonCacheService;
+import com.qmth.paper.library.common.service.LibraryCommonService;
 import com.qmth.paper.library.common.service.SysUserRoleService;
 import com.qmth.paper.library.common.util.ServletUtil;
 import org.springframework.stereotype.Service;
@@ -27,7 +27,7 @@ import java.util.List;
 public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUserRole> implements SysUserRoleService {
 
     @Resource
-    CommonCacheService commonCacheService;
+    LibraryCommonService libraryCommonService;
 
     @Resource
     SysUserRoleMapper sysUserRoleMapper;
@@ -53,7 +53,7 @@ public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUs
     @Override
     public MenuResult listByUserId() {
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
-        return commonCacheService.userMenuCache(sysUser.getId());
+        return libraryCommonService.getUserMenu(sysUser.getId());
     }
 
     @Override

+ 2 - 24
paper-library-common/src/main/java/com/qmth/paper/library/common/service/impl/SysUserServiceImpl.java

@@ -67,9 +67,6 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
     @Resource
     private SysRolePrivilegeService sysRolePrivilegeService;
 
-    @Resource
-    CommonCacheService commonCacheService;
-
     @Resource
     private LibraryCommonService commonService;
 
@@ -194,9 +191,6 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
         UpdateWrapper<SysUser> updateWrapper = new UpdateWrapper<>();
         updateWrapper.lambda().set(SysUser::getEnable, user.getEnable()).eq(SysUser::getId, user.getId());
         boolean success = this.update(updateWrapper);
-        if (Objects.isNull(commonCacheService.updateUserCache(user.getId()))) {
-            commonCacheService.removeUserCache(user.getId());
-        }
         //如果状态为禁用,需要踢下线重新登录
         if (!user.getEnable()) {
             commonService.removeUserInfo(user.getId(), true);
@@ -298,7 +292,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
             schoolCode = basicSchool.getCode();
         }
         if (!schoolCode.equalsIgnoreCase(SystemConstant.ADMIN_CODE)) {
-            basicSchool = commonCacheService.schoolCache(schoolCode);
+            basicSchool = basicSchoolService.getBySchoolCode(schoolCode);
             if (Objects.isNull(basicSchool)) {
                 throw ExceptionResultEnum.SCHOOL_NO_DATA.exception();
             }
@@ -379,7 +373,6 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
     @Transactional
     public Long saveUserCommon(UserSaveParams userSaveParams, Long requestUserId) {
         SysUserService sysUserService = SpringContextHolder.getBean(SysUserService.class);
-        boolean isSuccess = true;
         Long resultUserId = null;
         try {
             Long schoolId = userSaveParams.getSchoolId();
@@ -413,7 +406,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
                 commonService.addUserRolePrivilege(sysUser, userSaveParams.getRoleIds());
             } else {//修改用户
                 resultUserId = sysUser.getId();
-                List<SysUserRole> sysUserRoleList = commonCacheService.userRolePrivilegeCache(sysUser.getId());
+                List<SysUserRole> sysUserRoleList = libraryCommonService.getUserRolePrivilege(sysUser.getId());
                 List<Long> userRolesList = Arrays.asList(userSaveParams.getRoleIds());
                 Set<Long> dbUserRolesList = sysUserRoleList.stream().map(SysUserRole::getRoleId).collect(Collectors.toSet());
                 int count = (int) dbUserRolesList.stream().filter(s -> !userRolesList.contains(s)).count();
@@ -443,29 +436,14 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
                         sysRoleGroupMemberService.remove(sysRoleGroupMemberQueryWrapper);
                     }
 
-                    commonCacheService.removeUserRolePrivilegeCache(sysUser.getId());
                     commonService.addUserRolePrivilege(sysUser, userSaveParams.getRoleIds());
                     commonService.removeUserInfo(sysUser.getId(), true);
                 } else if (!dbUser.getOrgId().equals(sysUser.getOrgId())) {
                     commonService.removeUserInfo(sysUser.getId(), true);
                 }
-                //如果修改了机构或手机号,需更新用户缓存
-                if (Objects.nonNull(dbUser.getOrgId())) {
-                    if (dbUser.getOrgId().longValue() != sysUser.getOrgId().longValue()
-                            || !Objects.equals(dbUser.getMobileNumber(), sysUser.getMobileNumber())) {
-                        if (Objects.isNull(commonCacheService.updateUserCache(sysUser.getId()))) {
-                            commonCacheService.removeUserCache(sysUser.getId());
-                        }
-                        if (Objects.isNull(commonCacheService.updateUserAuthCache(sysUser.getId()))) {
-                            commonCacheService.removeUserAuthCache(sysUser.getId());
-                        }
-                    }
-                }
-
             }
         } catch (Exception e) {
             log.error(SystemConstant.LOG_ERROR, e);
-            isSuccess = false;
             if (e instanceof DuplicateKeyException) {
                 String errorColumn = e.getCause().toString();
                 String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3).replaceAll("'", "");

+ 0 - 1
paper-library-common/src/main/java/com/qmth/paper/library/common/service/impl/TBSessionServiceImpl.java

@@ -16,5 +16,4 @@ import org.springframework.stereotype.Service;
  */
 @Service
 public class TBSessionServiceImpl extends ServiceImpl<TBSessionMapper, TBSession> implements TBSessionService {
-
 }

+ 0 - 136
paper-library-common/src/main/java/com/qmth/paper/library/common/util/AuthThirdUtil.java

@@ -1,136 +0,0 @@
-package com.qmth.paper.library.common.util;
-
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.qmth.boot.tools.signature.SignatureEntity;
-import com.qmth.boot.tools.signature.SignatureType;
-import com.qmth.paper.library.common.enums.ExceptionResultEnum;
-import com.qmth.paper.library.common.contant.SpringContextHolder;
-import com.qmth.paper.library.common.entity.BasicSchool;
-import com.qmth.paper.library.common.entity.TBSession;
-import com.qmth.paper.library.common.service.BasicSchoolService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.servlet.http.HttpServletRequest;
-import java.util.Optional;
-
-/**
- * @Description: 第三方鉴权util
- * @Param:
- * @return:
- * @Author: wangliang
- * @Date: 2022/5/27
- */
-public class AuthThirdUtil {
-    private final static Logger log = LoggerFactory.getLogger(AuthThirdUtil.class);
-
-    /**
-     * 鉴权
-     *
-     * @param expireTime
-     * @param authorization
-     * @return
-     */
-    public static TBSession hasPermissionLogout(Long expireTime, String authorization) {
-        RedisUtil redisUtil = SpringContextHolder.getBean(RedisUtil.class);
-        HttpServletRequest request = ServletUtil.getRequest();
-        String url = request.getServletPath();
-        //验证authorization
-        Optional.ofNullable(authorization).orElseThrow(() -> ExceptionResultEnum.AUTHORIZATION_INVALID.exception());
-        Optional.ofNullable(expireTime).orElseThrow(() -> ExceptionResultEnum.TIME_INVALID.exception());
-
-        String method = request.getMethod();
-        final SignatureEntity info = SignatureEntity.parse(authorization, method, url, expireTime);
-        Optional.ofNullable(info).orElseThrow(() -> ExceptionResultEnum.AUTHORIZATION_ERROR.exception());
-
-        if (!url.equalsIgnoreCase(info.getUri())) {
-            log.warn("url faile: url error");
-            throw ExceptionResultEnum.AUTHORIZATION_ERROR.exception();
-        }
-        if (!method.equalsIgnoreCase(info.getMethod())) {
-            log.warn("method faile: method error");
-            throw ExceptionResultEnum.AUTHORIZATION_ERROR.exception();
-        }
-        if (info.getTimestamp() > expireTime) {
-            log.warn("Authorization faile: session has expired, expire time=" + expireTime);
-            throw ExceptionResultEnum.TIME_INVALID.exception();
-        }
-        if (SignatureType.TOKEN != info.getType()) {
-            log.warn("Authorization faile: signature type is not Token");
-            throw ExceptionResultEnum.AUTHORIZATION_ERROR.exception();
-        }
-        TBSession tbSession = (TBSession) redisUtil.getUserSession(info.getInvoker());
-        Optional.ofNullable(tbSession).orElseThrow(() -> ExceptionResultEnum.AUTHORIZATION_ERROR.exception());
-        if (!info.validate(tbSession.getAccessToken())) {
-            log.warn("Authorization faile: token invalid, token is " + tbSession.getAccessToken());
-            throw ExceptionResultEnum.AUTHORIZATION_ERROR.exception();
-        }
-        return tbSession;
-    }
-
-    /**
-     * 鉴权
-     *
-     * @param expireTime
-     * @param authorization
-     * @return
-     */
-    public static BasicSchool hasPermission(Long expireTime, String authorization) {
-        return commonHasPermission(expireTime, authorization);
-    }
-
-    /**
-     * 鉴权
-     *
-     * @return
-     */
-    public static BasicSchool hasPermission() {
-        return commonHasPermission(ServletUtil.getRequestTime(), ServletUtil.getRequestAuthorization());
-    }
-
-    /**
-     * 公用方法
-     *
-     * @param expireTime
-     * @param authorization
-     * @return
-     */
-    protected static BasicSchool commonHasPermission(Long expireTime, String authorization) {
-        BasicSchoolService basicSchoolService = SpringContextHolder.getBean(BasicSchoolService.class);
-        HttpServletRequest request = ServletUtil.getRequest();
-        String url = request.getServletPath();
-        //验证authorization
-        Optional.ofNullable(authorization).orElseThrow(() -> ExceptionResultEnum.AUTHORIZATION_INVALID.exception());
-        Optional.ofNullable(expireTime).orElseThrow(() -> ExceptionResultEnum.TIME_INVALID.exception());
-
-        String method = request.getMethod();
-        final SignatureEntity info = SignatureEntity.parse(authorization, method, url, expireTime);
-        Optional.ofNullable(info).orElseThrow(() -> ExceptionResultEnum.AUTHORIZATION_ERROR.exception());
-
-        if (!url.equalsIgnoreCase(info.getUri())) {
-            log.warn("url faile: url error");
-            throw ExceptionResultEnum.AUTHORIZATION_ERROR.exception();
-        }
-        if (!method.equalsIgnoreCase(info.getMethod())) {
-            log.warn("method faile: method error");
-            throw ExceptionResultEnum.AUTHORIZATION_ERROR.exception();
-        }
-        if (info.getTimestamp() > expireTime) {
-            log.warn("Authorization faile: session has expired, expire time=" + expireTime);
-            throw ExceptionResultEnum.TIME_INVALID.exception();
-        }
-        if (SignatureType.SECRET != info.getType()) {
-            log.warn("Authorization faile: signature type is not Secret");
-            throw ExceptionResultEnum.AUTHORIZATION_ERROR.exception();
-        }
-        QueryWrapper<BasicSchool> basicSchoolQueryWrapper = new QueryWrapper<>();
-        basicSchoolQueryWrapper.lambda().eq(BasicSchool::getAccessKey, info.getInvoker());
-        BasicSchool basicSchool = basicSchoolService.getOne(basicSchoolQueryWrapper);
-        Optional.ofNullable(basicSchool).orElseThrow(() -> ExceptionResultEnum.AUTHORIZATION_ERROR.exception("没有学校信息"));
-        if (!info.validate(basicSchool.getAccessSecret())) {
-            log.warn("Authorization faile: secret invalid, secret is " + basicSchool.getAccessSecret());
-            throw ExceptionResultEnum.AUTHORIZATION_ERROR.exception();
-        }
-        return basicSchool;
-    }
-}

+ 2 - 171
paper-library-common/src/main/java/com/qmth/paper/library/common/util/AuthUtil.java

@@ -1,27 +1,13 @@
 package com.qmth.paper.library.common.util;
 
-import com.qmth.boot.api.annotation.Aac;
-import com.qmth.boot.api.annotation.BOOL;
 import com.qmth.boot.core.enums.Platform;
-import com.qmth.boot.tools.signature.SignatureType;
-import com.qmth.paper.library.common.enums.ExceptionResultEnum;
-import com.qmth.paper.library.common.enums.PrivilegePropertyEnum;
-import com.qmth.paper.library.common.enums.RoleTypeEnum;
-import com.qmth.paper.library.common.SignatureEntityTest;
-import com.qmth.paper.library.common.bean.auth.AuthBean;
 import com.qmth.paper.library.common.bean.auth.ExpireTimeBean;
-import com.qmth.paper.library.common.contant.SpringContextHolder;
 import com.qmth.paper.library.common.contant.SystemConstant;
-import com.qmth.paper.library.common.entity.SysUser;
-import com.qmth.paper.library.common.entity.TBSession;
-import com.qmth.paper.library.common.service.CommonCacheService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.web.method.HandlerMethod;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.util.*;
+import java.util.Calendar;
+import java.util.Date;
 
 /**
  * @Description: 鉴权工具类util
@@ -33,161 +19,6 @@ import java.util.*;
 public class AuthUtil {
     private final static Logger log = LoggerFactory.getLogger(AuthUtil.class);
 
-    static CommonCacheService commonCacheService = null;
-
-    /**
-     * admin鉴权
-     *
-     * @param request
-     * @param response
-     * @param handler
-     * @return
-     */
-    public static boolean adminAuthInterceptor(HttpServletRequest request, HttpServletResponse response, Object handler) {
-        String url = request.getServletPath();
-        commonCacheService = SpringContextHolder.getBean(CommonCacheService.class);
-        Set<String> privilegeUrl = commonCacheService.privilegeUrlCache(PrivilegePropertyEnum.NO_AUTH);
-        //无需鉴权的url
-        int noAuthCount = Objects.nonNull(privilegeUrl) ? (int) privilegeUrl.stream().filter(s -> s.equalsIgnoreCase(url)).count() : 0;
-        if (noAuthCount > 0) {
-            return true;
-        }
-        String method = request.getMethod();
-        if (url.equalsIgnoreCase(SystemConstant.ERROR)) {
-            throw ExceptionResultEnum.NOT_FOUND.exception();
-        }
-        Platform platform = ServletUtil.getRequestPlatform();
-        String deviceId = ServletUtil.getRequestDeviceId();
-        String authorization = ServletUtil.getRequestAuthorization();
-        Long time = ServletUtil.getRequestTime();
-        log.info("Start authorization: url:{}, method:{}, platform:{}, deviceId:{}, authorization:{}, time:{}", url,
-                method, platform, deviceId, authorization, time);
-
-        TBSession tbSession = authHeadCommon(platform, deviceId, authorization, time, method, url);
-        Long userId = Long.parseLong(tbSession.getIdentity());
-        SysUser sysUser = commonCacheService.userCache(userId);
-        request.setAttribute(SystemConstant.SESSION, tbSession);
-        request.setAttribute(SystemConstant.USER, sysUser);
-        return authFootCommon(userId, SystemConstant.USER_OAUTH_CACHE, request, response, handler);
-    }
-
-    /**
-     * 鉴权头公用
-     *
-     * @param platform
-     * @param deviceId
-     * @param authorization
-     * @param time
-     * @return
-     */
-    static TBSession authHeadCommon(Platform platform,
-                                    String deviceId,
-                                    String authorization,
-                                    long time,
-                                    String method,
-                                    String url) {
-        RedisUtil redisUtil = SpringContextHolder.getBean(RedisUtil.class);
-//        if (SystemConstant.expire(time)) {
-//            log.warn("Authorization faile: time expired, server time=" + System.currentTimeMillis());
-//            throw new BusinessException(ExceptionResultEnum.AUTHORIZATION_ERROR);
-//        }
-        //测试
-        final SignatureEntityTest info = SignatureEntityTest.parse(authorization);
-        //校验签名信息
-//        final SignatureInfo info = SignatureInfo.parse(method.toLowerCase(), url, time, authorization);
-        if (info == null) {
-            log.warn("Authorization faile: signature decode error");
-            throw ExceptionResultEnum.AUTHORIZATION_ERROR.exception();
-        }
-        if (SignatureType.TOKEN != info.getType()) {
-            log.warn("Authorization faile: signature type is not Token");
-            throw ExceptionResultEnum.AUTHORIZATION_ERROR.exception();
-        }
-        //校验session
-        String sessionId = info.getInvoker();
-        TBSession tbSession = (TBSession) redisUtil.getUserSession(sessionId);
-        if (Objects.isNull(tbSession)) {
-            log.warn("Authorization faile: session id not exists: " + sessionId);
-            throw ExceptionResultEnum.NOT_LOGIN.exception();
-        }
-        if (tbSession.getExpireTime() <= System.currentTimeMillis() || info.getTimestamp() > tbSession.getExpireTime()) {
-            log.warn("Authorization faile: session has expired, expire time=" + tbSession.getExpireTime());
-            throw ExceptionResultEnum.NOT_LOGIN.exception();
-        }
-        if (!info.validate(tbSession.getAccessToken())) {
-            log.warn("Authorization faile: access token invalid, session token is " + tbSession.getAccessToken());
-            throw ExceptionResultEnum.AUTHORIZATION_ERROR.exception();
-        }
-        if (!tbSession.getPlatform().equalsIgnoreCase(platform.name())) {
-            log.warn("Authorization faile: platform invalid, session platform is " + tbSession.getPlatform());
-            throw ExceptionResultEnum.AUTHORIZATION_ERROR.exception();
-        }
-        if (!tbSession.getDeviceId().equalsIgnoreCase(deviceId)) {
-            log.warn("Authorization faile: deviceId invalid, session deviceId is " + tbSession.getDeviceId());
-            throw ExceptionResultEnum.AUTHORIZATION_ERROR.exception();
-        }
-        return tbSession;
-    }
-
-    /**
-     * 鉴权尾公用
-     *
-     * @param userId
-     * @param type
-     * @param request
-     * @param response
-     * @param handler
-     * @return
-     */
-    static boolean authFootCommon(long userId,
-                                  String type,
-                                  HttpServletRequest request,
-                                  HttpServletResponse response,
-                                  Object handler) {
-        String url = request.getServletPath();
-        //验证权限
-        AuthBean authBean = type.contains(SystemConstant.USER_OAUTH_CACHE) ? authBean = commonCacheService.userAuthCache(userId) : null;
-        if (Objects.isNull(authBean)) {
-            throw ExceptionResultEnum.ROLE_ENABLE_AUTHORIZATION.exception();
-        }
-        request.setAttribute(SystemConstant.SCHOOL, authBean.getSchool());
-        request.setAttribute(SystemConstant.ORG, authBean.getOrg());
-
-        //超级系统管理员拥有所有权限
-        int count = Objects.nonNull(authBean) ? (int) authBean.getRoleList().stream().filter(s -> Objects.equals(s.getName(), RoleTypeEnum.ADMIN.getDesc())).count() : 0;
-        if (count > 0) {
-            return true;
-        }
-        //系统公用接口不拦截
-        Set<String> sysUrls = commonCacheService.privilegeUrlCache(PrivilegePropertyEnum.SYS, SystemConstant.getHeadOrUserSchoolId());
-        int sysCount = Objects.nonNull(sysUrls) ? (int) sysUrls.stream().filter(s -> s.equalsIgnoreCase(url)).count() : 0;
-        if (sysCount > 0) {
-            return true;
-        }
-        HandlerMethod handlerMethod = (HandlerMethod) handler;
-        Map<String, Boolean> map = new HashMap<>();
-        Aac beanTypeAac = handlerMethod.getBeanType().getAnnotation(Aac.class);
-        Aac classAac = handlerMethod.getMethodAnnotation(Aac.class);
-        if (Objects.nonNull(beanTypeAac)) {
-            map.computeIfAbsent(SystemConstant.AUTH, v -> beanTypeAac.auth() == BOOL.TRUE ? true : false);
-        }
-        if (Objects.nonNull(classAac)) {
-            map.computeIfAbsent(SystemConstant.AUTH, v -> classAac.auth() == BOOL.TRUE ? true : false);
-        }
-
-        if (Objects.nonNull(map.get(SystemConstant.AUTH)) && !map.get(SystemConstant.AUTH)) {
-            return true;
-        }
-        Set<String> urls = authBean.getUrls();
-        int privilegeCount = Objects.nonNull(urls) ? (int) urls.stream().filter(s -> s.equalsIgnoreCase(url)).count() : 0;
-        if (privilegeCount == 0) {
-            log.warn("Authorization faile: url cannot access");
-            throw ExceptionResultEnum.UN_AUTHORIZATION.exception();
-        }
-        response.setStatus(ExceptionResultEnum.SUCCESS.getCode());
-        return true;
-    }
-
     /**
      * 获取过期时间
      *

+ 1 - 41
paper-library-common/src/main/java/com/qmth/paper/library/common/util/ConvertUtil.java

@@ -1,7 +1,7 @@
 package com.qmth.paper.library.common.util;
 
-import com.qmth.paper.library.common.enums.ExceptionResultEnum;
 import com.qmth.paper.library.common.contant.SystemConstant;
+import com.qmth.paper.library.common.enums.ExceptionResultEnum;
 import org.apache.pdfbox.pdmodel.PDDocument;
 import org.apache.pdfbox.pdmodel.PDPageTree;
 import org.apache.pdfbox.rendering.PDFRenderer;
@@ -10,17 +10,13 @@ import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.CellType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.data.redis.support.atomic.RedisAtomicLong;
 import org.springframework.stereotype.Component;
 
-import javax.annotation.Resource;
 import javax.imageio.ImageIO;
 import javax.servlet.http.HttpServletResponse;
 import java.awt.image.BufferedImage;
 import java.io.*;
 import java.net.URLEncoder;
-import java.text.DecimalFormat;
 import java.text.SimpleDateFormat;
 import java.util.*;
 
@@ -34,9 +30,6 @@ import java.util.*;
 public class ConvertUtil {
     private final static Logger log = LoggerFactory.getLogger(ConvertUtil.class);
 
-    @Resource
-    RedisTemplate<String, Object> redisTemplate;
-
     // inputStream转outputStream
     public static ByteArrayOutputStream parse(final InputStream in) throws Exception {
         final ByteArrayOutputStream swapStream = new ByteArrayOutputStream();
@@ -168,39 +161,6 @@ public class ConvertUtil {
     }
 
 
-    /**
-     * 获取递增序列号
-     *
-     * @param prefix 前缀
-     * @param model  模块
-     * @param digit  补齐位数
-     * @return 序列号
-     */
-    public String getIncre(String prefix, String model, int digit) {
-        StringBuilder temp = new StringBuilder();
-        for (int i = 0; i < digit; i++) {
-            temp.append("0");
-        }
-        //序列号前缀加特定标识,如系统模块名之类的 防止重复
-        String key = model + prefix;
-        String increResult = "";
-        try {
-            //如果该key不存在 会自动创建,值为第二个参数delta
-            //最终调用的还是jedis的incrBy(byte[] key, long value)方法
-            RedisAtomicLong counter = new RedisAtomicLong(key, Objects.requireNonNull(redisTemplate.getConnectionFactory()));
-            Long increment = counter.incrementAndGet();
-            //不足补位
-            DecimalFormat df = new DecimalFormat(temp.toString());
-            increResult = prefix + df.format(increment);
-        } catch (Exception e) {
-            // TODO: 2021/4/16  
-            System.out.println("获取序列号失败");
-            /*这里可以根据需求手动生成一个不重复的单号,
-             * */
-        }
-        return increResult;
-    }
-
     /**
      * 解析excel单元格类型
      *

+ 0 - 266
paper-library-common/src/main/java/com/qmth/paper/library/common/util/RedisUtil.java

@@ -1,266 +0,0 @@
-package com.qmth.paper.library.common.util;
-
-import com.qmth.paper.library.common.contant.SystemConstant;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.Resource;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-
-/**
- * @Description: redis util
- * @Param:
- * @return:
- * @Author: wangliang
- * @Date: 2020/4/15
- */
-@Component
-public class RedisUtil {
-
-    @Resource
-    RedisTemplate<String, Object> redisTemplate;
-
-    /**
-     * 获取用户会话信息
-     *
-     * @param sessionId
-     * @return
-     */
-    public Object getUserSession(String sessionId) {
-        return redisTemplate.opsForValue().get(SystemConstant.SESSION + sessionId);
-    }
-
-    /**
-     * 删除用户会话缓存
-     *
-     * @param sessionId
-     */
-    public void deleteUserSession(String sessionId) {
-        redisTemplate.delete(SystemConstant.SESSION + sessionId);
-    }
-
-    /**
-     * 设置用户session信息
-     *
-     * @param sessionId
-     * @param o
-     * @param time
-     */
-    public void setUserSession(String sessionId, Object o, long time) {
-        redisTemplate.opsForValue().set(SystemConstant.SESSION + sessionId, o, time, TimeUnit.SECONDS);
-    }
-
-    /**
-     * 获取过期时间
-     *
-     * @param sessionId
-     * @return
-     */
-    public Long getUserSessionExpire(String sessionId) {
-        return redisTemplate.opsForValue().getOperations().getExpire(SystemConstant.SESSION + sessionId);
-    }
-
-    /**
-     * 批量获取key的value
-     *
-     * @param keys
-     * @return
-     */
-    public List<?> multiGet(Set keys) {
-        return redisTemplate.opsForValue().multiGet(keys);
-    }
-
-    /**
-     * 获取key like
-     *
-     * @param key
-     * @return
-     */
-    public Set<?> getKeyPatterns(String key) {
-        if (Objects.nonNull(key)) {
-            return redisTemplate.keys(key);
-        } else {
-            return null;
-        }
-    }
-
-    /**
-     * 设置hash
-     *
-     * @param key
-     * @param hashKey
-     * @param hashValue
-     */
-    public void set(String key, String hashKey, Object hashValue) {
-        redisTemplate.opsForHash().put(key, hashKey, hashValue);
-    }
-
-    /**
-     * 获取hash
-     *
-     * @param key
-     * @param hashKey
-     * @return
-     */
-    public Object get(String key, String hashKey) {
-        return redisTemplate.opsForHash().get(key, hashKey);
-    }
-
-    /**
-     * hash删除
-     *
-     * @param key
-     * @param hashKey
-     */
-    public void delete(String key, String hashKey) {
-        redisTemplate.opsForHash().delete(key, hashKey);
-    }
-
-    /**
-     * 获取hash大小
-     *
-     * @param key
-     * @return
-     */
-    public Long getHashSize(String key) {
-        return redisTemplate.opsForHash().size(key);
-    }
-
-    /**
-     * 获取hash map
-     *
-     * @param key
-     * @return
-     */
-    public Map getHashEntries(String key) {
-        return redisTemplate.opsForHash().entries(key);
-    }
-
-    /**
-     * 分布式锁
-     *
-     * @param key
-     * @param timeout SECONDS
-     * @return
-     */
-    public boolean lock(String key, long timeout) {
-        long expireAt = System.currentTimeMillis() + (timeout * 1000) + 1;
-        return redisTemplate.opsForValue().setIfAbsent(key, expireAt, timeout, TimeUnit.SECONDS);
-    }
-
-    /**
-     * 删除锁
-     *
-     * @param key
-     * @return
-     */
-    public void releaseLock(String key) {
-        redisTemplate.expire(key, 100, TimeUnit.MILLISECONDS);
-    }
-
-    /**
-     * 设置缓存
-     *
-     * @param key
-     * @param o
-     */
-    public void set(String key, Object o) {
-        redisTemplate.opsForValue().set(key, o);
-    }
-
-    /**
-     * 设置缓存
-     *
-     * @param key
-     * @param o
-     * @param time
-     * @param timeUnit
-     */
-    public void set(String key, Object o, long time, TimeUnit timeUnit) {
-        redisTemplate.opsForValue().set(key, o, time, timeUnit);
-    }
-
-    /**
-     * 设置缓存
-     *
-     * @param key
-     * @param o
-     * @param time SECONDS
-     */
-    public void set(String key, Object o, long time) {
-        set(key, o, time, TimeUnit.SECONDS);
-    }
-
-    /**
-     * 获取缓存
-     *
-     * @param key
-     * @return
-     */
-    public Object get(String key) {
-        return redisTemplate.opsForValue().get(key);
-    }
-
-    /**
-     * 删除缓存
-     *
-     * @param key
-     * @return
-     */
-    public void delete(String key) {
-        redisTemplate.expire(key, 0, TimeUnit.SECONDS);
-    }
-
-    /**
-     * 保存hash结构
-     *
-     * @param key
-     * @param map
-     */
-    public void setForHash(String key, Map<String, Object> map) {
-        redisTemplate.opsForHash().putAll(key, map);
-    }
-
-    /**
-     * 保存list
-     *
-     * @param key
-     * @param Object
-     */
-    public void setForLeftList(String key, Object Object) {
-        redisTemplate.opsForList().leftPush(key, Object);
-    }
-
-    /**
-     * 获取list
-     *
-     * @param key
-     */
-    public Object getForRightList(String key) {
-        return redisTemplate.opsForList().rightPop(key, 0, TimeUnit.SECONDS);
-    }
-
-    /**
-     * 设置过期时间(秒)
-     *
-     * @param key
-     * @param timeOutSecond
-     */
-    public void expire(String key, int timeOutSecond) {
-        redisTemplate.expire(key, timeOutSecond, TimeUnit.SECONDS);
-    }
-
-    /**
-     * 设置过期时间
-     *
-     * @param key
-     * @param timeOut
-     */
-    public void expire(String key, long timeOut, TimeUnit timeUnit) {
-        redisTemplate.expire(key, timeOut, timeUnit);
-    }
-}

+ 1 - 1
paper-library/src/main/java/com/qmth/paper/library/PaperLibraryApplication.java

@@ -21,7 +21,7 @@ import javax.annotation.Resource;
 //用来扫描和发现指定包及其子包中的Entity定义
 @EnableTransactionManagement // spring开启事务支持
 @EnableAsync // 开启异步任务
-@EnableCaching // 开启缓存注解
+@EnableCaching
 public class PaperLibraryApplication {
 
     public static void main(String[] args) {

+ 3 - 3
paper-library/src/main/java/com/qmth/paper/library/api/ClientController.java

@@ -14,7 +14,7 @@ import com.qmth.paper.library.common.entity.BasicSchool;
 import com.qmth.paper.library.common.entity.SysUser;
 import com.qmth.paper.library.common.enums.AppSourceEnum;
 import com.qmth.paper.library.common.enums.ExceptionResultEnum;
-import com.qmth.paper.library.common.service.CommonCacheService;
+import com.qmth.paper.library.common.service.BasicSchoolService;
 import com.qmth.paper.library.common.service.LibraryCommonService;
 import com.qmth.paper.library.common.service.SysUserService;
 import com.qmth.paper.library.common.util.Result;
@@ -50,7 +50,7 @@ public class ClientController {
     SysUserService sysUserService;
 
     @Resource
-    CommonCacheService commonCacheService;
+    BasicSchoolService basicSchoolService;
 
     @Resource
     LibraryCommonService libraryCommonService;
@@ -69,7 +69,7 @@ public class ClientController {
             return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
         }
 
-        BasicSchool basicSchool = commonCacheService.schoolCache(login.getSchoolCode());
+        BasicSchool basicSchool = basicSchoolService.getBySchoolCode(login.getSchoolCode());
         if (Objects.isNull(basicSchool)) {
             throw ExceptionResultEnum.SCHOOL_NO_DATA.exception();
         }

+ 5 - 29
paper-library/src/main/java/com/qmth/paper/library/api/MenuCustomController.java

@@ -7,9 +7,7 @@ import com.qmth.paper.library.business.bean.params.TSchoolPrivilegeParam;
 import com.qmth.paper.library.business.bean.result.CustomPrivilegeResult;
 import com.qmth.paper.library.business.bean.result.TSchoolPrivilegeResult;
 import com.qmth.paper.library.common.bean.dto.PrivilegeDto;
-import com.qmth.paper.library.common.contant.SystemConstant;
 import com.qmth.paper.library.common.entity.*;
-import com.qmth.paper.library.common.enums.ExceptionResultEnum;
 import com.qmth.paper.library.common.service.*;
 import com.qmth.paper.library.common.util.Result;
 import com.qmth.paper.library.common.util.ResultUtil;
@@ -53,7 +51,7 @@ public class MenuCustomController {
     SysRoleService sysRoleService;
 
     @Resource
-    CommonCacheService commonCacheService;
+    SysUserService sysUserService;
 
     @Resource
     SysUserRoleService sysUserRoleService;
@@ -68,10 +66,8 @@ public class MenuCustomController {
     @ApiResponses({@ApiResponse(code = 200, message = "菜单权限信息", response = SysPrivilege.class)})
     @RequestMapping(value = "/custom/list", method = RequestMethod.POST)
     public Result customList() {
-        List<PrivilegeDto> customPrivilegeList = sysPrivilegeService.addCustomList();
-        SysConfig sysConfig = commonCacheService.addSysConfigCache(SystemConstant.SYS_PDF_SIZE_LIST);
-        Optional.ofNullable(sysConfig).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未配置全局pdf格式清单"));
-        return ResultUtil.ok(new CustomPrivilegeResult(customPrivilegeList, Arrays.asList(sysConfig.getConfigValue().replaceAll("\\[", "").replaceAll("\\]", "").split(", "))));
+        List<PrivilegeDto> customPrivilegeList = sysPrivilegeService.commonCustomList();
+        return ResultUtil.ok(new CustomPrivilegeResult(customPrivilegeList));
     }
 
     @ApiOperation(value = "学校新增/修改自定义菜单权限")
@@ -123,16 +119,10 @@ public class MenuCustomController {
         //清缓存
         if (!CollectionUtils.isEmpty(roleSetIds)) {
             for (Long l : roleSetIds) {
-                if (Objects.isNull(commonCacheService.updateRoleCache(l))) {
-                    commonCacheService.removeRoleCache(l);
-                }
-                if (CollectionUtils.isEmpty(commonCacheService.updateRolePrivilegeCache(l))) {
-                    commonCacheService.removeRolePrivilegeCache(l);
-                }
                 //绑定该角色的用户都需要清除鉴权缓存
                 List<SysUserRole> sysUserRoleList = sysUserRoleService.listByRoleId(l);
                 for (SysUserRole s : sysUserRoleList) {
-                    SysUser user = commonCacheService.userCache(s.getUserId());
+                    SysUser user = sysUserService.getById(s.getUserId());
                     if (Objects.nonNull(user)) {
                         commonService.removeUserInfo(s.getUserId(), true);
                     } else {
@@ -141,19 +131,6 @@ public class MenuCustomController {
                 }
             }
         }
-
-        SysConfig sysConfig = commonCacheService.addSysConfigCache(tSchoolPrivilegeParam.getSchoolId(), SystemConstant.PDF_SIZE_LIST);
-        if (Objects.isNull(sysConfig)) {
-            sysConfig = new SysConfig(tSchoolPrivilegeParam.getSchoolId(), SystemConstant.PDF_SIZE_LIST, "pdf格式清单", Arrays.asList(tSchoolPrivilegeParam.getPdfSize()).toString());
-        } else {
-            if (Objects.nonNull(tSchoolPrivilegeParam.getPdfSize()) && tSchoolPrivilegeParam.getPdfSize().length > 0) {
-                sysConfig.setConfigValue(Arrays.asList(tSchoolPrivilegeParam.getPdfSize()).toString());
-            } else {
-                sysConfig.setConfigValue(null);
-            }
-        }
-        sysConfigService.saveOrUpdate(sysConfig);
-        commonCacheService.removeSysConfigCache(tSchoolPrivilegeParam.getSchoolId(), SystemConstant.PDF_SIZE_LIST);
         return ResultUtil.ok(true);
     }
 
@@ -163,7 +140,6 @@ public class MenuCustomController {
     public Result getRolePrivileges(@RequestParam(value = "schoolId", required = true) Long schoolId) {
         List<TSchoolPrivilege> tSchoolPrivilegeList = tSchoolPrivilegeService.findBySchoolId(schoolId);
         List<String> privilegeIdList = tSchoolPrivilegeList.stream().map(s -> String.valueOf(s.getPrivilegeId())).collect(Collectors.toList());
-        SysConfig sysConfig = commonCacheService.addSysConfigCache(schoolId, SystemConstant.PDF_SIZE_LIST);
-        return ResultUtil.ok(new TSchoolPrivilegeResult(schoolId, privilegeIdList, Objects.nonNull(sysConfig) ? Arrays.asList(sysConfig.getConfigValue().replaceAll("\\[", "").replaceAll("\\]", "").split(", ")) : null));
+        return ResultUtil.ok(new TSchoolPrivilegeResult(schoolId, privilegeIdList));
     }
 }

+ 11 - 15
paper-library/src/main/java/com/qmth/paper/library/api/SysController.java

@@ -18,7 +18,10 @@ import com.qmth.paper.library.common.entity.BasicAttachment;
 import com.qmth.paper.library.common.entity.BasicSchool;
 import com.qmth.paper.library.common.entity.SysRole;
 import com.qmth.paper.library.common.entity.SysUser;
-import com.qmth.paper.library.common.enums.*;
+import com.qmth.paper.library.common.enums.AppSourceEnum;
+import com.qmth.paper.library.common.enums.ExceptionResultEnum;
+import com.qmth.paper.library.common.enums.RoleTypeEnum;
+import com.qmth.paper.library.common.enums.UploadFileEnum;
 import com.qmth.paper.library.common.service.*;
 import com.qmth.paper.library.common.util.Result;
 import com.qmth.paper.library.common.util.ResultUtil;
@@ -48,6 +51,9 @@ import java.util.stream.Collectors;
 public class SysController {
     private final static Logger log = LoggerFactory.getLogger(SysController.class);
 
+    @Resource
+    BasicSchoolService basicSchoolService;
+
     @Resource
     SysUserService sysUserService;
 
@@ -57,9 +63,6 @@ public class SysController {
     @Resource
     DictionaryConfig dictionaryConfig;
 
-    @Resource
-    CommonCacheService commonCacheService;
-
     @Resource
     PaperLibraryCommonService paperLibraryCommonService;
 
@@ -95,7 +98,7 @@ public class SysController {
 
         BasicSchool basicSchool = null;
         if (!login.getSchoolCode().equalsIgnoreCase(SystemConstant.ADMIN_CODE)) {
-            basicSchool = commonCacheService.schoolCache(login.getSchoolCode());
+            basicSchool = basicSchoolService.getBySchoolCode(login.getSchoolCode());
             if (Objects.isNull(basicSchool)) {
                 throw ExceptionResultEnum.SCHOOL_NO_DATA.exception();
             }
@@ -216,7 +219,7 @@ public class SysController {
         }
         QueryWrapper<SysUser> wrapper = new QueryWrapper<>();
         if (StringUtils.isNotBlank(loginParam.getSchoolCode())) {
-            BasicSchool basicSchool = commonCacheService.schoolCache(loginParam.getSchoolCode());
+            BasicSchool basicSchool = basicSchoolService.getBySchoolCode(loginParam.getSchoolCode());
             if (Objects.nonNull(basicSchool)) {
                 wrapper.lambda().eq(SysUser::getSchoolId, basicSchool.getId());
             }
@@ -270,7 +273,7 @@ public class SysController {
             throw ExceptionResultEnum.ERROR.exception("学校代码不能为空");
         }
         QueryWrapper<SysUser> wrapper = new QueryWrapper<>();
-        BasicSchool basicSchool = commonCacheService.schoolCache(loginParam.getSchoolCode());
+        BasicSchool basicSchool = basicSchoolService.getBySchoolCode(loginParam.getSchoolCode());
         if (Objects.isNull(basicSchool)) {
             throw ExceptionResultEnum.ERROR.exception("学校不存在");
         }
@@ -325,7 +328,7 @@ public class SysController {
             code = code.substring(0, code.indexOf("#"));
         }
         if (!code.equalsIgnoreCase(SystemConstant.ADMIN_CODE)) {
-            BasicSchool basicSchool = commonCacheService.schoolCache(code);
+            BasicSchool basicSchool = basicSchoolService.getBySchoolCode(code);
             Optional.ofNullable(basicSchool).orElseThrow(() -> ExceptionResultEnum.SCHOOL_NO_DATA.exception());
             authInfoService.appHasExpired(code);
             Map<String, String> map = new HashMap<>();
@@ -404,11 +407,4 @@ public class SysController {
         return ResultUtil.ok(System.currentTimeMillis());
     }
 
-    @ApiOperation(value = "获取系统编码")
-    @RequestMapping(value = "/get_code", method = RequestMethod.POST)
-    public Result getCode(@ApiParam(value = "编码类型", required = true) @RequestParam SystemCodeEnum type) {
-        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
-        String number = libraryCommonService.getSysIncrCode(type, sysUser);
-        return ResultUtil.ok((Object) number);
-    }
 }

+ 14 - 13
paper-library/src/main/java/com/qmth/paper/library/auth/PaperLibraryAuthenticationService.java

@@ -14,7 +14,8 @@ import com.qmth.paper.library.common.enums.PrivilegePropertyEnum;
 import com.qmth.paper.library.common.enums.RoleTypeEnum;
 import com.qmth.paper.library.common.service.AuthInfoService;
 import com.qmth.paper.library.common.service.CommonCacheService;
-import com.qmth.paper.library.common.util.RedisUtil;
+import com.qmth.paper.library.common.service.LibraryCommonService;
+import com.qmth.paper.library.common.service.SysUserService;
 import com.qmth.paper.library.common.util.ServletUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -32,9 +33,11 @@ public class PaperLibraryAuthenticationService implements AuthorizationService {
 
     @Resource
     CommonCacheService commonCacheService;
+    @Resource
+    LibraryCommonService libraryCommonService;
 
     @Resource
-    RedisUtil redisUtil;
+    SysUserService sysUserService;
 
     @Resource
     DictionaryConfig dictionaryConfig;
@@ -50,7 +53,7 @@ public class PaperLibraryAuthenticationService implements AuthorizationService {
     @Override
     public boolean hasPermission(AccessEntity accessEntity, String path) {
         if (Objects.nonNull(accessEntity) && Objects.nonNull(accessEntity.getIdentity())) {
-            TBSession tbSession = (TBSession) redisUtil.getUserSession(accessEntity.getIdentity());
+            TBSession tbSession = commonCacheService.getTbSession(accessEntity.getIdentity());
             if (Objects.isNull(tbSession)) {
                 log.warn("Authorization faile: session id not exists: {}", accessEntity.getIdentity());
                 throw ExceptionResultEnum.NOT_LOGIN.exception();
@@ -70,22 +73,22 @@ public class PaperLibraryAuthenticationService implements AuthorizationService {
                 throw ExceptionResultEnum.AUTHORIZATION_ERROR.exception();
             }
             Long userId = Long.parseLong(tbSession.getIdentity());
-            SysUser sysUser = commonCacheService.userCache(userId);
+            SysUser sysUser = sysUserService.getById(userId);
             HttpServletRequest request = ServletUtil.getRequest();
             HttpServletResponse response = ServletUtil.getResponse();
             request.setAttribute(SystemConstant.SESSION, tbSession);
             request.setAttribute(SystemConstant.USER, sysUser);
-            boolean auth = authFootCommon(userId, SystemConstant.USER_OAUTH_CACHE, path, request, response);
+            boolean auth = authFootCommon(userId, path, request, response);
             if (auth) {
-                Long expireTime = redisUtil.getUserSessionExpire(accessEntity.getIdentity());
-                if (Objects.nonNull(expireTime) && expireTime.longValue() > -1L) {
+//                Long expireTime = redisUtil.getUserSessionExpire(accessEntity.getIdentity());
+//                if (Objects.nonNull(expireTime) && expireTime.longValue() > -1L) {
                     if (Objects.nonNull(tbSession.getLastAccessTime()) && (System.currentTimeMillis() - tbSession.getLastAccessTime()) / 1000 > dictionaryConfig.sysDomain().getSessionActive().getSeconds()) {
                         log.warn("Authorization faile: session active, session active is {}", dictionaryConfig.sysDomain().getSessionActive().getSeconds());
                         throw ExceptionResultEnum.NOT_LOGIN.exception();
                     }
                     tbSession.setLastInfo();
-                    redisUtil.setUserSession(accessEntity.getIdentity(), tbSession, expireTime);
-                }
+//                    redisUtil.setUserSession(accessEntity.getIdentity(), tbSession, expireTime);
+//                }
             }
             return auth;
         }
@@ -96,19 +99,17 @@ public class PaperLibraryAuthenticationService implements AuthorizationService {
      * 鉴权尾公用
      *
      * @param userId
-     * @param type
      * @param path
      * @param request
      * @param response
      * @return
      */
     public boolean authFootCommon(Long userId,
-                                  String type,
                                   String path,
                                   HttpServletRequest request,
                                   HttpServletResponse response) {
         //验证权限
-        AuthBean authBean = type.contains(SystemConstant.USER_OAUTH_CACHE) ? authBean = commonCacheService.userAuthCache(userId) : null;
+        AuthBean authBean = libraryCommonService.getUserAuth(userId);
         if (Objects.isNull(authBean)) {
             throw ExceptionResultEnum.ROLE_ENABLE_AUTHORIZATION.exception();
         }
@@ -124,7 +125,7 @@ public class PaperLibraryAuthenticationService implements AuthorizationService {
             authInfoService.appHasExpired(authBean.getSchool().getCode());
         }
         //系统公用接口不拦截
-        Set<String> sysUrls = commonCacheService.privilegeUrlCache(PrivilegePropertyEnum.SYS, SystemConstant.getHeadOrUserSchoolId());
+        Set<String> sysUrls = libraryCommonService.getPrivilegeUrl(PrivilegePropertyEnum.SYS, SystemConstant.getHeadOrUserSchoolId());
         int sysCount = Objects.nonNull(sysUrls) ? (int) sysUrls.stream().filter(s -> s.equalsIgnoreCase(path)).count() : 0;
         if (sysCount > 0) {
             return true;

+ 3 - 3
paper-library/src/main/java/com/qmth/paper/library/auth/PaperLibrarySession.java

@@ -4,7 +4,7 @@ import com.qmth.boot.core.security.model.AccessEntity;
 import com.qmth.boot.tools.signature.SignatureType;
 import com.qmth.paper.library.common.contant.SpringContextHolder;
 import com.qmth.paper.library.common.entity.TBSession;
-import com.qmth.paper.library.common.util.RedisUtil;
+import com.qmth.paper.library.common.service.CommonCacheService;
 
 import java.util.Collection;
 import java.util.Objects;
@@ -31,8 +31,8 @@ public class PaperLibrarySession implements AccessEntity {
 
     @Override
     public String getSecret() {
-        RedisUtil redisUtil = SpringContextHolder.getBean(RedisUtil.class);
-        TBSession tbSession = (TBSession) redisUtil.getUserSession(identity);
+        CommonCacheService commonCacheService = SpringContextHolder.getBean(CommonCacheService.class);
+        TBSession tbSession = commonCacheService.getTbSession(identity);
         return Objects.nonNull(tbSession) ? tbSession.getAccessToken() : null;
     }
 

+ 1 - 7
paper-library/src/main/resources/application-dev.properties

@@ -17,12 +17,6 @@ com.qmth.datasource.username=${db.username}
 com.qmth.datasource.password=${db.password}
 com.qmth.mybatis.log-level=debug
 
-#---------redis config---------------
-com.qmth.redis.host=${db.host}
-com.qmth.redis.port=6379
-com.qmth.redis.db=3
-#com.qmth.redis.password=
-
 #---------sys config-----------------
 sys.config.oss=false
 sys.config.attachmentType=.xlsx,.xls,.doc,.docx,.pdf,.jpg,.jpeg,.png,.html,.zip,.mp3,.wav,.dll,.exe,.ftl,.bpmn,.xml
@@ -68,7 +62,7 @@ prefix.url.auth=admin/auth
 prefix.url.paper=admin/paper
 prefix.url.client=admin/client
 
-
+spring.cache.ehcache.config=classpath:static/ehcache.xml
 spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
 spring.jackson.time-zone=GMT+8
 

+ 45 - 0
paper-library/src/main/resources/static/ehcache.xml

@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd"
+         updateCheck="false">
+
+    <!-- diskStore:ehcache其实是支持内存+磁盘+堆外内存,几个层级的缓存 -->
+    <!-- 在这里设置一下,但是一般不用的 -->
+    <diskStore path="java.io.tmpdir/Tmp_EhCache" />
+
+    <!-- defaultCache,是默认的缓存策略 -->
+    <!-- 如果你指定的缓存策略没有找到,那么就用这个默认的缓存策略 -->
+    <!-- external:如果设置为true的话,那么timeout就没有效果,缓存就会一直存在,一般默认就是false -->
+    <!-- maxElementsInMemory:内存中可以缓存多少个缓存条目,在实践中,你是需要自己去计算的,比如你计算你要缓存的对象是什么?有多大?最多可以缓存多少MB,或者多少个G的数据?除以每个对象的大小,计算出最多可以放多少个对象 -->
+    <!-- overflowToDisk:如果内存不够的时候,是否溢出到磁盘 -->
+    <!-- diskPersistent:是否启用磁盘持久化的机制,在jvm崩溃的时候和重启之间,不用 -->
+    <!-- timeToIdleSeconds:对象最大的闲置的时间,如果超出闲置的时间,可能就会过期,我们这里就不用了,缓存最多闲置5分钟就被干掉了 -->
+    <!-- timeToLiveSeconds:对象最多存活的时间,我们这里也不用,超过这个时间,缓存就过期,就没了 -->
+    <!-- memoryStoreEvictionPolicy:当缓存数量达到了最大的指定条目数的时候,需要采用一定的算法,从缓存中清除一批数据,LRU,最近最少使用算法,最近一段时间内,最少使用的那些数据,就被干掉了 -->
+    <defaultCache
+            eternal="false"
+            maxElementsInMemory="1000"
+            overflowToDisk="false"
+            diskPersistent="false"
+            timeToIdleSeconds="0"
+            timeToLiveSeconds="0"
+            memoryStoreEvictionPolicy="LRU" />
+
+    <!-- 手动指定的缓存策略 -->
+    <!-- 比如你一个应用吧,可能要缓存很多种不同的数据,比如说商品信息,或者是其他的一些数据 -->
+    <!-- 对不同的数据,缓存策略可以在这里配置多种 -->
+    <cache
+            name="paperLibraryCache"
+            eternal="false"
+            maxElementsInMemory="1000"
+            overflowToDisk="false"
+            diskPersistent="false"
+            timeToIdleSeconds="0"
+            timeToLiveSeconds="0"
+            memoryStoreEvictionPolicy="LRU" />
+
+    <!-- ehcache这种东西,简单实用,是很快速的,1小时上手可以用在项目里了,没什么难度的 -->
+    <!-- ehcache这个技术,如果讲深了,里面的东西还是很多的,高级的feature,但是我们这里就不涉及了 -->
+
+</ehcache>
+

+ 0 - 5
pom.xml

@@ -104,11 +104,6 @@
                 <artifactId>core-fss</artifactId>
                 <version>${qmth.boot.version}</version>
             </dependency>
-            <dependency>
-                <groupId>com.qmth.boot</groupId>
-                <artifactId>data-redis</artifactId>
-                <version>${qmth.boot.version}</version>
-            </dependency>
             <dependency>
                 <groupId>com.qmth.boot</groupId>
                 <artifactId>data-mybatis-plus</artifactId>