76 门诊预约挂号

This commit is contained in:
ljj
2026-01-09 11:33:03 +08:00
parent 062c4a92b8
commit 8c74d45332
42 changed files with 8627 additions and 258 deletions

View File

@@ -76,6 +76,25 @@ public class SecurityUtils {
}
}
/**
* 安全获取用户名(失败时返回默认值)
**/
public static String getUsernameSafe() {
try {
Authentication authentication = getAuthentication();
if (authentication != null && authentication.getPrincipal() != null) {
if (authentication.getPrincipal() instanceof LoginUser) {
return ((LoginUser) authentication.getPrincipal()).getUsername();
} else {
return authentication.getPrincipal().toString();
}
}
} catch (Exception e) {
// 静默处理异常,返回默认值
}
return "anonymous";
}
/**
* 获取Authentication
*/