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) {
|
||||
|
||||
@@ -52,11 +52,21 @@ import org.springframework.web.servlet.view.RedirectView;
|
||||
public class DeviceController extends BaseController {
|
||||
|
||||
/** 设备详情页支持的功能标签页集合 */
|
||||
private static List tabs = Arrays.asList("general", "remoteControl", "apps", "files", "location", "logs");
|
||||
private static List<String> tabs = Arrays.asList("general", "remoteControl", "apps", "files", "location", "logs");
|
||||
|
||||
/**
|
||||
* 设备服务;Spring 自动注入的依赖。
|
||||
*
|
||||
* 注解:{@code @Autowired}。
|
||||
*/
|
||||
@Autowired
|
||||
private DeviceService deviceService;
|
||||
|
||||
/**
|
||||
* 会话Manager;Spring 自动注入的依赖。
|
||||
*
|
||||
* 注解:{@code @Autowired}。
|
||||
*/
|
||||
@Autowired
|
||||
private WebSocketSessionManager sessionManager;
|
||||
|
||||
|
||||
@@ -16,8 +16,33 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* 【Web 控制器】{@code ExceptionController}
|
||||
*
|
||||
* 类职责:
|
||||
* <ul>
|
||||
* <li>接收 HTTP 请求、做参数绑定/鉴权,并把业务委托给 Service。</li>
|
||||
* </ul>
|
||||
*
|
||||
* 学习提示:先看类上的 @RequestMapping 路径,再沿 public 方法里的 service 调用链阅读。
|
||||
*/
|
||||
@Controller
|
||||
public class ExceptionController extends BaseController implements ErrorController {
|
||||
/**
|
||||
* 处理异常Handler。
|
||||
*
|
||||
* 实现要点:包含异常捕获与降级/回滚分支;包含 5 个条件分支、0 个循环;主要调用:new Error。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"error"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param sessionId 参数 {@code sessionId}({@code String})
|
||||
* @param model 参数 {@code model}({@code Model})
|
||||
* @param language 参数 {@code language}({@code String})
|
||||
* @return 字符串结果
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"error"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -64,6 +89,16 @@ public class ExceptionController extends BaseController implements ErrorControll
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理gen204。
|
||||
*
|
||||
* 实现要点:包含异常捕获与降级/回滚分支。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping({"generate_204", "gen_204"})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
*/
|
||||
@RequestMapping({"generate_204", "gen_204"})
|
||||
public void gen204(HttpServletRequest request, HttpServletResponse response) {
|
||||
try {
|
||||
@@ -74,6 +109,21 @@ public class ExceptionController extends BaseController implements ErrorControll
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理blocked。
|
||||
*
|
||||
* 实现要点:主要调用:new Error。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"blocked"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param model 参数 {@code model}({@code Model})
|
||||
* @param url 参数 {@code url}({@code String})
|
||||
* @param serialNo 设备序列号({@code String})
|
||||
* @param language 参数 {@code language}({@code String})
|
||||
* @return 字符串结果
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"blocked"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -87,35 +137,96 @@ public class ExceptionController extends BaseController implements ErrorControll
|
||||
return this.getView(authentication, "/error");
|
||||
}
|
||||
|
||||
/**
|
||||
* 【Java 类型】{@code Error}
|
||||
*
|
||||
* 类职责:
|
||||
* <ul>
|
||||
* <li>提供该包内的可复用能力。</li>
|
||||
* <li>通过字段/依赖注入持有运行期状态,字段含义见下方“核心字段”。</li>
|
||||
* </ul>
|
||||
*
|
||||
* 核心字段(按声明顺序):
|
||||
* <ul>
|
||||
* <li>{@code code}(int):代码</li>
|
||||
* <li>{@code exception}(Exception):异常</li>
|
||||
* <li>{@code message}(String):消息</li>
|
||||
* </ul>
|
||||
*
|
||||
* 协作对象:{@code Exception}。
|
||||
*
|
||||
* 学习提示:先看类注释和 public 方法,再结合调用方理解它在整体流程中的位置。
|
||||
*/
|
||||
private class Error {
|
||||
/**
|
||||
* 代码。
|
||||
*/
|
||||
private int code;
|
||||
/**
|
||||
* 异常。
|
||||
*/
|
||||
private Exception exception;
|
||||
/**
|
||||
* 消息。
|
||||
*/
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* 构造 {@code Error} 实例。
|
||||
*
|
||||
* @param code 状态码/业务码({@code int})
|
||||
*/
|
||||
public Error(int code) {
|
||||
this.setCode(code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 {@code code}。
|
||||
* @return 数量/长度
|
||||
*/
|
||||
public int getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 {@code code}。
|
||||
*
|
||||
* @param code 状态码/业务码({@code int})
|
||||
*/
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 {@code exception}。
|
||||
* @return 字段/派生属性 {@code exception} 的值
|
||||
*/
|
||||
public Exception getException() {
|
||||
return this.exception;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 {@code exception}。
|
||||
*
|
||||
* @param exception 参数 {@code exception}({@code Exception})
|
||||
*/
|
||||
public void setException(Exception exception) {
|
||||
this.exception = exception;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 {@code message}。
|
||||
* @return 字符串结果
|
||||
*/
|
||||
public String getMessage() {
|
||||
return this.message;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 {@code message}。
|
||||
*
|
||||
* @param message 消息内容({@code String})
|
||||
*/
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@@ -11,8 +11,31 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* 【Web 控制器】{@code FragmentController}
|
||||
*
|
||||
* 类职责:
|
||||
* <ul>
|
||||
* <li>接收 HTTP 请求、做参数绑定/鉴权,并把业务委托给 Service。</li>
|
||||
* </ul>
|
||||
*
|
||||
* 学习提示:先看类上的 @RequestMapping 路径,再沿 public 方法里的 service 调用链阅读。
|
||||
*/
|
||||
@Controller
|
||||
public class FragmentController extends BaseController {
|
||||
/**
|
||||
* 处理view。
|
||||
*
|
||||
* 实现要点:包含 1 个条件分支、0 个循环。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"/view/**"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param model 参数 {@code model}({@code Model})
|
||||
* @return 字符串结果
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"/view/**"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -27,6 +50,19 @@ public class FragmentController extends BaseController {
|
||||
return this.getView(authentication, request.getServletPath());
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理resourceView。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"/view/system/resource"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param locale 参数 {@code locale}({@code Locale})
|
||||
* @param model 参数 {@code model}({@code Model})
|
||||
* @param category 分类(app/ota/other/report 等)({@code String})
|
||||
* @return 字符串结果
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"/view/system/resource"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -37,6 +73,21 @@ public class FragmentController extends BaseController {
|
||||
return "template/system/resource.html";
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理fragment。
|
||||
*
|
||||
* 实现要点:包含 1 个条件分支、0 个循环。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"/fragment/{fragmentName}"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param locale 参数 {@code locale}({@code Locale})
|
||||
* @param model 参数 {@code model}({@code Model})
|
||||
* @param fragmentName 参数 {@code fragmentName}({@code String})
|
||||
* @return 字符串结果
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"/fragment/{fragmentName}"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -48,20 +99,48 @@ public class FragmentController extends BaseController {
|
||||
model.addAttribute("hasUser", this.userService.hasUser());
|
||||
}
|
||||
|
||||
String var10000 = this.getView(authentication, request.getServletPath());
|
||||
return var10000 + " :: fragment";
|
||||
return this.getView(authentication, request.getServletPath()) + " :: fragment";
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理fragment。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"/fragment/{fragmentName}/{blockName}"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param locale 参数 {@code locale}({@code Locale})
|
||||
* @param model 参数 {@code model}({@code Model})
|
||||
* @param fragmentName 参数 {@code fragmentName}({@code String})
|
||||
* @param blockName 参数 {@code blockName}({@code String})
|
||||
* @return 字符串结果
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"/fragment/{fragmentName}/{blockName}"},
|
||||
method = {RequestMethod.GET}
|
||||
)
|
||||
public String fragment(HttpServletRequest request, HttpServletResponse response, Authentication authentication, Locale locale, Model model, @PathVariable String fragmentName, @PathVariable String blockName) {
|
||||
super.init(request, response, authentication);
|
||||
String var10000 = this.getView(authentication, "/fragment/" + fragmentName);
|
||||
return var10000 + " :: " + blockName;
|
||||
return this.getView(authentication, "/fragment/" + fragmentName) + " :: " + blockName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理dialog。
|
||||
*
|
||||
* 实现要点:包含 1 个条件分支、0 个循环。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"/dialog/{dialogName}"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param locale 参数 {@code locale}({@code Locale})
|
||||
* @param model 参数 {@code model}({@code Model})
|
||||
* @param dialogName 参数 {@code dialogName}({@code String})
|
||||
* @param category 分类(app/ota/other/report 等)({@code String})
|
||||
* @return 字符串结果
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"/dialog/{dialogName}"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -73,7 +152,6 @@ public class FragmentController extends BaseController {
|
||||
model.addAttribute("hasUser", this.userService.hasUser());
|
||||
}
|
||||
|
||||
String var10000 = this.getView(authentication, request.getServletPath());
|
||||
return var10000 + " :: dialog";
|
||||
return this.getView(authentication, request.getServletPath()) + " :: dialog";
|
||||
}
|
||||
}
|
||||
@@ -23,8 +23,37 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.view.RedirectView;
|
||||
|
||||
/**
|
||||
* 【Web 控制器】{@code HomeController}
|
||||
*
|
||||
* 类职责:
|
||||
* <ul>
|
||||
* <li>接收 HTTP 请求、做参数绑定/鉴权,并把业务委托给 Service。</li>
|
||||
* </ul>
|
||||
*
|
||||
* 学习提示:先看类上的 @RequestMapping 路径,再沿 public 方法里的 service 调用链阅读。
|
||||
*/
|
||||
@Controller
|
||||
public class HomeController extends BaseController {
|
||||
/**
|
||||
* 处理home。
|
||||
*
|
||||
* 实现要点:包含 13 个条件分支、0 个循环。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"/", "/index.html"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param tokenUuid 参数 {@code tokenUuid}({@code UUID})
|
||||
* @param siteUuid 站点 UUID({@code UUID})
|
||||
* @param locale 参数 {@code locale}({@code String})
|
||||
* @param model 参数 {@code model}({@code Model})
|
||||
* @param hostName 参数 {@code hostName}({@code String})
|
||||
* @param language 参数 {@code language}({@code String})
|
||||
* @param siteId 参数 {@code siteId}({@code String})
|
||||
* @return 字符串结果
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"/", "/index.html"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -99,6 +128,18 @@ public class HomeController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理home。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"/remoteLogout"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param model 参数 {@code model}({@code Model})
|
||||
* @param language 参数 {@code language}({@code String})
|
||||
* @return 字符串结果
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"/remoteLogout"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -109,6 +150,16 @@ public class HomeController extends BaseController {
|
||||
return this.getView(authentication, "/remoteLogout");
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理homePost。
|
||||
*
|
||||
* 实现要点:包含异常捕获与降级/回滚分支。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"/"}, method = {RequestMethod.POST})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"/"},
|
||||
method = {RequestMethod.POST}
|
||||
@@ -121,6 +172,22 @@ public class HomeController extends BaseController {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册转换为模型站点。
|
||||
*
|
||||
* 实现要点:包含 2 个条件分支、0 个循环。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"register"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param tokenUuid 参数 {@code tokenUuid}({@code UUID})
|
||||
* @param modelSite 参数 {@code modelSite}({@code String})
|
||||
* @param model 参数 {@code model}({@code ModelMap})
|
||||
* @param language 参数 {@code language}({@code String})
|
||||
* @return 字符串结果
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"register"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -143,6 +210,18 @@ public class HomeController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理redirect转换为注册。
|
||||
*
|
||||
* 实现要点:主要调用:new RedirectView。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"{modelSite}/register"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param model 参数 {@code model}({@code ModelMap})
|
||||
* @param modelSite 参数 {@code modelSite}({@code String})
|
||||
* @param language 参数 {@code language}({@code String})
|
||||
* @return 处理结果
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"{modelSite}/register"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -152,6 +231,22 @@ public class HomeController extends BaseController {
|
||||
return new RedirectView("../register?modelSite=" + modelSite);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理bypassMode。
|
||||
*
|
||||
* 实现要点:包含 5 个条件分支、0 个循环;主要调用:new Cookie。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"/bypass", "/dpc"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param tokenUuid 参数 {@code tokenUuid}({@code UUID})
|
||||
* @param model 参数 {@code model}({@code ModelMap})
|
||||
* @param language 参数 {@code language}({@code String})
|
||||
* @param hostName 参数 {@code hostName}({@code String})
|
||||
* @return 字符串结果
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"/bypass", "/dpc"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -189,6 +284,22 @@ public class HomeController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理bypassMode使用模型。
|
||||
*
|
||||
* 实现要点:包含 5 个条件分支、0 个循环;主要调用:new Cookie。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"{modelSite}/bypass", "{modelSite}/dpc"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param tokenUuid 参数 {@code tokenUuid}({@code UUID})
|
||||
* @param model 参数 {@code model}({@code ModelMap})
|
||||
* @param language 参数 {@code language}({@code String})
|
||||
* @param hostName 参数 {@code hostName}({@code String})
|
||||
* @return 字符串结果
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"{modelSite}/bypass", "{modelSite}/dpc"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -226,6 +337,22 @@ public class HomeController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理请求Trial。
|
||||
*
|
||||
* 实现要点:包含 5 个条件分支、0 个循环;主要调用:new Cookie。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"/requestTrial"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param tokenUuid 参数 {@code tokenUuid}({@code UUID})
|
||||
* @param model 参数 {@code model}({@code ModelMap})
|
||||
* @param language 参数 {@code language}({@code String})
|
||||
* @param hostName 参数 {@code hostName}({@code String})
|
||||
* @return 字符串结果
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"/requestTrial"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -263,6 +390,14 @@ public class HomeController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理forward转换为登录。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(method = {RequestMethod.OPTIONS, RequestMethod.GET}, path = {"/login/{siteId}"})}。
|
||||
*
|
||||
* @param siteId 参数 {@code siteId}({@code String})
|
||||
* @return 字符串结果
|
||||
*/
|
||||
@RequestMapping(
|
||||
method = {RequestMethod.OPTIONS, RequestMethod.GET},
|
||||
path = {"/login/{siteId}"}
|
||||
|
||||
@@ -16,8 +16,33 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.server.NotAcceptableStatusException;
|
||||
|
||||
/**
|
||||
* 【Web 控制器】{@code UserController}
|
||||
*
|
||||
* 类职责:
|
||||
* <ul>
|
||||
* <li>接收 HTTP 请求、做参数绑定/鉴权,并把业务委托给 Service。</li>
|
||||
* </ul>
|
||||
*
|
||||
* 学习提示:先看类上的 @RequestMapping 路径,再沿 public 方法里的 service 调用链阅读。
|
||||
*/
|
||||
@Controller
|
||||
public class UserController extends BaseController {
|
||||
/**
|
||||
* 处理home。
|
||||
*
|
||||
* 实现要点:包含 2 个条件分支、0 个循环。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"/resetPassword"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param model 参数 {@code model}({@code Model})
|
||||
* @param passwordTokenUid 参数 {@code passwordTokenUid}({@code String})
|
||||
* @param language 参数 {@code language}({@code String})
|
||||
* @return 字符串结果
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"/resetPassword"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -43,6 +68,19 @@ public class UserController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设置列表。
|
||||
*
|
||||
* 实现要点:包含 1 个条件分支、0 个循环;主要调用:new NotAcceptableStatusException。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"/keepSession"}, method = {RequestMethod.GET}, produces = {"text/plain"})}、{@code @ResponseBody}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param accessToken 参数 {@code accessToken}({@code String})
|
||||
* @return 字符串结果
|
||||
* @throws NotAcceptableStatusException 当 NotAcceptableStatusException 条件不满足或底层调用失败时抛出。
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"/keepSession"},
|
||||
method = {RequestMethod.GET},
|
||||
|
||||
@@ -9,8 +9,29 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* 【Web 控制器】{@code BarcodeController}
|
||||
*
|
||||
* 类职责:
|
||||
* <ul>
|
||||
* <li>接收 HTTP 请求、做参数绑定/鉴权,并把业务委托给 Service。</li>
|
||||
* </ul>
|
||||
*
|
||||
* 学习提示:先看类上的 @RequestMapping 路径,再沿 public 方法里的 service 调用链阅读。
|
||||
*/
|
||||
@Controller
|
||||
public class BarcodeController {
|
||||
/**
|
||||
* 处理qr代码。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"/barcode/qr/{code}"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param code 状态码/业务码({@code String})
|
||||
* @param size 每页数量({@code Integer})
|
||||
* @param margin 参数 {@code margin}({@code Integer})
|
||||
* @param encrypt 参数 {@code encrypt}({@code Boolean})
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"/barcode/qr/{code}"},
|
||||
method = {RequestMethod.GET}
|
||||
|
||||
@@ -36,25 +36,103 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.servlet.HandlerMapping;
|
||||
|
||||
/**
|
||||
* 【Web 控制器】{@code FilesController}
|
||||
*
|
||||
* 类职责:
|
||||
* <ul>
|
||||
* <li>接收 HTTP 请求、做参数绑定/鉴权,并把业务委托给 Service。</li>
|
||||
* <li>通过字段/依赖注入持有运行期状态,字段含义见下方“核心字段”。</li>
|
||||
* </ul>
|
||||
*
|
||||
* 核心字段(按声明顺序):
|
||||
* <ul>
|
||||
* <li>{@code servletContext}(ServletContext):字段 servletContext</li>
|
||||
* <li>{@code fileService}(FileService):文件服务</li>
|
||||
* <li>{@code storeAppService}(StoreAppService):store应用服务</li>
|
||||
* <li>{@code storeOtaService}(StoreOtaService):storeOTA 固件服务</li>
|
||||
* <li>{@code deviceService}(DeviceService):设备服务</li>
|
||||
* <li>{@code reportService}(ReportService):报表服务</li>
|
||||
* </ul>
|
||||
*
|
||||
* 协作对象:{@code ServletContext、FileService、StoreAppService、StoreOtaService、DeviceService、ReportService}。
|
||||
*
|
||||
* 学习提示:先看类上的 @RequestMapping 路径,再沿 public 方法里的 service 调用链阅读。
|
||||
*/
|
||||
@Controller
|
||||
public class FilesController {
|
||||
/**
|
||||
* 字段 servletContext;Spring 自动注入的依赖。
|
||||
*
|
||||
* 注解:{@code @Autowired}。
|
||||
*/
|
||||
@Autowired
|
||||
private ServletContext servletContext;
|
||||
/**
|
||||
* 文件服务;Spring 自动注入的依赖。
|
||||
*
|
||||
* 注解:{@code @Autowired}。
|
||||
*/
|
||||
@Autowired
|
||||
private FileService fileService;
|
||||
/**
|
||||
* store应用服务;Spring 自动注入的依赖。
|
||||
*
|
||||
* 注解:{@code @Autowired}。
|
||||
*/
|
||||
@Autowired
|
||||
private StoreAppService storeAppService;
|
||||
/**
|
||||
* storeOTA 固件服务;Spring 自动注入的依赖。
|
||||
*
|
||||
* 注解:{@code @Autowired}。
|
||||
*/
|
||||
@Autowired
|
||||
private StoreOtaService storeOtaService;
|
||||
/**
|
||||
* 设备服务;Spring 自动注入的依赖。
|
||||
*
|
||||
* 注解:{@code @Autowired}。
|
||||
*/
|
||||
@Autowired
|
||||
private DeviceService deviceService;
|
||||
/**
|
||||
* 报表服务;Spring 自动注入的依赖。
|
||||
*
|
||||
* 注解:{@code @Autowired}。
|
||||
*/
|
||||
@Autowired
|
||||
private ReportService reportService;
|
||||
/**
|
||||
* storeOther服务;Spring 自动注入的依赖。
|
||||
*
|
||||
* 注解:{@code @Autowired}。
|
||||
*/
|
||||
@Autowired
|
||||
private StoreOtherService storeOtherService;
|
||||
/**
|
||||
* cloud存储服务;Spring 自动注入的依赖。
|
||||
*
|
||||
* 注解:{@code @Autowired}。
|
||||
*/
|
||||
@Autowired
|
||||
private CloudStorageService cloudStorageService;
|
||||
|
||||
/**
|
||||
* 获取用户文件。
|
||||
*
|
||||
* 实现要点:主要调用:new McFile、delete。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"userfile/{userUuid}/{fileUuid}/{fileName}"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param userUuid 用户 UUID({@code UUID})
|
||||
* @param fileUuid 文件 UUID({@code UUID})
|
||||
* @param fileName 文件名({@code String})
|
||||
* @param position 参数 {@code position}({@code Long})
|
||||
* @param crc32 参数 {@code crc32}({@code Long})
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"userfile/{userUuid}/{fileUuid}/{fileName}"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -66,6 +144,20 @@ public class FilesController {
|
||||
file.delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理geDevicet文件。
|
||||
*
|
||||
* 实现要点:包含 1 个条件分支、0 个循环;主要调用:new McFile。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"file/device/{deviceUuid}/{fileUuid}/{fileName}"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param deviceUuid 设备 UUID({@code UUID})
|
||||
* @param fileUuid 文件 UUID({@code UUID})
|
||||
* @param fileName 文件名({@code String})
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"file/device/{deviceUuid}/{fileUuid}/{fileName}"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -78,6 +170,20 @@ public class FilesController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件。
|
||||
*
|
||||
* 实现要点:包含异常捕获与降级/回滚分支;包含 2 个条件分支、0 个循环;主要调用:new McFile。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"file/{fileType}/{fileUuid}/{fileName}"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param fileType 参数 {@code fileType}({@code String})
|
||||
* @param fileUuid 文件 UUID({@code UUID})
|
||||
* @param fileName 文件名({@code String})
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"file/{fileType}/{fileUuid}/{fileName}"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -103,6 +209,18 @@ public class FilesController {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取报表模板。
|
||||
*
|
||||
* 实现要点:包含 1 个条件分支、0 个循环;主要调用:new McFile、exists。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"file/report/template/{fileName}"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param fileName 文件名({@code String})
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"file/report/template/{fileName}"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -117,6 +235,19 @@ public class FilesController {
|
||||
McResource.copyFileToResponse(this.servletContext, response, file, fileName, 0, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取MustReserved文件。
|
||||
*
|
||||
* 实现要点:包含 1 个条件分支、0 个循环;主要调用:new McFile。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"must/reserved/{fileUuid}/{fileName}"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param fileUuid 文件 UUID({@code UUID})
|
||||
* @param fileName 文件名({@code String})
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"must/reserved/{fileUuid}/{fileName}"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -129,6 +260,20 @@ public class FilesController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Must下载文件。
|
||||
*
|
||||
* 实现要点:包含 2 个条件分支、0 个循环;主要调用:new McFile。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"must/download/{isDirectory}/{fileUuid}/{fileName}/**"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param fileUuid 文件 UUID({@code UUID})
|
||||
* @param fileName 文件名({@code String})
|
||||
* @param isDirectory 参数 {@code isDirectory}({@code String})
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"must/download/{isDirectory}/{fileUuid}/{fileName}/**"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -149,6 +294,22 @@ public class FilesController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Store应用文件。
|
||||
*
|
||||
* 实现要点:包含 1 个条件分支、0 个循环;主要调用:new McFile。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"store/{fileType}/{packageName}/{versionCode}/{fileUuid}/{fileName}"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param fileType 参数 {@code fileType}({@code String})
|
||||
* @param packageName 参数 {@code packageName}({@code String})
|
||||
* @param versionCode 参数 {@code versionCode}({@code long})
|
||||
* @param fileUuid 文件 UUID({@code UUID})
|
||||
* @param fileName 文件名({@code String})
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"store/{fileType}/{packageName}/{versionCode}/{fileUuid}/{fileName}"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -161,6 +322,20 @@ public class FilesController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取StoreOTA 固件文件。
|
||||
*
|
||||
* 实现要点:包含 1 个条件分支、0 个循环;主要调用:new McFile。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"store/ota/{productId}/{fileUuid}/{fileName}"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param productId 参数 {@code productId}({@code String})
|
||||
* @param fileUuid 文件 UUID({@code UUID})
|
||||
* @param fileName 文件名({@code String})
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"store/ota/{productId}/{fileUuid}/{fileName}"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -173,6 +348,19 @@ public class FilesController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取StoreOther文件。
|
||||
*
|
||||
* 实现要点:包含 1 个条件分支、0 个循环;主要调用:new McFile。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"store/other/{fileUuid}/{fileName}"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param fileUuid 文件 UUID({@code UUID})
|
||||
* @param fileName 文件名({@code String})
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"store/other/{fileUuid}/{fileName}"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -185,6 +373,24 @@ public class FilesController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件。
|
||||
*
|
||||
* 实现要点:包含异常捕获与降级/回滚分支;包含 10 个条件分支、0 个循环;主要调用:new McFile。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"{siteUuid}/file/{fileType}/{fileUuid}/{fileName}"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param siteUuid 站点 UUID({@code String})
|
||||
* @param fileType 参数 {@code fileType}({@code String})
|
||||
* @param fileUuid 文件 UUID({@code String})
|
||||
* @param fileName 文件名({@code String})
|
||||
* @param range 参数 {@code range}({@code String})
|
||||
* @param etag 参数 {@code etag}({@code String})
|
||||
* @param from 起始时间({@code Integer})
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"{siteUuid}/file/{fileType}/{fileUuid}/{fileName}"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -250,6 +456,19 @@ public class FilesController {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取应用Icon。
|
||||
*
|
||||
* 实现要点:包含异常捕获与降级/回滚分支;包含 6 个条件分支、0 个循环;主要调用:getUrl、new McFile、exists。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"icon/app/{fileUuid}/{fileName}"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param fileUuid 文件 UUID({@code UUID})
|
||||
* @param fileName 文件名({@code String})
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"icon/app/{fileUuid}/{fileName}"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -283,8 +502,7 @@ public class FilesController {
|
||||
if (iconFile.exists()) {
|
||||
byte[] iconData = iconFile.toBytes();
|
||||
if (iconData != null) {
|
||||
String var10000 = Files.getNameWithoutExtension(fileName);
|
||||
fileName = var10000 + (iconData[0] == 60 ? ".svg" : ".png");
|
||||
fileName = Files.getNameWithoutExtension(fileName) + (iconData[0] == 60 ? ".svg" : ".png");
|
||||
fileName = McUrlUtils.encode(fileName);
|
||||
McResource.copyFileToResponse(this.servletContext, response, iconData, fileName);
|
||||
return;
|
||||
@@ -296,6 +514,19 @@ public class FilesController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Must站点应用Icon。
|
||||
*
|
||||
* 实现要点:包含 3 个条件分支、0 个循环;主要调用:new McFile、exists。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"icon/must/app/{profileUuid}/{fileName}"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param profileUuid 配置档案 UUID({@code UUID})
|
||||
* @param fileName 文件名({@code String})
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"icon/must/app/{profileUuid}/{fileName}"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -318,6 +549,18 @@ public class FilesController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Store应用Icon。
|
||||
*
|
||||
* 实现要点:包含 2 个条件分支、0 个循环;主要调用:new McFile。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"icon/store/app/{packageName}"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param packageName 参数 {@code packageName}({@code String})
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"icon/store/app/{packageName}"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -337,6 +580,18 @@ public class FilesController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取MimeIcon。
|
||||
*
|
||||
* 实现要点:包含 1 个条件分支、0 个循环。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"icon/mime/{extension}"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param extension 参数 {@code extension}({@code String})
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"icon/mime/{extension}"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -350,6 +605,18 @@ public class FilesController {
|
||||
forwardRequest(request, response, resourcePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取FolderIcon。
|
||||
*
|
||||
* 实现要点:包含 1 个条件分支、0 个循环。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"icon/folder/{folderType}"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param folderType 参数 {@code folderType}({@code String})
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"icon/folder/{folderType}"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -363,6 +630,18 @@ public class FilesController {
|
||||
forwardRequest(request, response, resourcePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户配置档案镜像。
|
||||
*
|
||||
* 实现要点:包含 1 个条件分支、0 个循环;主要调用:new File、new McFile。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"profile/user/{userUuid}"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param aHttputhentication 参数 {@code aHttputhentication}({@code Authentication})
|
||||
* @param userUuid 用户 UUID({@code UUID})
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"profile/user/{userUuid}"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -379,6 +658,18 @@ public class FilesController {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Favicon。
|
||||
*
|
||||
* 实现要点:包含 1 个条件分支、0 个循环;主要调用:new McFile、exists。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"favicon"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param siteUuid 站点 UUID({@code UUID})
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"favicon"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -394,6 +685,18 @@ public class FilesController {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Background镜像。
|
||||
*
|
||||
* 实现要点:包含 3 个条件分支、0 个循环;主要调用:new McFile、exists。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"background"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param siteUuid 站点 UUID({@code UUID})
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"background"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -421,6 +724,15 @@ public class FilesController {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Sitebackground镜像。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"background/{siteUuid}"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param siteUuid 站点 UUID({@code UUID})
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"background/{siteUuid}"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -429,6 +741,15 @@ public class FilesController {
|
||||
this.getSiteImage(request, response, siteUuid, "background");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取站点Logo镜像。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"logo/{siteUuid}"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param siteUuid 站点 UUID({@code UUID})
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"logo/{siteUuid}"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -437,6 +758,15 @@ public class FilesController {
|
||||
this.getSiteImage(request, response, siteUuid, "logo");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取站点配置档案镜像。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"profile/site/{siteUuid}"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param siteUuid 站点 UUID({@code UUID})
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"profile/site/{siteUuid}"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -445,6 +775,16 @@ public class FilesController {
|
||||
this.getSiteImage(request, response, siteUuid, "profile");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取站点镜像。
|
||||
*
|
||||
* 实现要点:包含异常捕获与降级/回滚分支;包含 5 个条件分支、0 个循环;主要调用:getUrl、new McFile、exists。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param siteUuid 站点 UUID({@code UUID})
|
||||
* @param type 类型({@code String})
|
||||
*/
|
||||
public void getSiteImage(HttpServletRequest request, HttpServletResponse response, UUID siteUuid, String type) {
|
||||
if (this.cloudStorageService.hasCloudStorage()) {
|
||||
String url = this.cloudStorageService.getUrl(siteUuid, type);
|
||||
@@ -485,6 +825,17 @@ public class FilesController {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Org配置档案镜像。
|
||||
*
|
||||
* 实现要点:主要调用:new McFile。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"profile/org/{userUuid}"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param userUuid 用户 UUID({@code UUID})
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"profile/org/{userUuid}"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -495,6 +846,18 @@ public class FilesController {
|
||||
McResource.copyFileToResponse(this.servletContext, response, new McFile(profilePath), "profile.jpg", 0, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备Screen镜像。
|
||||
*
|
||||
* 实现要点:包含 2 个条件分支、0 个循环;主要调用:exists、new McFile。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"device/screen/{deviceUuid}"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param deviceUuid 设备 UUID({@code UUID})
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"device/screen/{deviceUuid}"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -512,6 +875,19 @@ public class FilesController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备文件。
|
||||
*
|
||||
* 实现要点:包含异常捕获与降级/回滚分支;包含 1 个条件分支、0 个循环;主要调用:new McFile。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"device/file/{deviceUuid}/{hostFile}/{fileName}"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param deviceUuid 设备 UUID({@code UUID})
|
||||
* @param hostFile 参数 {@code hostFile}({@code String})
|
||||
* @param fileName 文件名({@code String})
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"device/file/{deviceUuid}/{hostFile}/{fileName}"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -531,6 +907,18 @@ public class FilesController {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取检查Sum。
|
||||
*
|
||||
* 实现要点:包含 1 个条件分支、0 个循环;主要调用:new McFile。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"file/checksum/{fileUuid}"}, method = {RequestMethod.GET})}、{@code @ResponseBody}。
|
||||
*
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param fileUuid 文件 UUID({@code UUID})
|
||||
* @param size 每页数量({@code Integer})
|
||||
* @return 字符串结果
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"file/checksum/{fileUuid}"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -548,6 +936,15 @@ public class FilesController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理forward请求。
|
||||
*
|
||||
* 实现要点:包含异常捕获与降级/回滚分支;包含 1 个条件分支、0 个循环。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param path 参数 {@code path}({@code String})
|
||||
*/
|
||||
public static void forwardRequest(HttpServletRequest request, HttpServletResponse response, String path) {
|
||||
try {
|
||||
if (!response.isCommitted()) {
|
||||
@@ -562,6 +959,18 @@ public class FilesController {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找文件。
|
||||
*
|
||||
* 实现要点:包含异常捕获与降级/回滚分支;包含 4 个条件分支、0 个循环;主要调用:getUrl。
|
||||
*
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param fileUuid 文件 UUID({@code UUID})
|
||||
* @param fileType 参数 {@code fileType}({@code String})
|
||||
* @param minify 参数 {@code minify}({@code boolean})
|
||||
* @param siteUuid 站点 UUID({@code UUID})
|
||||
* @return 文件元数据;未找到时返回 {@code null}
|
||||
*/
|
||||
private BaseFile findFile(HttpServletResponse response, UUID fileUuid, String fileType, boolean minify, UUID siteUuid) {
|
||||
BaseFile file = null;
|
||||
switch (fileType) {
|
||||
|
||||
@@ -17,8 +17,27 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
/**
|
||||
* 【Web 控制器】{@code ResourceController}
|
||||
*
|
||||
* 类职责:
|
||||
* <ul>
|
||||
* <li>接收 HTTP 请求、做参数绑定/鉴权,并把业务委托给 Service。</li>
|
||||
* </ul>
|
||||
*
|
||||
* 学习提示:先看类上的 @RequestMapping 路径,再沿 public 方法里的 service 调用链阅读。
|
||||
*/
|
||||
@Controller
|
||||
public class ResourceController extends BaseController {
|
||||
/**
|
||||
* 获取Script。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"/js/**", "/css/**"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @return 字符串结果
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"/js/**", "/css/**"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -27,6 +46,19 @@ public class ResourceController extends BaseController {
|
||||
return this.getResource(authentication, request.getServletPath());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取登录Script。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"js/controller/login.js"}, method = {RequestMethod.GET}, produces = {"application/javascript"})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param model 参数 {@code model}({@code Model})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param hostHeader 参数 {@code hostHeader}({@code String})
|
||||
* @param hostParam 参数 {@code hostParam}({@code String})
|
||||
* @param pageFor 参数 {@code pageFor}({@code String})
|
||||
* @return 字符串结果
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"js/controller/login.js"},
|
||||
method = {RequestMethod.GET},
|
||||
@@ -38,6 +70,18 @@ public class ResourceController extends BaseController {
|
||||
return this.getResource(authentication, request.getServletPath());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取重置PasswordScript。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"/js/controller/resetPassword.js"}, method = {RequestMethod.GET}, produces = {"application/javascript"})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param model 参数 {@code model}({@code Model})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @param userUuid 用户 UUID({@code UUID})
|
||||
* @param tokenUuid 参数 {@code tokenUuid}({@code UUID})
|
||||
* @return 字符串结果
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"/js/controller/resetPassword.js"},
|
||||
method = {RequestMethod.GET},
|
||||
@@ -50,27 +94,54 @@ public class ResourceController extends BaseController {
|
||||
return this.getResource(authentication, request.getServletPath());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取镜像。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"img/**"}, method = {RequestMethod.GET})}、{@code @ResponseBody}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @return 字段/派生属性 {@code image} 的值
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"img/**"},
|
||||
method = {RequestMethod.GET}
|
||||
)
|
||||
@ResponseBody
|
||||
public ResponseEntity getImage(HttpServletRequest request, Authentication authentication) {
|
||||
public ResponseEntity<?> getImage(HttpServletRequest request, Authentication authentication) {
|
||||
String path = this.getTemplateResource(authentication, request.getServletPath());
|
||||
return this.getServletResource(request, path);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Images。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"images/**"}, method = {RequestMethod.GET})}、{@code @ResponseBody}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param authentication Spring Security 认证信息({@code Authentication})
|
||||
* @return 字段/派生属性 {@code images} 的值
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"images/**"},
|
||||
method = {RequestMethod.GET}
|
||||
)
|
||||
@ResponseBody
|
||||
public ResponseEntity getImages(HttpServletRequest request, Authentication authentication) {
|
||||
public ResponseEntity<?> getImages(HttpServletRequest request, Authentication authentication) {
|
||||
String path = this.getTemplateResource(authentication, "/img" + request.getServletPath());
|
||||
return this.getServletResource(request, path);
|
||||
}
|
||||
|
||||
private ResponseEntity getServletResource(HttpServletRequest request, String path) {
|
||||
/**
|
||||
* 获取ServletResource。
|
||||
*
|
||||
* 实现要点:包含 1 个条件分支、0 个循环;主要调用:new MediaType。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param path 参数 {@code path}({@code String})
|
||||
* @return 字段/派生属性 {@code servletResource} 的值
|
||||
*/
|
||||
private ResponseEntity<?> getServletResource(HttpServletRequest request, String path) {
|
||||
String subType = Files.getFileExtension(path);
|
||||
if (Strings.isNullOrEmpty(subType)) {
|
||||
subType = "jpg";
|
||||
|
||||
@@ -39,32 +39,121 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.thymeleaf.TemplateEngine;
|
||||
import org.thymeleaf.context.WebContext;
|
||||
|
||||
/**
|
||||
* 【Web 控制器】{@code StoreController}
|
||||
*
|
||||
* 类职责:
|
||||
* <ul>
|
||||
* <li>接收 HTTP 请求、做参数绑定/鉴权,并把业务委托给 Service。</li>
|
||||
* <li>通过字段/依赖注入持有运行期状态,字段含义见下方“核心字段”。</li>
|
||||
* </ul>
|
||||
*
|
||||
* 核心字段(按声明顺序):
|
||||
* <ul>
|
||||
* <li>{@code servletContext}(ServletContext):字段 servletContext</li>
|
||||
* <li>{@code storeAppService}(StoreAppService):store应用服务</li>
|
||||
* <li>{@code storeOtaService}(StoreOtaService):storeOTA 固件服务</li>
|
||||
* <li>{@code storeWebAppService}(StoreWebAppService):storeWeb应用服务</li>
|
||||
* <li>{@code stringTemplateEngine}(TemplateEngine):string模板Engine</li>
|
||||
* <li>{@code keyStoreService}(KeyStoreService):密钥Store服务</li>
|
||||
* </ul>
|
||||
*
|
||||
* 协作对象:{@code ServletContext、StoreAppService、StoreOtaService、StoreWebAppService、TemplateEngine、KeyStoreService}。
|
||||
*
|
||||
* 学习提示:先看类上的 @RequestMapping 路径,再沿 public 方法里的 service 调用链阅读。
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping({"store"})
|
||||
public class StoreController {
|
||||
/**
|
||||
* 字段 servletContext;Spring 自动注入的依赖。
|
||||
*
|
||||
* 注解:{@code @Autowired}。
|
||||
*/
|
||||
@Autowired
|
||||
private ServletContext servletContext;
|
||||
/**
|
||||
* store应用服务;Spring 自动注入的依赖。
|
||||
*
|
||||
* 注解:{@code @Autowired}。
|
||||
*/
|
||||
@Autowired
|
||||
private StoreAppService storeAppService;
|
||||
/**
|
||||
* storeOTA 固件服务;Spring 自动注入的依赖。
|
||||
*
|
||||
* 注解:{@code @Autowired}。
|
||||
*/
|
||||
@Autowired
|
||||
private StoreOtaService storeOtaService;
|
||||
/**
|
||||
* storeWeb应用服务;Spring 自动注入的依赖。
|
||||
*
|
||||
* 注解:{@code @Autowired}。
|
||||
*/
|
||||
@Autowired
|
||||
private StoreWebAppService storeWebAppService;
|
||||
/**
|
||||
* string模板Engine;Spring 自动注入的依赖。
|
||||
*
|
||||
* 注解:{@code @Autowired @Qualifier("stringTemplateEngine")}。
|
||||
*/
|
||||
@Autowired
|
||||
@Qualifier("stringTemplateEngine")
|
||||
private TemplateEngine stringTemplateEngine;
|
||||
/**
|
||||
* 密钥Store服务;Spring 自动注入的依赖。
|
||||
*
|
||||
* 注解:{@code @Autowired}。
|
||||
*/
|
||||
@Autowired
|
||||
private KeyStoreService keyStoreService;
|
||||
/**
|
||||
* storeOther服务;Spring 自动注入的依赖。
|
||||
*
|
||||
* 注解:{@code @Autowired}。
|
||||
*/
|
||||
@Autowired
|
||||
private StoreOtherService storeOtherService;
|
||||
/**
|
||||
* 文件服务;Spring 自动注入的依赖。
|
||||
*
|
||||
* 注解:{@code @Autowired}。
|
||||
*/
|
||||
@Autowired
|
||||
private FileService fileService;
|
||||
/**
|
||||
* cloud存储服务;Spring 自动注入的依赖。
|
||||
*
|
||||
* 注解:{@code @Autowired}。
|
||||
*/
|
||||
@Autowired
|
||||
private CloudStorageService cloudStorageService;
|
||||
/**
|
||||
* host许可证服务;Spring 自动注入的依赖。
|
||||
*
|
||||
* 注解:{@code @Autowired @Lazy}。
|
||||
*/
|
||||
@Autowired
|
||||
@Lazy
|
||||
private HostLicenseService hostLicenseService;
|
||||
|
||||
/**
|
||||
* 获取最新应用。
|
||||
*
|
||||
* 实现要点:包含 2 个条件分支、0 个循环;主要调用:find。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"apps/download/{packageName}"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param packageName 参数 {@code packageName}({@code String})
|
||||
* @param range 参数 {@code range}({@code String})
|
||||
* @param etag 参数 {@code etag}({@code String})
|
||||
* @param certMd5 参数 {@code certMd5}({@code String})
|
||||
* @param keyStoreId 参数 {@code keyStoreId}({@code String})
|
||||
* @param versionCode 参数 {@code versionCode}({@code int})
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"apps/download/{packageName}"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -82,6 +171,22 @@ public class StoreController {
|
||||
this.getApp(request, response, range, etag, packageName, String.valueOf(versionCode), keyStoreId, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取应用。
|
||||
*
|
||||
* 实现要点:包含异常捕获与降级/回滚分支;包含 4 个条件分支、0 个循环;主要调用:find。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"apps/{packageName}/{version}/{keyStoreId}"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param range 参数 {@code range}({@code String})
|
||||
* @param etag 参数 {@code etag}({@code String})
|
||||
* @param packageName 参数 {@code packageName}({@code String})
|
||||
* @param version 参数 {@code version}({@code String})
|
||||
* @param keyStoreId 参数 {@code keyStoreId}({@code String})
|
||||
* @param sdkVersion 参数 {@code sdkVersion}({@code int})
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"apps/{packageName}/{version}/{keyStoreId}"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -124,6 +229,21 @@ public class StoreController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取应用。
|
||||
*
|
||||
* 实现要点:包含异常捕获与降级/回滚分支;包含 1 个条件分支、0 个循环。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"app/{fileUuid}"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param fileUuid 文件 UUID({@code UUID})
|
||||
* @param range 参数 {@code range}({@code String})
|
||||
* @param etag 参数 {@code etag}({@code String})
|
||||
* @param position 参数 {@code position}({@code Long})
|
||||
* @param checksum 参数 {@code checksum}({@code Long})
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"app/{fileUuid}"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -142,6 +262,15 @@ public class StoreController {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取应用。
|
||||
*
|
||||
* 实现要点:包含异常捕获与降级/回滚分支;包含 1 个条件分支、0 个循环;主要调用:getUrl、new McFile。
|
||||
*
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param appFile 参数 {@code appFile}({@code StoreAppFile})
|
||||
* @param range 参数 {@code range}({@code String})
|
||||
*/
|
||||
private void getApp(HttpServletResponse response, StoreAppFile appFile, String range) {
|
||||
String url = this.cloudStorageService.getUrl("store", "app", appFile.getPackageName(), appFile.getVersionCode(), appFile.getFileUuid());
|
||||
if (Strings.isNullOrEmpty(url)) {
|
||||
@@ -157,6 +286,18 @@ public class StoreController {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理应用Release备注。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"apps/{packageName}/releaseNote"}, method = {RequestMethod.GET})}、{@code @ResponseBody}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param packageName 参数 {@code packageName}({@code String})
|
||||
* @param sdkVersion 参数 {@code sdkVersion}({@code int})
|
||||
* @return 字符串结果
|
||||
* @throws IOException 当 IOException 条件不满足或底层调用失败时抛出。
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"apps/{packageName}/releaseNote"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -166,6 +307,23 @@ public class StoreController {
|
||||
return this.appReleaseNote(request, response, packageName, (String)null, (Integer)null, sdkVersion, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理应用Release备注。
|
||||
*
|
||||
* 实现要点:包含 2 个条件分支、0 个循环;主要调用:new WebContext、find、process。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"apps/{packageName}/{keyStore}/releaseNote", "apps/{packageName}/{keyStore}/releaseNote/{pathSdkVersion}"}, method = {RequestMethod.GET})}、{@code @ResponseBody}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param packageName 参数 {@code packageName}({@code String})
|
||||
* @param keyStore 参数 {@code keyStore}({@code String})
|
||||
* @param pathSdkVersion 参数 {@code pathSdkVersion}({@code Integer})
|
||||
* @param sdkVersion 参数 {@code sdkVersion}({@code int})
|
||||
* @param isFormal 参数 {@code isFormal}({@code Boolean})
|
||||
* @return 字符串结果
|
||||
* @throws IOException 当 IOException 条件不满足或底层调用失败时抛出。
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"apps/{packageName}/{keyStore}/releaseNote", "apps/{packageName}/{keyStore}/releaseNote/{pathSdkVersion}"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -196,6 +354,20 @@ public class StoreController {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理应用Release备注Show全部。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"apps/{packageName}/{keyStore}/releaseNote/showAllDownloadLink", "apps/{packageName}/{keyStore}/releaseNote/showAllDownloadLink/{pathSdkVersion}"}, method = {RequestMethod.GET})}、{@code @ResponseBody}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param packageName 参数 {@code packageName}({@code String})
|
||||
* @param keyStore 参数 {@code keyStore}({@code String})
|
||||
* @param pathSdkVersion 参数 {@code pathSdkVersion}({@code Integer})
|
||||
* @param sdkVersion 参数 {@code sdkVersion}({@code int})
|
||||
* @return 字符串结果
|
||||
* @throws IOException 当 IOException 条件不满足或底层调用失败时抛出。
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"apps/{packageName}/{keyStore}/releaseNote/showAllDownloadLink", "apps/{packageName}/{keyStore}/releaseNote/showAllDownloadLink/{pathSdkVersion}"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -205,6 +377,21 @@ public class StoreController {
|
||||
return this.appReleaseNote(request, response, packageName, keyStore, pathSdkVersion, sdkVersion, (Boolean)null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取OTA 固件。
|
||||
*
|
||||
* 实现要点:包含异常捕获与降级/回滚分支;包含 2 个条件分支、0 个循环;主要调用:getUrl、new McFile。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"ota/{fileUuid}"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param fileUuid 文件 UUID({@code UUID})
|
||||
* @param range 参数 {@code range}({@code String})
|
||||
* @param etag 参数 {@code etag}({@code String})
|
||||
* @param position 参数 {@code position}({@code Long})
|
||||
* @param checksum 参数 {@code checksum}({@code Long})
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"ota/{fileUuid}"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -230,6 +417,22 @@ public class StoreController {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Web应用。
|
||||
*
|
||||
* 实现要点:包含异常捕获与降级/回滚分支;主要调用:find。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"webapp/{fileUuid}"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param fileUuid 文件 UUID({@code String})
|
||||
* @param range 参数 {@code range}({@code String})
|
||||
* @param etag 参数 {@code etag}({@code String})
|
||||
* @param position 参数 {@code position}({@code Long})
|
||||
* @param checksum 参数 {@code checksum}({@code Long})
|
||||
* @throws IOException 当 IOException 条件不满足或底层调用失败时抛出。
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"webapp/{fileUuid}"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -246,6 +449,20 @@ public class StoreController {
|
||||
this.getWebApp(response, app, range);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Web应用。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"webapp/latest"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param range 参数 {@code range}({@code String})
|
||||
* @param etag 参数 {@code etag}({@code String})
|
||||
* @param groupId 参数 {@code groupId}({@code String})
|
||||
* @param artifactId 参数 {@code artifactId}({@code String})
|
||||
* @param isFormal 参数 {@code isFormal}({@code boolean})
|
||||
* @throws IOException 当 IOException 条件不满足或底层调用失败时抛出。
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"webapp/latest"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -255,6 +472,15 @@ public class StoreController {
|
||||
this.getWebApp(response, app, range);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Web应用。
|
||||
*
|
||||
* 实现要点:包含异常捕获与降级/回滚分支;包含 3 个条件分支、0 个循环;主要调用:getUrl、new McFile、exists。
|
||||
*
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param app 参数 {@code app}({@code StoreWebApp})
|
||||
* @param range 参数 {@code range}({@code String})
|
||||
*/
|
||||
private void getWebApp(HttpServletResponse response, StoreWebApp app, String range) {
|
||||
try {
|
||||
if (app != null) {
|
||||
@@ -278,6 +504,23 @@ public class StoreController {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理web应用Release备注。
|
||||
*
|
||||
* 实现要点:主要调用:findAll、new WebContext、process。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"webapp/releaseNote"}, method = {RequestMethod.GET})}、{@code @ResponseBody}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param groupId 参数 {@code groupId}({@code String})
|
||||
* @param artifactId 参数 {@code artifactId}({@code String})
|
||||
* @param version 参数 {@code version}({@code String})
|
||||
* @param limit 数量上限({@code int})
|
||||
* @param isFormal 参数 {@code isFormal}({@code boolean})
|
||||
* @return 字符串结果
|
||||
* @throws IOException 当 IOException 条件不满足或底层调用失败时抛出。
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"webapp/releaseNote"},
|
||||
method = {RequestMethod.GET}
|
||||
@@ -294,6 +537,21 @@ public class StoreController {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Other文件。
|
||||
*
|
||||
* 实现要点:包含异常捕获与降级/回滚分支;包含 2 个条件分支、0 个循环;主要调用:getUrl、new McFile。
|
||||
*
|
||||
* 框架注解:{@code @RequestMapping(value = {"other/{fileName}"}, method = {RequestMethod.GET})}。
|
||||
*
|
||||
* @param request HTTP 请求({@code HttpServletRequest})
|
||||
* @param response HTTP 响应({@code HttpServletResponse})
|
||||
* @param fileName 文件名({@code String})
|
||||
* @param range 参数 {@code range}({@code String})
|
||||
* @param etag 参数 {@code etag}({@code String})
|
||||
* @param position 参数 {@code position}({@code Long})
|
||||
* @param checksum 参数 {@code checksum}({@code Long})
|
||||
*/
|
||||
@RequestMapping(
|
||||
value = {"other/{fileName}"},
|
||||
method = {RequestMethod.GET}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* 文件/图片下载与静态资源控制器:处理设备截图、应用图标、报表下载等二进制响应。
|
||||
*
|
||||
* <p>本包主要类型:
|
||||
* <ul>
|
||||
* <li>{@link BarcodeController}</li>
|
||||
* <li>{@link FilesController}</li>
|
||||
* <li>{@link ResourceController}</li>
|
||||
* <li>{@link StoreController}</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>阅读建议:结合本包内类的 Javadoc 与 {@code docs/CODE_WALKTHROUGH.md} 一起看,
|
||||
* 先理解输入/输出,再跟踪 Service 与 MongoTemplate 的调用链。
|
||||
*/
|
||||
package com.midm.controller.lib;
|
||||
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* 页面路由控制器:负责 Thymeleaf 页面渲染、登录跳转和静态资源入口。
|
||||
*
|
||||
* <p>本包主要类型:
|
||||
* <ul>
|
||||
* <li>{@link BaseController}</li>
|
||||
* <li>{@link DeviceController}</li>
|
||||
* <li>{@link ExceptionController}</li>
|
||||
* <li>{@link FragmentController}</li>
|
||||
* <li>{@link HomeController}</li>
|
||||
* <li>{@link UserController}</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>阅读建议:结合本包内类的 Javadoc 与 {@code docs/CODE_WALKTHROUGH.md} 一起看,
|
||||
* 先理解输入/输出,再跟踪 Service 与 MongoTemplate 的调用链。
|
||||
*/
|
||||
package com.midm.controller;
|
||||
Reference in new issue
Block a user