mirror of
https://github.com/continew-org/continew-starter.git
synced 2025-09-09 20:57:23 +08:00
chore: 优化部分代码格式和注释
This commit is contained in:
@@ -13,7 +13,7 @@
|
|||||||
<description>ContiNew Starter 认证模块 - SaToken</description>
|
<description>ContiNew Starter 认证模块 - SaToken</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- Web 模块 -->
|
<!-- Web 模块 - 核心模块 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>top.continew</groupId>
|
<groupId>top.continew</groupId>
|
||||||
<artifactId>continew-starter-web-core</artifactId>
|
<artifactId>continew-starter-web-core</artifactId>
|
||||||
|
@@ -18,7 +18,6 @@ package top.continew.starter.idempotent.aop;
|
|||||||
|
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.text.CharSequenceUtil;
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
|
||||||
import org.aspectj.lang.ProceedingJoinPoint;
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
import org.aspectj.lang.annotation.Around;
|
import org.aspectj.lang.annotation.Around;
|
||||||
import org.aspectj.lang.annotation.Aspect;
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
@@ -98,7 +97,7 @@ public class IdempotentAspect {
|
|||||||
String key = idempotent.key();
|
String key = idempotent.key();
|
||||||
if (CharSequenceUtil.isNotBlank(key)) {
|
if (CharSequenceUtil.isNotBlank(key)) {
|
||||||
Object eval = ExpressionUtils.eval(key, target, method, args);
|
Object eval = ExpressionUtils.eval(key, target, method, args);
|
||||||
if (ObjectUtil.isNull(eval)) {
|
if (eval == null) {
|
||||||
throw new IdempotentException("幂等 Key 解析错误");
|
throw new IdempotentException("幂等 Key 解析错误");
|
||||||
}
|
}
|
||||||
key = Convert.toStr(eval);
|
key = Convert.toStr(eval);
|
||||||
|
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package top.continew.starter.json.jackson.util;
|
package top.continew.starter.json.jackson.util;
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.extra.spring.SpringUtil;
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
@@ -61,7 +60,7 @@ public class JSONUtils {
|
|||||||
* @return {@link String }
|
* @return {@link String }
|
||||||
*/
|
*/
|
||||||
public static String toJsonStr(Object object) {
|
public static String toJsonStr(Object object) {
|
||||||
if (ObjectUtil.isNull(object)) {
|
if (object == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- Web 模块 -->
|
<!-- Web 模块 - 核心模块 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>top.continew</groupId>
|
<groupId>top.continew</groupId>
|
||||||
<artifactId>continew-starter-web-core</artifactId>
|
<artifactId>continew-starter-web-core</artifactId>
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
<description>ContiNew Starter 限流模块</description>
|
<description>ContiNew Starter 限流模块</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- Web 模块 -->
|
<!-- Web 模块 - 核心模块 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>top.continew</groupId>
|
<groupId>top.continew</groupId>
|
||||||
<artifactId>continew-starter-web-core</artifactId>
|
<artifactId>continew-starter-web-core</artifactId>
|
||||||
|
@@ -18,7 +18,6 @@ package top.continew.starter.ratelimiter.aop;
|
|||||||
|
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.text.CharSequenceUtil;
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
|
||||||
import org.aspectj.lang.JoinPoint;
|
import org.aspectj.lang.JoinPoint;
|
||||||
import org.aspectj.lang.ProceedingJoinPoint;
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
import org.aspectj.lang.annotation.Around;
|
import org.aspectj.lang.annotation.Around;
|
||||||
@@ -162,7 +161,7 @@ public class RateLimiterAspect {
|
|||||||
String key = rateLimiter.key();
|
String key = rateLimiter.key();
|
||||||
if (CharSequenceUtil.isNotBlank(key)) {
|
if (CharSequenceUtil.isNotBlank(key)) {
|
||||||
Object eval = ExpressionUtils.eval(key, target, method, args);
|
Object eval = ExpressionUtils.eval(key, target, method, args);
|
||||||
if (ObjectUtil.isNull(eval)) {
|
if (eval == null) {
|
||||||
throw new RateLimiterException("限流 Key 解析错误");
|
throw new RateLimiterException("限流 Key 解析错误");
|
||||||
}
|
}
|
||||||
key = Convert.toStr(eval);
|
key = Convert.toStr(eval);
|
||||||
|
@@ -13,7 +13,7 @@
|
|||||||
<description>ContiNew Starter 安全模块 - XSS 过滤模块</description>
|
<description>ContiNew Starter 安全模块 - XSS 过滤模块</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- Web 模块 -->
|
<!-- Web 模块 - 核心模块 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>top.continew</groupId>
|
<groupId>top.continew</groupId>
|
||||||
<artifactId>continew-starter-web-core</artifactId>
|
<artifactId>continew-starter-web-core</artifactId>
|
||||||
|
@@ -13,18 +13,18 @@
|
|||||||
<description>ContiNew Starter 链路追踪模块</description>
|
<description>ContiNew Starter 链路追踪模块</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- Servlet API -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>jakarta.servlet</groupId>
|
|
||||||
<artifactId>jakarta.servlet-api</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 核心模块 -->
|
<!-- 核心模块 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>top.continew</groupId>
|
<groupId>top.continew</groupId>
|
||||||
<artifactId>continew-starter-core</artifactId>
|
<artifactId>continew-starter-core</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Servlet API -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>jakarta.servlet</groupId>
|
||||||
|
<artifactId>jakarta.servlet-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- TLog(轻量级的分布式日志标记追踪神器) -->
|
<!-- TLog(轻量级的分布式日志标记追踪神器) -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.yomahub</groupId>
|
<groupId>com.yomahub</groupId>
|
||||||
|
@@ -12,6 +12,17 @@
|
|||||||
<description>ContiNew Starter Web 模块 - 核心模块</description>
|
<description>ContiNew Starter Web 模块 - 核心模块</description>
|
||||||
|
|
||||||
<dependencies>
|
<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 服务器) -->
|
<!-- Spring Boot Web(提供 Spring MVC Web 开发能力,默认内置 Tomcat 服务器) -->
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -31,21 +42,5 @@
|
|||||||
<groupId>jakarta.servlet</groupId>
|
<groupId>jakarta.servlet</groupId>
|
||||||
<artifactId>jakarta.servlet-api</artifactId>
|
<artifactId>jakarta.servlet-api</artifactId>
|
||||||
</dependency>
|
</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>
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@@ -24,7 +24,6 @@ import cn.hutool.http.useragent.UserAgentUtil;
|
|||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import jakarta.servlet.http.HttpSession;
|
import jakarta.servlet.http.HttpSession;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.web.context.request.RequestAttributes;
|
import org.springframework.web.context.request.RequestAttributes;
|
||||||
import org.springframework.web.context.request.RequestContextHolder;
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
@@ -69,9 +68,6 @@ public class ServletUtils extends JakartaServletUtil {
|
|||||||
* @return 浏览器及其版本信息
|
* @return 浏览器及其版本信息
|
||||||
*/
|
*/
|
||||||
public static String getBrowser(String userAgentString) {
|
public static String getBrowser(String userAgentString) {
|
||||||
if (StringUtils.isBlank(userAgentString)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
UserAgent userAgent = UserAgentUtil.parse(userAgentString);
|
UserAgent userAgent = UserAgentUtil.parse(userAgentString);
|
||||||
if (userAgent == null || userAgent.getBrowser() == null) {
|
if (userAgent == null || userAgent.getBrowser() == null) {
|
||||||
@@ -79,9 +75,7 @@ public class ServletUtils extends JakartaServletUtil {
|
|||||||
}
|
}
|
||||||
String browserName = userAgent.getBrowser().getName();
|
String browserName = userAgent.getBrowser().getName();
|
||||||
String version = userAgent.getVersion();
|
String version = userAgent.getVersion();
|
||||||
return StringUtils.isBlank(version)
|
return CharSequenceUtil.isBlank(version) ? browserName : browserName + StringConstants.SPACE + version;
|
||||||
? browserName
|
|
||||||
: browserName + StringConstants.SPACE + version;
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -107,9 +101,6 @@ public class ServletUtils extends JakartaServletUtil {
|
|||||||
* @return 操作系统
|
* @return 操作系统
|
||||||
*/
|
*/
|
||||||
public static String getOs(String userAgentString) {
|
public static String getOs(String userAgentString) {
|
||||||
if (StringUtils.isEmpty(userAgentString)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
UserAgent userAgent = UserAgentUtil.parse(userAgentString);
|
UserAgent userAgent = UserAgentUtil.parse(userAgentString);
|
||||||
if (userAgent == null || userAgent.getOs() == null) {
|
if (userAgent == null || userAgent.getOs() == null) {
|
||||||
|
@@ -2,7 +2,6 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>top.continew</groupId>
|
<groupId>top.continew</groupId>
|
||||||
<artifactId>continew-starter-web</artifactId>
|
<artifactId>continew-starter-web</artifactId>
|
||||||
@@ -13,12 +12,19 @@
|
|||||||
<description>ContiNew Starter Web 模块 - 增强支持模块</description>
|
<description>ContiNew Starter Web 模块 - 增强支持模块</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!--web 模块 - 核心模块-->
|
<!-- Web 模块 - 核心模块 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>top.continew</groupId>
|
<groupId>top.continew</groupId>
|
||||||
<artifactId>continew-starter-web-core</artifactId>
|
<artifactId>continew-starter-web-core</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- API 文档模块 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>top.continew</groupId>
|
||||||
|
<artifactId>continew-starter-api-doc</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- Undertow 服务器(采用 Java 开发的灵活的高性能 Web 服务器,提供包括阻塞和基于 NIO 的非堵塞机制) -->
|
<!-- Undertow 服务器(采用 Java 开发的灵活的高性能 Web 服务器,提供包括阻塞和基于 NIO 的非堵塞机制) -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
@@ -30,15 +36,5 @@
|
|||||||
<groupId>com.feiniaojin</groupId>
|
<groupId>com.feiniaojin</groupId>
|
||||||
<artifactId>graceful-response</artifactId>
|
<artifactId>graceful-response</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- API 文档模块 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>top.continew</groupId>
|
|
||||||
<artifactId>continew-starter-api-doc</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
Reference in New Issue
Block a user