更新sql和代码规范修改

This commit is contained in:
moxiangrong
2024-02-18 15:26:45 +08:00
parent 6f5e6e4662
commit c132b68745
1293 changed files with 43935 additions and 18456 deletions

View File

@ -35,7 +35,8 @@ public class YshopApiLogAutoConfiguration {
* 创建 ApiAccessLogFilter Bean记录 API 请求日志
*/
@Bean
@ConditionalOnProperty(prefix = "yshop.access-log", value = "enable", matchIfMissing = true) // 允许使用 yshop.access-log.enable=false 禁用访问日志
@ConditionalOnProperty(prefix = "yshop.access-log", value = "enable", matchIfMissing = true)
// 允许使用 yshop.access-log.enable=false 禁用访问日志
public FilterRegistrationBean<ApiAccessLogFilter> apiAccessLogFilter(WebProperties webProperties,
@Value("${spring.application.name}") String applicationName,
ApiAccessLogFrameworkService apiAccessLogFrameworkService) {

View File

@ -8,7 +8,7 @@ import org.springframework.scheduling.annotation.Async;
/**
* API 访问日志 Framework Service 实现类
*
* <p>
* 基于 {@link ApiAccessLogApi} 服务,记录访问日志
*
* @author yshop

View File

@ -8,7 +8,7 @@ import org.springframework.scheduling.annotation.Async;
/**
* API 错误日志 Framework Service 实现类
*
* <p>
* 基于 {@link ApiErrorLogApi} 服务,记录错误日志
*
* @author yshop

View File

@ -8,7 +8,7 @@ import java.io.IOException;
/**
* Long 序列化规则
*
* <p>
* 会将超长 long 值转换为 string解决前端 JavaScript 最大安全整数是 2^53-1 的问题
*
* @author 星语

View File

@ -30,7 +30,7 @@ import static co.yixiang.yshop.framework.web.core.util.WebFrameworkUtils.HEADER_
/**
* Swagger 自动配置类,基于 OpenAPI + Springdoc 实现。
*
* <p>
* 友情提示:
* 1. Springdoc 文档地址:<a href="https://github.com/springdoc/springdoc-openapi">仓库</a>
* 2. Swagger 规范,于 2015 更名为 OpenAPI 规范,本质是一个东西
@ -40,7 +40,8 @@ import static co.yixiang.yshop.framework.web.core.util.WebFrameworkUtils.HEADER_
@AutoConfiguration
@ConditionalOnClass({OpenAPI.class})
@EnableConfigurationProperties(SwaggerProperties.class)
@ConditionalOnProperty(prefix = "springdoc.api-docs", name = "enabled", havingValue = "true", matchIfMissing = true) // 设置为 false 时,禁用
@ConditionalOnProperty(prefix = "springdoc.api-docs", name = "enabled", havingValue = "true", matchIfMissing = true)
// 设置为 false 时,禁用
public class YshopSwaggerAutoConfiguration {
// ========== 全局 OpenAPI 配置 ==========
@ -137,7 +138,7 @@ public class YshopSwaggerAutoConfiguration {
/**
* 构建 Authorization 认证请求头参数
*
* <p>
* 解决 Knife4j <a href="https://gitee.com/xiaoym/knife4j/issues/I69QBU">Authorize 未生效请求header里未包含参数</a>
*
* @return 认证参数

View File

@ -32,10 +32,10 @@ public class WebProperties {
/**
* API 前缀,实现所有 Controller 提供的 RESTFul API 的统一前缀
*
*
* <p>
* <p>
* 意义:通过该前缀,避免 Swagger、Actuator 意外通过 Nginx 暴露出来给外部,带来安全性问题
* 这样Nginx 只需要配置转发到 /api/* 的所有接口即可。
* 这样Nginx 只需要配置转发到 /api/* 的所有接口即可。
*
* @see YshopWebAutoConfiguration#configurePathMatch(PathMatchConfigurer)
*/
@ -44,7 +44,7 @@ public class WebProperties {
/**
* Controller 所在包的 Ant 路径规则
*
* <p>
* 主要目的是,给该 Controller 设置指定的 {@link #prefix}
*/
@NotEmpty(message = "Controller 所在包不能为空")

View File

@ -12,7 +12,7 @@ import java.io.IOException;
import java.io.InputStreamReader;
/**
* Request Body 缓存 Wrapper
* Request Body 缓存 Wrapper
*
* @author yshop
*/
@ -55,7 +55,8 @@ public class CacheRequestBodyWrapper extends HttpServletRequestWrapper {
}
@Override
public void setReadListener(ReadListener readListener) {}
public void setReadListener(ReadListener readListener) {
}
@Override
public int available() {

View File

@ -54,7 +54,7 @@ public class GlobalExceptionHandler {
* 因为 Filter 不走 SpringMVC 的流程,但是我们又需要兜底处理异常,所以这里提供一个全量的异常处理过程,保持逻辑统一。
*
* @param request 请求
* @param ex 异常
* @param ex 异常
* @return 通用返回
*/
public CommonResult<?> allExceptionHandler(HttpServletRequest request, Throwable ex) {
@ -96,7 +96,7 @@ public class GlobalExceptionHandler {
/**
* 处理 SpringMVC 请求参数缺失
*
* <p>
* 例如说,接口上设置了 @RequestParam("xx") 参数,结果并未传递 xx 参数
*/
@ExceptionHandler(value = MissingServletRequestParameterException.class)
@ -107,7 +107,7 @@ public class GlobalExceptionHandler {
/**
* 处理 SpringMVC 请求参数类型错误
*
* <p>
* 例如说,接口上设置了 @RequestParam("xx") 参数为 Integer结果传递 xx 参数类型为 String
*/
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
@ -160,7 +160,7 @@ public class GlobalExceptionHandler {
/**
* 处理 SpringMVC 请求地址不存在
*
* <p>
* 注意,它需要设置如下两个配置项:
* 1. spring.mvc.throw-exception-if-no-handler-found 为 true
* 2. spring.mvc.static-path-pattern 为 /statics/**
@ -173,7 +173,7 @@ public class GlobalExceptionHandler {
/**
* 处理 SpringMVC 请求方法不正确
*
* <p>
* 例如说A 接口的方法为 GET 方式,结果请求方法为 POST 方式,导致不匹配
*/
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
@ -193,7 +193,7 @@ public class GlobalExceptionHandler {
/**
* 处理 Spring Security 权限不足的异常
*
* <p>
* 来源是,使用 @PreAuthorize 注解AOP 进行权限拦截
*/
@ExceptionHandler(value = AccessDeniedException.class)
@ -205,7 +205,7 @@ public class GlobalExceptionHandler {
/**
* 处理业务异常 ServiceException
*
* <p>
* 例如说,商品库存不足,用户手机号已存在。
*/
@ExceptionHandler(value = ServiceException.class)
@ -235,7 +235,7 @@ public class GlobalExceptionHandler {
// 执行插入 errorLog
apiErrorLogFrameworkService.createApiErrorLog(errorLog);
} catch (Throwable th) {
log.error("[createExceptionLog][url({}) log({}) 发生异常]", req.getRequestURI(), JsonUtils.toJsonString(errorLog), th);
log.error("[createExceptionLog][url({}) log({}) 发生异常]", req.getRequestURI(), JsonUtils.toJsonString(errorLog), th);
}
}

View File

@ -12,11 +12,11 @@ import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
/**
* 全局响应结果ResponseBody处理器
*
* <p>
* 不同于在网上看到的很多文章,会选择自动将 Controller 返回结果包上 {@link CommonResult}
* 在 onemall 中,是 Controller 在返回时,主动自己包上 {@link CommonResult}。
* 原因是GlobalResponseBodyHandler 本质上是 AOP它不应该改变 Controller 返回的数据结构
*
* <p>
* 目前GlobalResponseBodyHandler 的主要作用是,记录 Controller 的返回结果,
* 方便 {@link co.yixiang.yshop.framework.apilog.core.filter.ApiAccessLogFilter} 记录访问日志
*/

View File

@ -51,7 +51,7 @@ public class WebFrameworkUtils {
/**
* 设置用户类型
*
* @param request 请求
* @param request 请求
* @param userType 用户类型
*/
public static void setLoginUserType(ServletRequest request, Integer userType) {

View File

@ -65,7 +65,7 @@ public class YshopXssAutoConfiguration implements WebMvcConfigurer {
return builder -> builder.serializerByType(LocalDate.class, new LocalDateTimeSerializer(DatePattern.NORM_DATE_FORMATTER))
.serializerByType(LocalDateTime.class, new LocalDateTimeSerializer(DatePattern.NORM_DATETIME_FORMATTER))
.serializerByType(LocalTime.class, new LocalDateTimeSerializer(DatePattern.NORM_TIME_FORMATTER))
//字符串转日期
//字符串转日期
.deserializerByType(LocalDateTime.class, new LocalDateTimeDeserializer(DatePattern.NORM_DATETIME_FORMATTER))
.deserializerByType(LocalDate.class, new LocalDateDeserializer(DatePattern.NORM_DATE_FORMATTER))
.deserializerByType(LocalTime.class, new LocalTimeDeserializer(DatePattern.NORM_TIME_FORMATTER));

View File

@ -1,6 +1,6 @@
/**
* 针对 XSS 的基础封装
*
* <p>
* XSS 说明https://tech.meituan.com/2018/09/27/fe-security.html
*/
package co.yixiang.yshop.framework.xss;