mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-13 21:32:07 +08:00
1、access_token多级缓存同时失效下的刷新处理;
2、loginUser整体用utf-8编码处理中文乱码; 3、角色用sort排序;
This commit is contained in:
+3
-5
@@ -1,7 +1,7 @@
|
||||
package com.cf.imes.module.system.dal.mysql.permission;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.framework.security.core.LoginUser;
|
||||
@@ -12,9 +12,7 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Mapper
|
||||
public interface RoleMapper extends BaseMapperX<RoleDO> {
|
||||
@@ -28,7 +26,7 @@ public interface RoleMapper extends BaseMapperX<RoleDO> {
|
||||
//如果是超级管理员并且未传organId,就查看自己的的
|
||||
lambdaQueryWrapperX.inIfPresent(RoleDO::getOrganId,0L,loginUser.getOrganId());
|
||||
}*/
|
||||
if(isSupAdmin && !Objects.isNull(reqVO.getOrganId())) {
|
||||
if(isSupAdmin && ObjectUtil.isNotNull(reqVO.getOrganId())) {
|
||||
//如果是超级管理员并且传入organId,就查看传入的组织
|
||||
lambdaQueryWrapperX.eqIfPresent(RoleDO::getOrganId, reqVO.getOrganId());
|
||||
} else {
|
||||
@@ -41,7 +39,7 @@ public interface RoleMapper extends BaseMapperX<RoleDO> {
|
||||
.eqIfPresent(RoleDO::getStatus, reqVO.getStatus())
|
||||
.betweenIfPresent(RoleDO::getCreateTime, reqVO.getCreateTime())
|
||||
.ne(RoleDO::getId, 1)
|
||||
.orderByDesc(RoleDO::getId);
|
||||
.orderByAsc(RoleDO::getSort);
|
||||
|
||||
return selectPage(reqVO, lambdaQueryWrapperX);
|
||||
}
|
||||
|
||||
+11
-1
@@ -15,6 +15,7 @@ import com.cf.imes.module.system.dal.dataobject.oauth2.OAuth2RefreshTokenDO;
|
||||
import com.cf.imes.module.system.dal.mysql.oauth2.OAuth2AccessTokenMapper;
|
||||
import com.cf.imes.module.system.dal.mysql.oauth2.OAuth2RefreshTokenMapper;
|
||||
import com.cf.imes.module.system.dal.redis.oauth2.OAuth2AccessTokenRedisDAO;
|
||||
import org.mybatis.spring.MyBatisSystemException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -97,7 +98,16 @@ public class OAuth2TokenServiceImpl implements OAuth2TokenService {
|
||||
}
|
||||
|
||||
// 获取不到,从 MySQL 中获取
|
||||
accessTokenDO = oauth2AccessTokenMapper.selectByAccessToken(accessToken);
|
||||
try {
|
||||
accessTokenDO = oauth2AccessTokenMapper.selectByAccessToken(accessToken);
|
||||
} catch (MyBatisSystemException e) {
|
||||
// 可能存在本地缓存和redis缓存都失效的情况下,mybatis-plus的organid填充器拿不到组织id,只捕获“不存在组织编号”的异常返回null让前端refresh-accesstoken,其他异常正常继续抛出
|
||||
if (e.getMessage().contains(OrganContextHolder.ORGANID_NOT_EXIST_EXCEPTION)) {
|
||||
return null;
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
// 如果在 MySQL 存在,则往 Redis 中写入
|
||||
if (accessTokenDO != null && !DateUtils.isExpired(accessTokenDO.getExpiresTime())) {
|
||||
oauth2AccessTokenRedisDAO.set(accessTokenDO);
|
||||
|
||||
Reference in New Issue
Block a user