mirror of
https://gitee.com/xiaonuobase/snowy.git
synced 2026-03-22 10:47:16 +08:00
【更新】优化获取用户id的写法,兼容B、C端日志记录和数据记录
This commit is contained in:
@@ -90,10 +90,12 @@ public class DevLogAop {
|
||||
CommonLog commonLog = method.getAnnotation(CommonLog.class);
|
||||
String userName = "未知";
|
||||
try {
|
||||
SaBaseLoginUser loginUser = StpLoginUserUtil.getLoginUser();
|
||||
if(ObjectUtil.isNotNull(loginUser)) {
|
||||
userName = loginUser.getName();
|
||||
} else {
|
||||
try {
|
||||
SaBaseLoginUser loginUser = StpLoginUserUtil.getLoginUser();
|
||||
if(ObjectUtil.isNotNull(loginUser)) {
|
||||
userName = loginUser.getName();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
SaBaseClientLoginUser clientLoginUser = StpClientLoginUserUtil.getClientLoginUser();
|
||||
if(ObjectUtil.isNotNull(clientLoginUser)) {
|
||||
userName = clientLoginUser.getName();
|
||||
|
||||
@@ -603,10 +603,14 @@ public class GlobalConfigure implements WebMvcConfigurer {
|
||||
*/
|
||||
private String getUserId() {
|
||||
try {
|
||||
String loginId = StpUtil.getLoginIdAsString();
|
||||
if (ObjectUtil.isNotEmpty(loginId)) {
|
||||
return loginId;
|
||||
} else {
|
||||
try {
|
||||
String loginId = StpUtil.getLoginIdAsString();
|
||||
if (ObjectUtil.isNotEmpty(loginId)) {
|
||||
return loginId;
|
||||
} else {
|
||||
return "-1";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
String clientLoginId = StpClientUtil.getLoginIdAsString();
|
||||
if (ObjectUtil.isNotEmpty(clientLoginId)) {
|
||||
return clientLoginId;
|
||||
|
||||
Reference in New Issue
Block a user