|
@@ -184,22 +184,7 @@ public class SessionContextHolder implements ServletRequestListener {
|
|
|
* @return 用户ID
|
|
|
*/
|
|
|
public static Long getId() {
|
|
|
- return getId(true);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取当前用户ID
|
|
|
- *
|
|
|
- * @param required 是否必须
|
|
|
- * @return 用户ID
|
|
|
- */
|
|
|
- public static Long getId(boolean required) {
|
|
|
- Session session = getSession(required);
|
|
|
- Long id = ObjectUtils.ifNull(session, Session::getId);
|
|
|
- if (required) {
|
|
|
- return AssertUtils.nonnull(id, () -> "Session id must not be null");
|
|
|
- }
|
|
|
- return id;
|
|
|
+ return ObjectUtils.ifNull(getSession(false), Session::getId);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -218,7 +203,7 @@ public class SessionContextHolder implements ServletRequestListener {
|
|
|
* @return 请求地址
|
|
|
*/
|
|
|
public static String getHost() {
|
|
|
- return ObjectUtils.ifNull(getSession(), Session::getHost);
|
|
|
+ return ObjectUtils.ifNull(getSession(false), Session::getHost);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -237,7 +222,7 @@ public class SessionContextHolder implements ServletRequestListener {
|
|
|
* @return 使用信息
|
|
|
*/
|
|
|
public static Using getUsing() {
|
|
|
- return ObjectUtils.ifNull(getSession(), Session::getUsing);
|
|
|
+ return ObjectUtils.ifNull(getSession(false), Session::getUsing);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -256,7 +241,7 @@ public class SessionContextHolder implements ServletRequestListener {
|
|
|
* @return 应用范围
|
|
|
*/
|
|
|
public static String getScope() {
|
|
|
- return ObjectUtils.ifNull(getSession(), Session::getScope);
|
|
|
+ return ObjectUtils.ifNull(getSession(false), Session::getScope);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -275,7 +260,7 @@ public class SessionContextHolder implements ServletRequestListener {
|
|
|
* @return 设备标识
|
|
|
*/
|
|
|
public static String getDevice() {
|
|
|
- return ObjectUtils.ifNull(getSession(), Session::getDevice);
|
|
|
+ return ObjectUtils.ifNull(getSession(false), Session::getDevice);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -294,7 +279,7 @@ public class SessionContextHolder implements ServletRequestListener {
|
|
|
* @return 渠道来源
|
|
|
*/
|
|
|
public static String getChannel() {
|
|
|
- return ObjectUtils.ifNull(getSession(), Session::getChannel);
|
|
|
+ return ObjectUtils.ifNull(getSession(false), Session::getChannel);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -313,7 +298,7 @@ public class SessionContextHolder implements ServletRequestListener {
|
|
|
* @return 平台信息
|
|
|
*/
|
|
|
public static Platform getPlatform() {
|
|
|
- return ObjectUtils.ifNull(getSession(), Session::getPlatform);
|
|
|
+ return ObjectUtils.ifNull(getSession(false), Session::getPlatform);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -332,7 +317,7 @@ public class SessionContextHolder implements ServletRequestListener {
|
|
|
* @return 终端信息
|
|
|
*/
|
|
|
public static Terminal getTerminal() {
|
|
|
- return ObjectUtils.ifNull(getSession(), Session::getTerminal);
|
|
|
+ return ObjectUtils.ifNull(getSession(false), Session::getTerminal);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -351,7 +336,7 @@ public class SessionContextHolder implements ServletRequestListener {
|
|
|
* @return 版本信息
|
|
|
*/
|
|
|
public static String getVersion() {
|
|
|
- return ObjectUtils.ifNull(getSession(), Session::getVersion);
|
|
|
+ return ObjectUtils.ifNull(getSession(false), Session::getVersion);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -370,7 +355,7 @@ public class SessionContextHolder implements ServletRequestListener {
|
|
|
* @return true/false
|
|
|
*/
|
|
|
public static boolean isAnonymous() {
|
|
|
- Session session = getSession();
|
|
|
+ Session session = getSession(false);
|
|
|
return session == null || session.isAnonymous();
|
|
|
}
|
|
|
|
|
@@ -391,7 +376,7 @@ public class SessionContextHolder implements ServletRequestListener {
|
|
|
* @return 时间戳
|
|
|
*/
|
|
|
public static Long getTimestamp() {
|
|
|
- return ObjectUtils.ifNull(getSession(), Session::getTimestamp);
|
|
|
+ return ObjectUtils.ifNull(getSession(false), Session::getTimestamp);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -429,7 +414,7 @@ public class SessionContextHolder implements ServletRequestListener {
|
|
|
* @return 设备指纹
|
|
|
*/
|
|
|
public static String getFingerprint() {
|
|
|
- return ObjectUtils.ifNull(getSession(), Session::getFingerprint);
|
|
|
+ return ObjectUtils.ifNull(getSession(false), Session::getFingerprint);
|
|
|
}
|
|
|
|
|
|
/**
|