mirror of https://gitee.com/xiaonuobase/snowy
【更新】优化获取用户id的写法,兼容B、C端日志记录和数据记录
parent
2616c755ba
commit
9785e2c8dd
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue