fix: repair decompiled sources and add exhaustive documentation
- restore generic signatures, scoped variables and missing code from original bytecode - remove decompiler artifacts and document classes, methods, fields and packages - restore resources, add Batik/BouncyCastle dependencies and build/runtime docs
This commit is contained in:
1 parent
9d7e42eda8
commit
10aa1829f5
346 files changed
+42404
-622
No files matched your search
@@ -14,22 +14,88 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.web.servlet.LocaleResolver;
|
||||
|
||||
/**
|
||||
* 【Java 类型】{@code BaseController}
|
||||
*
|
||||
* 类职责:
|
||||
* <ul>
|
||||
* <li>提供该包内的可复用能力。</li>
|
||||
* <li>通过字段/依赖注入持有运行期状态,字段含义见下方“核心字段”。</li>
|
||||
* </ul>
|
||||
*
|
||||
* 核心字段(按声明顺序):
|
||||
* <ul>
|
||||
* <li>{@code localeResolver}(LocaleResolver):语言区域解析器</li>
|
||||
* <li>{@code localeService}(LocaleService):语言区域服务</li>
|
||||
* <li>{@code userService}(UserService):用户服务</li>
|
||||
* <li>{@code siteService}(SiteService):站点服务</li>
|
||||
* <li>{@code user}(User):用户</li>
|
||||
* <li>{@code theme}(String):字段 theme</li>
|
||||
* </ul>
|
||||
*
|
||||
* 协作对象:{@code LocaleResolver、LocaleService、UserService、SiteService、User}。
|
||||
*
|
||||
* 学习提示:先看类注释和 public 方法,再结合调用方理解它在整体流程中的位置。
|
||||
*/
|
||||
public class BaseController {
|
||||
/**
|
||||
* 语言区域解析器;Spring 自动注入的依赖。
|
||||
*
|
||||
* 注解:{@code @Autowired}。
|
||||
*/
|
||||
@Autowired
|
||||
protected LocaleResolver localeResolver;
|
||||
/**
|
||||
* 语言区域服务;Spring 自动注入的依赖。
|
||||
*
|
||||
* 注解:{@code @Autowired}。
|
||||
*/
|
||||
@Autowired
|
||||
protected LocaleService localeService;
|
||||
/**
|
||||
* 用户服务;Spring 自动注入的依赖。
|
||||
*
|
||||
* 注解:{@code @Autowired}。
|
||||
*/
|
||||
@Autowired
|
||||
protected UserService userService;
|
||||
/**
|
||||
* 站点服务;Spring 自动注入的依赖。
|
||||
*
|
||||
* 注解:{@code @Autowired}。
|
||||
*/
|
||||
@Autowired
|
||||
protected SiteService siteService;
|
||||
/**
|
||||
* 用户。
|
||||
*/
|
||||
protected User user = null;
|
||||
/**
|
||||
* 字段 theme。
|
||||
*/
|
||||
protected String theme = "default";
|
||||
|
||||
/**
|
||||
* 初始化对象状态(补齐 UUID/时间戳/默认字段)。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
*/
|
||||
protected void init(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
|
||||
this.init(request, response, authentication, (String)null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化对象状态(补齐 UUID/时间戳/默认字段)。
|
||||
*
|
||||
* 实现要点:包含 3 个条件分支、0 个循环。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param localeTag 参数 {@code localeTag}({@code String})
|
||||
*/
|
||||
protected void init(HttpServletRequest request, HttpServletResponse response, Authentication authentication, String localeTag) {
|
||||
this.determineUser(request, authentication);
|
||||
String userLocale = !Strings.isNullOrEmpty(localeTag) ? localeTag : (this.user != null ? this.user.getSettingAsString("language") : request.getLocale().toLanguageTag());
|
||||
@@ -48,16 +114,39 @@ public class BaseController {
|
||||
this.localeResolver.setLocale(request, response, altLocale);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取View。
|
||||
*
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param viewName 参数 {@code viewName}({@code String})
|
||||
* @return 字符串结果
|
||||
*/
|
||||
protected String getView(Authentication authentication, String viewName) {
|
||||
return this.getResource(authentication, viewName + ".html");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Resource。
|
||||
*
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param fileName 文件名({@code String})
|
||||
* @return 字符串结果
|
||||
*/
|
||||
protected String getResource(Authentication authentication, String fileName) {
|
||||
User user = UserPrincipal.getUser(authentication);
|
||||
String theme = user == null ? "default" : user.getTheme();
|
||||
return theme + fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取模板Resource。
|
||||
*
|
||||
* 实现要点:包含 1 个条件分支、0 个循环。
|
||||
*
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param fileName 文件名({@code String})
|
||||
* @return 字符串结果
|
||||
*/
|
||||
protected String getTemplateResource(Authentication authentication, String fileName) {
|
||||
if (this.user == null) {
|
||||
this.user = UserPrincipal.getUser(authentication);
|
||||
@@ -67,6 +156,14 @@ public class BaseController {
|
||||
return "templates/" + theme + fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理determine用户。
|
||||
*
|
||||
* 实现要点:包含同步块;包含 1 个条件分支、0 个循环。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
*/
|
||||
private void determineUser(HttpServletRequest request, Authentication authentication) {
|
||||
if (authentication != null) {
|
||||
synchronized(authentication) {
|
||||
|
||||
Reference in new issue
Block a user