From 937844f4f6c87d4c4035f4ad36ae9f63bba678b4 Mon Sep 17 00:00:00 2001 From: click33 <2393584716@qq.com> Date: Wed, 19 Mar 2025 08:09:49 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=99=BB=E5=BD=95=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E4=B8=8E=E6=B3=A8=E9=94=80=E5=8F=82=E6=95=B0=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E7=BB=86=E8=8A=82=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/cn/dev33/satoken/stp/StpLogic.java | 6 +++--- .../satoken/stp/parameter/SaLoginParameter.java | 16 ++++++++-------- .../satoken/stp/parameter/SaLogoutParameter.java | 3 +++ ...{SaReplacedMode.java => SaReplacedRange.java} | 2 +- 4 files changed, 15 insertions(+), 12 deletions(-) rename sa-token-core/src/main/java/cn/dev33/satoken/stp/parameter/enums/{SaReplacedMode.java => SaReplacedRange.java} (96%) diff --git a/sa-token-core/src/main/java/cn/dev33/satoken/stp/StpLogic.java b/sa-token-core/src/main/java/cn/dev33/satoken/stp/StpLogic.java index 40a22aee..55efe079 100644 --- a/sa-token-core/src/main/java/cn/dev33/satoken/stp/StpLogic.java +++ b/sa-token-core/src/main/java/cn/dev33/satoken/stp/StpLogic.java @@ -35,7 +35,7 @@ import cn.dev33.satoken.stp.parameter.SaLoginParameter; import cn.dev33.satoken.stp.parameter.SaLogoutParameter; import cn.dev33.satoken.stp.parameter.enums.SaLogoutMode; import cn.dev33.satoken.stp.parameter.enums.SaLogoutRange; -import cn.dev33.satoken.stp.parameter.enums.SaReplacedMode; +import cn.dev33.satoken.stp.parameter.enums.SaReplacedRange; import cn.dev33.satoken.strategy.SaStrategy; import cn.dev33.satoken.util.SaFoxUtil; import cn.dev33.satoken.util.SaTokenConsts; @@ -523,10 +523,10 @@ public class StpLogic { // 1、获取全局配置的 isConcurrent 参数 // 如果配置为:不允许一个账号多地同时登录,则需要先将这个账号的历史登录会话标记为:被顶下线 if( ! loginParameter.getIsConcurrent()) { - if(loginParameter.getReplacedMode() == SaReplacedMode.CURR_DEVICE_TYPE) { + if(loginParameter.getReplacedRange() == SaReplacedRange.CURR_DEVICE_TYPE) { replaced(id, loginParameter.getDeviceTypeOrDefault()); } - if(loginParameter.getReplacedMode() == SaReplacedMode.ALL_DEVICE_TYPE) { + if(loginParameter.getReplacedRange() == SaReplacedRange.ALL_DEVICE_TYPE) { replaced(id, createSaLogoutParameter()); } } diff --git a/sa-token-core/src/main/java/cn/dev33/satoken/stp/parameter/SaLoginParameter.java b/sa-token-core/src/main/java/cn/dev33/satoken/stp/parameter/SaLoginParameter.java index c4e4870b..f3f83032 100644 --- a/sa-token-core/src/main/java/cn/dev33/satoken/stp/parameter/SaLoginParameter.java +++ b/sa-token-core/src/main/java/cn/dev33/satoken/stp/parameter/SaLoginParameter.java @@ -19,7 +19,7 @@ import cn.dev33.satoken.SaManager; import cn.dev33.satoken.config.SaTokenConfig; import cn.dev33.satoken.dao.SaTokenDao; import cn.dev33.satoken.stp.parameter.enums.SaLogoutMode; -import cn.dev33.satoken.stp.parameter.enums.SaReplacedMode; +import cn.dev33.satoken.stp.parameter.enums.SaReplacedRange; import cn.dev33.satoken.util.SaTokenConsts; import java.util.LinkedHashMap; @@ -53,7 +53,7 @@ public class SaLoginParameter { /** * 顶人下线的范围 */ - private SaReplacedMode replacedMode = SaReplacedMode.CURR_DEVICE_TYPE; + private SaReplacedRange replacedRange = SaReplacedRange.CURR_DEVICE_TYPE; /** * 溢出 maxLoginCount 的客户端,将以何种方式注销下线 @@ -291,18 +291,18 @@ public class SaLoginParameter { * * @return replacedMode 顶人下线的范围 */ - public SaReplacedMode getReplacedMode() { - return this.replacedMode; + public SaReplacedRange getReplacedRange() { + return this.replacedRange; } /** * 设置 顶人下线的范围 * - * @param replacedMode / + * @param replacedRange / * @return 对象自身 */ - public SaLoginParameter setReplacedMode(SaReplacedMode replacedMode) { - this.replacedMode = replacedMode; + public SaLoginParameter setReplacedRange(SaReplacedRange replacedRange) { + this.replacedRange = replacedRange; return this; } @@ -513,7 +513,7 @@ public class SaLoginParameter { return "SaLoginParameter [" + "deviceType=" + deviceType + ", deviceId=" + deviceId - + ", replacedMode=" + replacedMode + + ", replacedRange=" + replacedRange + ", overflowLogoutMode=" + overflowLogoutMode + ", isLastingCookie=" + isLastingCookie + ", timeout=" + timeout diff --git a/sa-token-core/src/main/java/cn/dev33/satoken/stp/parameter/SaLogoutParameter.java b/sa-token-core/src/main/java/cn/dev33/satoken/stp/parameter/SaLogoutParameter.java index cd03bcf1..0b627d4f 100644 --- a/sa-token-core/src/main/java/cn/dev33/satoken/stp/parameter/SaLogoutParameter.java +++ b/sa-token-core/src/main/java/cn/dev33/satoken/stp/parameter/SaLogoutParameter.java @@ -40,6 +40,7 @@ public class SaLogoutParameter { /** * 如果 token 已被冻结,是否保留其操作权 (是否允许此 token 调用注销API) + * (此参数只在调用 StpUtil.[logout/kickout/replaced]ByTokenValue("xxxxxxxxxxxxxxxxxxx", new SaLogoutParameter()) 时有效) */ private Boolean isKeepFreezeOps = false; @@ -109,6 +110,7 @@ public class SaLogoutParameter { /** * 获取 如果 token 已被冻结,是否保留其操作权 (是否允许此 token 调用注销API) + * (此参数只在调用 StpUtil.[logout/kickout/replaced]ByTokenValue("xxxxxxxxxxxxxxxxxxx", new SaLogoutParameter()) 时有效) * * @return / */ @@ -118,6 +120,7 @@ public class SaLogoutParameter { /** * 设置 如果 token 已被冻结,是否保留其操作权 (是否允许此 token 调用注销API) + * (此参数只在调用 StpUtil.[logout/kickout/replaced]ByTokenValue("xxxxxxxxxxxxxxxxxxx", new SaLogoutParameter()) 时有效) * * @param isKeepFreezeOps / * @return 对象自身 diff --git a/sa-token-core/src/main/java/cn/dev33/satoken/stp/parameter/enums/SaReplacedMode.java b/sa-token-core/src/main/java/cn/dev33/satoken/stp/parameter/enums/SaReplacedRange.java similarity index 96% rename from sa-token-core/src/main/java/cn/dev33/satoken/stp/parameter/enums/SaReplacedMode.java rename to sa-token-core/src/main/java/cn/dev33/satoken/stp/parameter/enums/SaReplacedRange.java index 6808f3e8..d6894018 100644 --- a/sa-token-core/src/main/java/cn/dev33/satoken/stp/parameter/enums/SaReplacedMode.java +++ b/sa-token-core/src/main/java/cn/dev33/satoken/stp/parameter/enums/SaReplacedRange.java @@ -21,7 +21,7 @@ package cn.dev33.satoken.stp.parameter.enums; * @author click33 * @since 1.41.0 */ -public enum SaReplacedMode { +public enum SaReplacedRange { /** * 当前指定的设备类型端