package com.emergencyrepair.common.audit;
|
|
/**
|
* Carries the request user through the current request thread for MyBatis fills.
|
*/
|
public final class CurrentUserContext {
|
private static final ThreadLocal<String> USERNAME = new ThreadLocal<>();
|
|
private CurrentUserContext() {
|
}
|
|
public static void set(String username) {
|
USERNAME.set(username);
|
}
|
|
public static String get() {
|
String username = USERNAME.get();
|
return username == null || username.trim().isEmpty() ? "admin" : username.trim();
|
}
|
|
public static void clear() {
|
USERNAME.remove();
|
}
|
}
|