修改mybatis自动插入的creator updater 字段为用户昵称

This commit is contained in:
yangsb
2024-04-25 17:45:18 +08:00
parent b73028b192
commit a7eff5f294
16 changed files with 74 additions and 23 deletions
@@ -25,6 +25,8 @@ public class WebFrameworkUtils {
private static final String REQUEST_ATTRIBUTE_COMMON_RESULT = "common_result";
private static final String REQUEST_ATTRIBUTE_LOGIN_USER_NAME = "login-user-name";
public static final String HEADER_ORGAN_ID = "organ-id";
/**
@@ -56,6 +58,10 @@ public class WebFrameworkUtils {
request.setAttribute(REQUEST_ATTRIBUTE_LOGIN_USER_ID, userId);
}
public static void setLoginUserName(ServletRequest request, String nickname) {
request.setAttribute(REQUEST_ATTRIBUTE_LOGIN_USER_NAME, nickname);
}
/**
* 设置用户类型
*
@@ -80,6 +86,20 @@ public class WebFrameworkUtils {
return (Long) request.getAttribute(REQUEST_ATTRIBUTE_LOGIN_USER_ID);
}
/**
* 获得当前用户的昵称,从请求中
* 注意:该方法仅限于 framework 框架使用!!!
*
* @param request 请求
* @return 用户编号
*/
private static String getLoginUserName(HttpServletRequest request) {
if (request == null) {
return null;
}
return (String) request.getAttribute(REQUEST_ATTRIBUTE_LOGIN_USER_NAME);
}
/**
* 获得当前用户的类型
* 注意:该方法仅限于 web 相关的 framework 组件使用!!!
@@ -116,6 +136,12 @@ public class WebFrameworkUtils {
return getLoginUserId(request);
}
public static String getLoginUserName() {
HttpServletRequest request = getRequest();
return getLoginUserName(request);
}
public static Integer getTerminal() {
HttpServletRequest request = getRequest();
if (request == null) {