【更新】升级satoken为1.31.0

pull/46/head
xuyuxiang 2022-10-13 14:54:02 +08:00
parent 6300e29cd3
commit 7094edbd2b
6 changed files with 26 additions and 20 deletions

View File

@ -15,7 +15,7 @@
<description>登录鉴权插件api接口</description>
<properties>
<sa.token.version>1.30.0</sa.token.version>
<sa.token.version>1.31.0</sa.token.version>
</properties>
<dependencies>

View File

@ -708,8 +708,8 @@ public class StpClientUtil {
* @param size
* @return token
*/
public static List<String> searchTokenValue(String keyword, int start, int size) {
return stpLogic.searchTokenValue(keyword, start, size);
public static List<String> searchTokenValue(String keyword, int start, int size, boolean sortType) {
return stpLogic.searchTokenValue(keyword, start, size, sortType);
}
/**
@ -719,8 +719,8 @@ public class StpClientUtil {
* @param size
* @return sessionId
*/
public static List<String> searchSessionId(String keyword, int start, int size) {
return stpLogic.searchSessionId(keyword, start, size);
public static List<String> searchSessionId(String keyword, int start, int size, boolean sortType) {
return stpLogic.searchSessionId(keyword, start, size, sortType);
}
/**
@ -730,8 +730,8 @@ public class StpClientUtil {
* @param size
* @return sessionId
*/
public static List<String> searchTokenSessionId(String keyword, int start, int size) {
return stpLogic.searchTokenSessionId(keyword, start, size);
public static List<String> searchTokenSessionId(String keyword, int start, int size, boolean sortType) {
return stpLogic.searchTokenSessionId(keyword, start, size, sortType);
}

View File

@ -15,7 +15,7 @@
<description>登录鉴权插件</description>
<properties>
<sa.token.version>1.30.0</sa.token.version>
<sa.token.version>1.31.0</sa.token.version>
<just.auth.version>1.16.5</just.auth.version>
</properties>

View File

@ -46,11 +46,11 @@ public class AuthExceptionUtil {
// 如果是权限异常 403
NotPermissionException notPermissionException = (NotPermissionException) e;
commonResult = CommonResult.get(HttpStatus.HTTP_FORBIDDEN, "无此权限:" + notPermissionException.getPermission(), null);
} else if (e instanceof DisableLoginException) {
} else if (e instanceof DisableServiceException) {
// 如果是被封禁异常 403
DisableLoginException disableLoginException = (DisableLoginException) e;
commonResult = CommonResult.get(HttpStatus.HTTP_FORBIDDEN, "账号被封禁:" + disableLoginException.getDisableTime() + "秒后解封", null);
DisableServiceException disableServiceException = (DisableServiceException) e;
commonResult = CommonResult.get(HttpStatus.HTTP_FORBIDDEN, "账号被封禁:" + disableServiceException.getDisableTime() + "秒后解封", null);
} else if (e instanceof SaTokenException) {
// 如果是SaToken异常 直接返回

View File

@ -88,13 +88,13 @@ public class AuthListener implements SaTokenListener {
/** 每次被封禁时触发 */
@Override
public void doDisable(String loginType, Object loginId, long disableTime) {
public void doDisable(String loginType, Object loginId, String service, int level, long disableTime) {
// ...
}
/** 每次被解封时触发 */
@Override
public void doUntieDisable(String loginType, Object loginId) {
public void doUntieDisable(String loginType, Object loginId, String service) {
// ...
}
@ -109,4 +109,10 @@ public class AuthListener implements SaTokenListener {
public void doLogoutSession(String id) {
// ...
}
/** 每次Token续期时触发 */
@Override
public void doRenewTimeout(String tokenValue, Object loginId, long timeout) {
// ...
}
}

View File

@ -62,7 +62,7 @@ public class AuthSessionServiceImpl implements AuthSessionService {
@Override
public AuthSessionAnalysisResult analysis() {
AuthSessionAnalysisResult authSessionAnalysisResult = new AuthSessionAnalysisResult();
List<JSONObject> sessionListB = StpUtil.searchSessionId("", -1, -1).stream().map(sessionId -> {
List<JSONObject> sessionListB = StpUtil.searchSessionId("", -1, -1, true).stream().map(sessionId -> {
JSONObject jsonObject = JSONUtil.createObj();
String userId = StrUtil.split(sessionId, StrUtil.COLON).get(3);
SaSession saSession = StpUtil.getSessionByLoginId(userId, false);
@ -74,7 +74,7 @@ public class AuthSessionServiceImpl implements AuthSessionService {
return jsonObject;
}).collect(Collectors.toList());
List<JSONObject> sessionListC = StpClientUtil.searchSessionId("", -1, -1).stream().map(sessionId -> {
List<JSONObject> sessionListC = StpClientUtil.searchSessionId("", -1, -1, true).stream().map(sessionId -> {
JSONObject jsonObject = JSONUtil.createObj();
String userId = StrUtil.split(sessionId, StrUtil.COLON).get(3);
SaSession saSession = StpClientUtil.getSessionByLoginId(userId, false);
@ -107,7 +107,7 @@ public class AuthSessionServiceImpl implements AuthSessionService {
public Page<AuthSessionPageResult> pageForB(AuthSessionPageParam authSessionPageParam) {
Page<AuthSessionPageResult> defaultPage = CommonPageRequest.defaultPage();
long current = defaultPage.getCurrent();
int total = StpUtil.searchSessionId("", -1, Convert.toInt(defaultPage.getSize())).size();
int total = StpUtil.searchSessionId("", -1, Convert.toInt(defaultPage.getSize()), true).size();
if(ObjectUtil.isNotEmpty(total)) {
defaultPage = new Page<>(current, defaultPage.getSize(), total);
String keyword = "";
@ -116,7 +116,7 @@ public class AuthSessionServiceImpl implements AuthSessionService {
}
List<String> userIdList = StpUtil.searchSessionId(keyword,
Convert.toInt((current - 1) * defaultPage.getSize()),
Convert.toInt(defaultPage.getSize())).stream().map(sessionId ->
Convert.toInt(defaultPage.getSize()), true).stream().map(sessionId ->
StrUtil.split(sessionId, StrUtil.COLON).get(3)).collect(Collectors.toList());
if (ObjectUtil.isNotEmpty(userIdList)) {
List<AuthSessionPageResult> authSessionPageResultList = loginUserApi.listUserByUserIdList(userIdList).stream().map(userJsonObject -> {
@ -164,7 +164,7 @@ public class AuthSessionServiceImpl implements AuthSessionService {
public Page<AuthSessionPageResult> pageForC(AuthSessionPageParam authSessionPageParam) {
Page<AuthSessionPageResult> defaultPage = CommonPageRequest.defaultPage();
long current = defaultPage.getCurrent();
int total = StpClientUtil.searchSessionId("", -1, Convert.toInt(defaultPage.getSize())).size();
int total = StpClientUtil.searchSessionId("", -1, Convert.toInt(defaultPage.getSize()), true).size();
if(ObjectUtil.isNotEmpty(total)) {
defaultPage = new Page<>(current, defaultPage.getSize(), total);
String keyword = "";
@ -173,10 +173,10 @@ public class AuthSessionServiceImpl implements AuthSessionService {
}
List<String> userIdList = StpClientUtil.searchSessionId(keyword,
Convert.toInt((current - 1) * defaultPage.getSize()),
Convert.toInt(defaultPage.getSize())).stream().map(sessionId ->
Convert.toInt(defaultPage.getSize()), true).stream().map(sessionId ->
StrUtil.split(sessionId, StrUtil.COLON).get(3)).collect(Collectors.toList());
if (ObjectUtil.isNotEmpty(userIdList)) {
List<AuthSessionPageResult> authSessionPageResultList = loginUserApi.listUserByUserIdList(userIdList).stream().map(userJsonObject -> {
List<AuthSessionPageResult> authSessionPageResultList = clientLoginUserApi.listUserByUserIdList(userIdList).stream().map(userJsonObject -> {
SaSession saSession = StpClientUtil.getSessionByLoginId(userJsonObject.getStr("id"), false);
AuthSessionPageResult authSessionPageResult = JSONUtil.toBean(userJsonObject, AuthSessionPageResult.class);
authSessionPageResult.setSessionId(saSession.getId());