wangliang 2 жил өмнө
parent
commit
4c3cb23e59

+ 7 - 6
paper-library-common/src/main/java/com/qmth/paper/library/common/service/impl/AuthInfoServiceImpl.java

@@ -7,19 +7,18 @@ import com.qmth.boot.core.solar.model.OrgInfo;
 import com.qmth.boot.core.solar.service.SolarService;
 import com.qmth.paper.library.common.bean.dto.AuthOrgInfoDto;
 import com.qmth.paper.library.common.config.DictionaryConfig;
-import com.qmth.paper.library.common.enums.AuthEnum;
-import com.qmth.paper.library.common.enums.ExceptionResultEnum;
-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.contant.SystemConstant;
 import com.qmth.paper.library.common.entity.BasicSchool;
 import com.qmth.paper.library.common.entity.SysOrg;
 import com.qmth.paper.library.common.entity.TSAuth;
+import com.qmth.paper.library.common.enums.AuthEnum;
+import com.qmth.paper.library.common.enums.ExceptionResultEnum;
+import com.qmth.paper.library.common.enums.UploadFileEnum;
 import com.qmth.paper.library.common.mapper.BasicSchoolMapper;
 import com.qmth.paper.library.common.mapper.SysOrgMapper;
 import com.qmth.paper.library.common.mapper.TSAuthMapper;
 import com.qmth.paper.library.common.service.*;
+import com.qmth.paper.library.common.util.FileStoreUtil;
 import org.apache.commons.codec.digest.DigestUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -196,7 +195,9 @@ public class AuthInfoServiceImpl implements AuthInfoService {
             } else {
                 tsAuthList.add(new TSAuth(o.getId(), solarProperties.getAccessKey(), solarProperties.getAccessSecret(), authEnum, appInfo.getControl().getExpireTime()));
             }
-            commonCacheService.updateAuthInfoCache(o.getCode());
+            if (Objects.isNull(commonCacheService.updateAuthInfoCache(o.getCode()))) {
+                commonCacheService.removeAuthInfoCache(o.getCode());
+            }
 
             QueryWrapper<BasicSchool> basicSchoolQueryWrapper = new QueryWrapper<>();
             basicSchoolQueryWrapper.lambda().eq(BasicSchool::getCode, o.getCode());

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

@@ -63,7 +63,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
      * @return
      */
     @Override
-    @Cacheable(value = SystemConstant.ROLE_CACHE, key = "#p0")
+    @Cacheable(value = SystemConstant.ROLE_CACHE, key = "#p0", unless = "#result == null")
     public SysRole roleCache(Long roleId) {
         return sysRoleService.getById(roleId);
     }
@@ -75,7 +75,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
      * @return
      */
     @Override
-    @CachePut(value = SystemConstant.ROLE_CACHE, key = "#p0")
+    @CachePut(value = SystemConstant.ROLE_CACHE, key = "#p0", condition = "#result != null")
     public SysRole updateRoleCache(Long roleId) {
         return sysRoleService.getById(roleId);
     }
@@ -99,7 +99,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
      * @return
      */
     @Override
-    @Cacheable(value = SystemConstant.USER_MENU_CACHE, key = "#p0")
+    @Cacheable(value = SystemConstant.USER_MENU_CACHE, key = "#p0", unless = "#result == null")
     public MenuResult userMenuCache(Long userId) {
         return commonService.getUserMenu(userId);
     }
@@ -111,7 +111,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
      * @return
      */
     @Override
-    @CachePut(value = SystemConstant.USER_MENU_CACHE, key = "#p0")
+    @CachePut(value = SystemConstant.USER_MENU_CACHE, key = "#p0", condition = "#result != null")
     public MenuResult updateUserMenuCache(Long userId) {
         return commonService.getUserMenu(userId);
     }
@@ -134,7 +134,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
      * @return
      */
     @Override
-    @Cacheable(value = SystemConstant.USER_ACCOUNT_CACHE, key = "#p0")
+    @Cacheable(value = SystemConstant.USER_ACCOUNT_CACHE, key = "#p0", unless = "#result == null")
     public SysUser userCache(Long userId) {
         return sysUserService.getById(userId);
     }
@@ -146,7 +146,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
      * @return
      */
     @Override
-    @CachePut(value = SystemConstant.USER_ACCOUNT_CACHE, key = "#p0")
+    @CachePut(value = SystemConstant.USER_ACCOUNT_CACHE, key = "#p0", condition = "#result != null")
     public SysUser updateUserCache(Long userId) {
         return sysUserService.getById(userId);
     }
@@ -169,7 +169,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
      * @return
      */
     @Override
-    @Cacheable(value = SystemConstant.USER_OAUTH_CACHE, key = "#p0")
+    @Cacheable(value = SystemConstant.USER_OAUTH_CACHE, key = "#p0", unless = "#result == null")
     public AuthBean userAuthCache(Long userId) {
         return commonService.getUserAuth(userId);
     }
@@ -181,7 +181,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
      * @return
      */
     @Override
-    @CachePut(value = SystemConstant.USER_OAUTH_CACHE, key = "#p0")
+    @CachePut(value = SystemConstant.USER_OAUTH_CACHE, key = "#p0", condition = "#result != null")
     public AuthBean updateUserAuthCache(Long userId) {
         return commonService.getUserAuth(userId);
     }
@@ -204,7 +204,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
      * @return
      */
     @Override
-    @Cacheable(value = SystemConstant.SCHOOL_CACHE, key = "#p0")
+    @Cacheable(value = SystemConstant.SCHOOL_CACHE, key = "#p0", unless = "#result == null")
     public BasicSchool schoolCache(Long schoolId) {
         return basicSchoolService.getById(schoolId);
     }
@@ -216,7 +216,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
      * @return
      */
     @Override
-    @Cacheable(value = SystemConstant.SCHOOL_CODE_CACHE, key = "#p0")
+    @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);
@@ -230,7 +230,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
      * @return
      */
     @Override
-    @CachePut(value = SystemConstant.SCHOOL_CACHE, key = "#p0")
+    @CachePut(value = SystemConstant.SCHOOL_CACHE, key = "#p0", condition = "#result != null")
     public BasicSchool updateSchoolCache(Long schoolId) {
         return basicSchoolService.getById(schoolId);
     }
@@ -242,7 +242,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
      * @return
      */
     @Override
-    @CachePut(value = SystemConstant.SCHOOL_CODE_CACHE, key = "#p0")
+    @CachePut(value = SystemConstant.SCHOOL_CODE_CACHE, key = "#p0", condition = "#result != null")
     public BasicSchool updateSchoolCache(String code) {
         QueryWrapper<BasicSchool> basicSchoolQueryWrapper = new QueryWrapper<>();
         basicSchoolQueryWrapper.lambda().eq(BasicSchool::getCode, code);
@@ -296,7 +296,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
      * @return
      */
     @Override
-    @Cacheable(value = SystemConstant.ORG_CACHE, key = "#p0")
+    @Cacheable(value = SystemConstant.ORG_CACHE, key = "#p0", unless = "#result == null")
     public SysOrg orgCache(Long orgId) {
         return sysOrgService.getById(orgId);
     }
@@ -308,7 +308,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
      * @return
      */
     @Override
-    @CachePut(value = SystemConstant.ORG_CACHE, key = "#p0")
+    @CachePut(value = SystemConstant.ORG_CACHE, key = "#p0", condition = "#result != null")
     public SysOrg updateOrgCache(Long orgId) {
         return sysOrgService.getById(orgId);
     }
@@ -340,13 +340,13 @@ public class CommonCacheServiceImpl implements CommonCacheService {
      * @return
      */
     @Override
-    @Cacheable(value = SystemConstant.PRIVILEGE_URL_CACHE, key = "#p0")
+    @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")
+    @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);
     }
@@ -358,7 +358,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
      * @return
      */
     @Override
-    @CachePut(value = SystemConstant.PRIVILEGE_URL_CACHE, key = "#p0")
+    @CachePut(value = SystemConstant.PRIVILEGE_URL_CACHE, key = "#p0", condition = "#result != null")
     public Set<String> updatePrivilegeUrlCache(PrivilegePropertyEnum privilegePropertyEnum) {
         return commonService.getPrivilegeUrl(privilegePropertyEnum);
     }
@@ -381,7 +381,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
      * @return
      */
     @Override
-    @Cacheable(value = SystemConstant.ROLE_PRIVILEGE_CACHE, key = "#p0")
+    @Cacheable(value = SystemConstant.ROLE_PRIVILEGE_CACHE, key = "#p0", unless = "#result == null")
     public List<SysRolePrivilege> rolePrivilegeCache(Long roleId) {
         return commonService.getRolePrivilege(roleId);
     }
@@ -393,7 +393,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
      * @return
      */
     @Override
-    @CachePut(value = SystemConstant.ROLE_PRIVILEGE_CACHE, key = "#p0")
+    @CachePut(value = SystemConstant.ROLE_PRIVILEGE_CACHE, key = "#p0", condition = "#result != null")
     public List<SysRolePrivilege> updateRolePrivilegeCache(Long roleId) {
         return commonService.getRolePrivilege(roleId);
     }
@@ -416,7 +416,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
      * @return
      */
     @Override
-    @Cacheable(value = SystemConstant.USER_ROLE_PRIVILEGE_CACHE, key = "#p0")
+    @Cacheable(value = SystemConstant.USER_ROLE_PRIVILEGE_CACHE, key = "#p0", unless = "#result == null")
     public List<SysUserRole> userRolePrivilegeCache(Long userId) {
         return commonService.getUserRolePrivilege(userId);
     }
@@ -428,7 +428,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
      * @return
      */
     @Override
-    @CachePut(value = SystemConstant.USER_ROLE_PRIVILEGE_CACHE, key = "#p0")
+    @CachePut(value = SystemConstant.USER_ROLE_PRIVILEGE_CACHE, key = "#p0", condition = "#result != null")
     public List<SysUserRole> updateUserRolePrivilegeCache(Long userId) {
         return commonService.getUserRolePrivilege(userId);
     }
@@ -459,7 +459,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
     }
 
     @Override
-    @CachePut(value = SystemConstant.AUTH_INFO_CACHE, key = "#p0", unless = "#result == null")
+    @CachePut(value = SystemConstant.AUTH_INFO_CACHE, key = "#p0", condition = "#result != null")
     public AuthOrgInfoDto updateAuthInfoCache(String code) {
         AppInfo appInfo = solarService.getAppInfo();
         AuthOrgInfoDto authOrgInfoDto = null;
@@ -497,7 +497,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
      * @return
      */
     @Override
-    @CachePut(value = SystemConstant.SYS_CONFIG_CACHE, key = "#p0", unless = "#result == null")
+    @CachePut(value = SystemConstant.SYS_CONFIG_CACHE, key = "#p0", condition = "#result != null")
     public SysConfig updateSysConfigCache(String key) {
         return sysConfigService.getById(new QueryWrapper<SysConfig>().lambda().eq(SysConfig::getConfigKey, key));
     }
@@ -534,7 +534,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
      * @return
      */
     @Override
-    @CachePut(value = SystemConstant.SYS_CONFIG_CACHE, key = "#p0 + '-' + #p1", unless = "#result != null")
+    @CachePut(value = SystemConstant.SYS_CONFIG_CACHE, key = "#p0 + '-' + #p1", condition = "#result != null")
     public SysConfig updateSysConfigCache(Long schoolId, String key) {
         return sysConfigService.getOne(new QueryWrapper<SysConfig>().lambda().eq(SysConfig::getSchoolId, schoolId).eq(SysConfig::getConfigKey, key));
     }
@@ -552,13 +552,13 @@ public class CommonCacheServiceImpl implements CommonCacheService {
     }
 
     @Override
-    @Cacheable(value = SystemConstant.ORG_COLLEGE_LEVEL_CACHE, key = "#p0")
+    @Cacheable(value = SystemConstant.ORG_COLLEGE_LEVEL_CACHE, key = "#p0", unless = "#result == null")
     public List<SysOrg> addOrgCollegeLevelCache(Long schoolId) {
         return sysOrgService.findCollegeLevelOrgList(schoolId);
     }
 
     @Override
-    @CachePut(value = SystemConstant.ORG_COLLEGE_LEVEL_CACHE, key = "#p0")
+    @CachePut(value = SystemConstant.ORG_COLLEGE_LEVEL_CACHE, key = "#p0", condition = "#result != null")
     public List<SysOrg> updateOrgCollegeLevelCache(Long schoolId) {
         return sysOrgService.findCollegeLevelOrgList(schoolId);
     }

+ 6 - 2
paper-library-common/src/main/java/com/qmth/paper/library/common/service/impl/SysOrgServiceImpl.java

@@ -127,7 +127,9 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
                 org.updateInfo(sysUser.getId());
                 success = this.updateById(org);
             }
-            commonCacheService.updateOrgCollegeLevelCache(schoolId);
+            if(Objects.isNull(commonCacheService.updateOrgCollegeLevelCache(schoolId))){
+                commonCacheService.removeOrgCollegeLevelCache(schoolId);
+            }
         } catch (Exception e) {
             if (e instanceof DuplicateKeyException) {
                 String errorColumn = e.getCause().toString();
@@ -395,7 +397,9 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
                 }
             }
         }
-        commonCacheService.updateOrgCollegeLevelCache(requestUser.getSchoolId());
+        if(Objects.isNull(commonCacheService.updateOrgCollegeLevelCache(requestUser.getSchoolId()))){
+            commonCacheService.removeOrgCollegeLevelCache(requestUser.getSchoolId());
+        }
         return map;
     }
 

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

@@ -318,7 +318,7 @@ public class SysPrivilegeServiceImpl extends ServiceImpl<SysPrivilegeMapper, Sys
      * @return
      */
     @Override
-    @Cacheable(value = SystemConstant.CUSTOM_PRIVILEGE_CACHE)
+    @Cacheable(value = SystemConstant.CUSTOM_PRIVILEGE_CACHE, unless = "#result == null")
     public List<PrivilegeDto> addCustomList() {
         return this.commonCustomList();
     }
@@ -329,7 +329,7 @@ public class SysPrivilegeServiceImpl extends ServiceImpl<SysPrivilegeMapper, Sys
      * @return
      */
     @Override
-    @CachePut(value = SystemConstant.CUSTOM_PRIVILEGE_CACHE, unless = "#result == null")
+    @CachePut(value = SystemConstant.CUSTOM_PRIVILEGE_CACHE, condition = "#result != null")
     public List<PrivilegeDto> updateCustomList() {
         return this.commonCustomList();
     }

+ 21 - 8
paper-library-common/src/main/java/com/qmth/paper/library/common/service/impl/SysRoleServiceImpl.java

@@ -6,19 +6,20 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.boot.api.exception.ApiException;
+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.enums.FieldUniqueEnum;
+import com.qmth.paper.library.common.mapper.SysRoleMapper;
 import com.qmth.paper.library.common.service.*;
 import com.qmth.paper.library.common.util.ResultUtil;
 import com.qmth.paper.library.common.util.ServletUtil;
-import com.qmth.paper.library.common.contant.SystemConstant;
-import com.qmth.paper.library.common.mapper.SysRoleMapper;
 import org.slf4j.Logger;
 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;
@@ -114,11 +115,15 @@ 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);
-                commonCacheService.updateRoleCache(role.getId());
+                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);//角色权限
-                    commonCacheService.updateRolePrivilegeCache(role.getId());
+                    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);
@@ -186,12 +191,16 @@ 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);
-                commonCacheService.updateRoleCache(role.getId());
+                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);//角色权限
-                    commonCacheService.updateRolePrivilegeCache(role.getId());
+                    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);
@@ -226,7 +235,9 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
                 .set(SysRoleGroupMember::getEnable, role.getEnable());
         sysRoleGroupMemberService.update(sysRoleGroupMemberUpdateWrapper);
 
-        commonCacheService.updateRoleCache(role.getId());
+        if (Objects.isNull(commonCacheService.updateRoleCache(role.getId()))) {
+            commonCacheService.removeRoleCache(role.getId());
+        }
         //如果状态为禁用,需要踢下线重新登录
         if (!role.getEnable()) {
             List<SysUserRole> sysUserRoleList = sysUserRoleService.listByRoleId(role.getId());
@@ -243,7 +254,9 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
         updateWrapper.lambda().set(SysRole::getEnable, role.getEnable()).eq(SysRole::getId, role.getId());
         this.update(updateWrapper);
 
-        commonCacheService.updateRoleCache(role.getId());
+        if (Objects.isNull(commonCacheService.updateRoleCache(role.getId()))) {
+            commonCacheService.removeRoleCache(role.getId());
+        }
         //如果状态为禁用,需要踢下线重新登录
         if (!role.getEnable()) {
             List<SysUserRole> sysUserRoleList = sysUserRoleService.listByRoleId(role.getId());

+ 15 - 5
paper-library-common/src/main/java/com/qmth/paper/library/common/service/impl/SysUserServiceImpl.java

@@ -141,8 +141,10 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
     public boolean enable(SysUser user) throws NoSuchAlgorithmException, IllegalAccessException {
         UpdateWrapper<SysUser> updateWrapper = new UpdateWrapper<>();
         updateWrapper.lambda().set(SysUser::getEnable, user.getEnable()).eq(SysUser::getId, user.getId());
-        commonCacheService.updateUserCache(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);
@@ -415,8 +417,12 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
                 if (Objects.nonNull(dbUser.getOrgId())) {
                     if (dbUser.getOrgId().longValue() != sysUser.getOrgId().longValue()
                             || !Objects.equals(dbUser.getMobileNumber(), sysUser.getMobileNumber())) {
-                        commonCacheService.updateUserCache(sysUser.getId());
-                        commonCacheService.updateUserAuthCache(sysUser.getId());
+                        if (Objects.isNull(commonCacheService.updateUserCache(sysUser.getId()))) {
+                            commonCacheService.removeUserCache(sysUser.getId());
+                        }
+                        if (Objects.isNull(commonCacheService.updateUserAuthCache(sysUser.getId()))) {
+                            commonCacheService.removeUserAuthCache(sysUser.getId());
+                        }
                     }
                 }
 
@@ -507,8 +513,12 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
                 if (Objects.nonNull(dbUser.getOrgId())) {
                     if (containsQuestionTeacher || dbUser.getOrgId().longValue() != sysUser.getOrgId().longValue()
                             || !Objects.equals(dbUser.getMobileNumber(), sysUser.getMobileNumber())) {
-                        commonCacheService.updateUserCache(sysUser.getId());
-                        commonCacheService.updateUserAuthCache(sysUser.getId());
+                        if (Objects.isNull(commonCacheService.updateUserCache(sysUser.getId()))) {
+                            commonCacheService.removeUserCache(sysUser.getId());
+                        }
+                        if (Objects.isNull(commonCacheService.updateUserAuthCache(sysUser.getId()))) {
+                            commonCacheService.removeUserAuthCache(sysUser.getId());
+                        }
                     }
                 }
             }

+ 6 - 2
paper-library/src/main/java/com/qmth/paper/library/api/MenuCustomController.java

@@ -124,8 +124,12 @@ public class MenuCustomController {
         //清缓存
         if (!CollectionUtils.isEmpty(roleSetIds)) {
             for (Long l : roleSetIds) {
-                commonCacheService.updateRoleCache(l);
-                commonCacheService.updateRolePrivilegeCache(l);
+                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) {