chore: 优化部分代码格式和注释

This commit is contained in:
2025-05-21 22:18:10 +08:00
parent d5a74b42e8
commit 2fdd5b6fd3
11 changed files with 33 additions and 54 deletions

View File

@@ -12,6 +12,17 @@
<description>ContiNew Starter Web 模块 - 核心模块</description>
<dependencies>
<!-- 核心模块 -->
<dependency>
<groupId>top.continew</groupId>
<artifactId>continew-starter-core</artifactId>
</dependency>
<!-- JSON 模块 - Jackson -->
<dependency>
<groupId>top.continew</groupId>
<artifactId>continew-starter-json-jackson</artifactId>
</dependency>
<!-- Spring Boot Web提供 Spring MVC Web 开发能力,默认内置 Tomcat 服务器) -->
<dependency>
@@ -31,21 +42,5 @@
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
</dependency>
<!--核心模块-->
<dependency>
<groupId>top.continew</groupId>
<artifactId>continew-starter-core</artifactId>
</dependency>
<!-- JSON 模块 - Jackson -->
<dependency>
<groupId>top.continew</groupId>
<artifactId>continew-starter-json-jackson</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -24,7 +24,6 @@ import cn.hutool.http.useragent.UserAgentUtil;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
@@ -69,9 +68,6 @@ public class ServletUtils extends JakartaServletUtil {
* @return 浏览器及其版本信息
*/
public static String getBrowser(String userAgentString) {
if (StringUtils.isBlank(userAgentString)) {
return null;
}
try {
UserAgent userAgent = UserAgentUtil.parse(userAgentString);
if (userAgent == null || userAgent.getBrowser() == null) {
@@ -79,9 +75,7 @@ public class ServletUtils extends JakartaServletUtil {
}
String browserName = userAgent.getBrowser().getName();
String version = userAgent.getVersion();
return StringUtils.isBlank(version)
? browserName
: browserName + StringConstants.SPACE + version;
return CharSequenceUtil.isBlank(version) ? browserName : browserName + StringConstants.SPACE + version;
} catch (Exception e) {
return null;
}
@@ -107,9 +101,6 @@ public class ServletUtils extends JakartaServletUtil {
* @return 操作系统
*/
public static String getOs(String userAgentString) {
if (StringUtils.isEmpty(userAgentString)) {
return null;
}
try {
UserAgent userAgent = UserAgentUtil.parse(userAgentString);
if (userAgent == null || userAgent.getOs() == null) {