feat(验证): 分页插件输出logo分析
This commit is contained in:
parent
d13bb2dbab
commit
8d13f48c70
|
@ -8,7 +8,7 @@ import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class ResourceConfiguration extends WebMvcConfiguration {
|
public class ResourceConfiguration extends WebMvcConfiguration {
|
||||||
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
|
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||||
log.info("ResourceConfiguration===>设置静态资源映射......");
|
log.info("ResourceConfiguration===>设置静态资源映射...");
|
||||||
registry.addResourceHandler("/doc.html").addResourceLocations("classpath:/META-INF/resources/");
|
registry.addResourceHandler("/doc.html").addResourceLocations("classpath:/META-INF/resources/");
|
||||||
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
|
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class WebMvcConfiguration extends WebMvcConfigurationSupport {
|
||||||
* @param registry 跨域注册表
|
* @param registry 跨域注册表
|
||||||
*/
|
*/
|
||||||
protected void addCorsMappings(CorsRegistry registry) {
|
protected void addCorsMappings(CorsRegistry registry) {
|
||||||
log.info("开始跨域注册表...");
|
log.info("WebMvcConfiguration===>开始跨域注册表...");
|
||||||
registry.addMapping("/**")// 添加路径规则
|
registry.addMapping("/**")// 添加路径规则
|
||||||
.allowCredentials(true)// 是否允许在跨域的情况下传递Cookie
|
.allowCredentials(true)// 是否允许在跨域的情况下传递Cookie
|
||||||
.allowedOriginPatterns("*")// 允许请求来源的域规则
|
.allowedOriginPatterns("*")// 允许请求来源的域规则
|
||||||
|
@ -43,7 +43,7 @@ public class WebMvcConfiguration extends WebMvcConfigurationSupport {
|
||||||
* @param registry InterceptorRegistry
|
* @param registry InterceptorRegistry
|
||||||
*/
|
*/
|
||||||
protected void addInterceptors(InterceptorRegistry registry) {
|
protected void addInterceptors(InterceptorRegistry registry) {
|
||||||
log.info("开始注册自定义拦截器...");
|
log.info("WebMvcConfiguration===>开始注册自定义拦截器...");
|
||||||
// 需要拦截的
|
// 需要拦截的
|
||||||
registry.addInterceptor(loginAuthInterceptor).addPathPatterns("/**")
|
registry.addInterceptor(loginAuthInterceptor).addPathPatterns("/**")
|
||||||
.excludePathPatterns(interceptorsProperties.getNoAuthUrls());
|
.excludePathPatterns(interceptorsProperties.getNoAuthUrls());
|
||||||
|
@ -55,7 +55,7 @@ public class WebMvcConfiguration extends WebMvcConfigurationSupport {
|
||||||
* @param converters 转换器
|
* @param converters 转换器
|
||||||
*/
|
*/
|
||||||
public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
|
public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
|
||||||
log.info("扩展消息转换器...");
|
log.info("WebMvcConfiguration===>扩展消息转换器...");
|
||||||
// 创建一个消息转换器对象
|
// 创建一个消息转换器对象
|
||||||
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
|
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
|
||||||
// 需要为消息转换器设置一个对象转换器,对象转换器可以将Java对象序列化为json数据
|
// 需要为消息转换器设置一个对象转换器,对象转换器可以将Java对象序列化为json数据
|
||||||
|
|
|
@ -11,7 +11,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
@ToString
|
@ToString
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class BunnyException extends RuntimeException {
|
public class BunnyException extends RuntimeException {
|
||||||
|
|
||||||
Integer code;// 状态码
|
Integer code;// 状态码
|
||||||
String message;// 描述信息
|
String message;// 描述信息
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ public class GlobalExceptionHandler {
|
||||||
@ExceptionHandler(BunnyException.class)
|
@ExceptionHandler(BunnyException.class)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Result<Object> exceptionHandler(BunnyException exception) {
|
public Result<Object> exceptionHandler(BunnyException exception) {
|
||||||
log.error("自定义异常信息:{}", exception.getMessage());
|
log.error("GlobalExceptionHandler===>自定义异常信息:{}", exception.getMessage());
|
||||||
return Result.error(exception.getCode(), exception.getMessage());
|
return Result.error(exception.getCode(), exception.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ public class GlobalExceptionHandler {
|
||||||
@ExceptionHandler(RuntimeException.class)
|
@ExceptionHandler(RuntimeException.class)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Result<Object> exceptionHandler(RuntimeException exception) {
|
public Result<Object> exceptionHandler(RuntimeException exception) {
|
||||||
log.error("运行时异常信息:{}", exception.getMessage());
|
log.error("GlobalExceptionHandler===>运行时异常信息:{}", exception.getMessage());
|
||||||
return Result.error(500, "出错了啦");
|
return Result.error(500, "出错了啦");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ public class GlobalExceptionHandler {
|
||||||
@ExceptionHandler(Exception.class)
|
@ExceptionHandler(Exception.class)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Result<Object> error(Exception exception) {
|
public Result<Object> error(Exception exception) {
|
||||||
log.error("系统异常信息:{}", exception.getMessage());
|
log.error("GlobalExceptionHandler===>系统异常信息:{}", exception.getMessage());
|
||||||
return Result.error(exception.getMessage());
|
return Result.error(exception.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,14 +44,15 @@ public class GlobalExceptionHandler {
|
||||||
@ExceptionHandler(ArithmeticException.class)
|
@ExceptionHandler(ArithmeticException.class)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Result<Object> error(ArithmeticException exception) {
|
public Result<Object> error(ArithmeticException exception) {
|
||||||
log.error("特定异常信息:{}", exception.getMessage());
|
log.error("GlobalExceptionHandler===>特定异常信息:{}", exception.getMessage());
|
||||||
return Result.error(null, exception.getMessage());
|
return Result.error(null, exception.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
// spring security异常
|
// spring security异常
|
||||||
@ExceptionHandler(AccessDeniedException.class)
|
@ExceptionHandler(AccessDeniedException.class)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Result<String> error(AccessDeniedException e) throws AccessDeniedException {
|
public Result<String> error(AccessDeniedException exception) throws AccessDeniedException {
|
||||||
|
log.error("GlobalExceptionHandler===>spring security异常:{}", exception.getMessage());
|
||||||
return Result.error(ResultCodeEnum.PERMISSION);
|
return Result.error(ResultCodeEnum.PERMISSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +60,7 @@ public class GlobalExceptionHandler {
|
||||||
@ExceptionHandler(SQLIntegrityConstraintViolationException.class)
|
@ExceptionHandler(SQLIntegrityConstraintViolationException.class)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Result<String> exceptionHandler(SQLIntegrityConstraintViolationException exception) {
|
public Result<String> exceptionHandler(SQLIntegrityConstraintViolationException exception) {
|
||||||
log.error("处理SQL异常:{}", exception.getMessage());
|
log.error("GlobalExceptionHandler===>处理SQL异常:{}", exception.getMessage());
|
||||||
String message = exception.getMessage();
|
String message = exception.getMessage();
|
||||||
if (message.contains("Duplicate entry")) {
|
if (message.contains("Duplicate entry")) {
|
||||||
// 截取用户名
|
// 截取用户名
|
||||||
|
|
|
@ -3,8 +3,6 @@ package com.atguigu.interceptor;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.atguigu.context.BaseContext;
|
import com.atguigu.context.BaseContext;
|
||||||
import com.atguigu.spzx.model.entity.system.SysUser;
|
import com.atguigu.spzx.model.entity.system.SysUser;
|
||||||
import com.atguigu.spzx.model.vo.result.Result;
|
|
||||||
import com.atguigu.spzx.model.vo.result.ResultCodeEnum;
|
|
||||||
import com.atguigu.utils.InterceptorUtil;
|
import com.atguigu.utils.InterceptorUtil;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
@ -18,8 +16,6 @@ import org.springframework.lang.Nullable;
|
||||||
import org.springframework.web.method.HandlerMethod;
|
import org.springframework.web.method.HandlerMethod;
|
||||||
import org.springframework.web.servlet.HandlerInterceptor;
|
import org.springframework.web.servlet.HandlerInterceptor;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
|
@ -52,7 +48,7 @@ public class LoginAuthInterceptor implements HandlerInterceptor {
|
||||||
// 将用户信息放到ThreadLocal中
|
// 将用户信息放到ThreadLocal中
|
||||||
SysUser sysUser = JSON.parseObject(userinfoString, SysUser.class);
|
SysUser sysUser = JSON.parseObject(userinfoString, SysUser.class);
|
||||||
BaseContext.setSysUser(sysUser);
|
BaseContext.setSysUser(sysUser);
|
||||||
|
|
||||||
// 更新Redis过期时间
|
// 更新Redis过期时间
|
||||||
redisTemplate.expire(token, 7, TimeUnit.DAYS);
|
redisTemplate.expire(token, 7, TimeUnit.DAYS);
|
||||||
|
|
||||||
|
@ -65,19 +61,6 @@ public class LoginAuthInterceptor implements HandlerInterceptor {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void afterCompletion(@NonNull HttpServletRequest request, @NonNull HttpServletResponse response, @NonNull Object handler, @Nullable Exception ex) throws Exception {
|
public void afterCompletion(@NonNull HttpServletRequest request, @NonNull HttpServletResponse response, @NonNull Object handler, @Nullable Exception ex) throws Exception {
|
||||||
log.info("删除ThreadLocal...");
|
|
||||||
BaseContext.removeSysUser();
|
BaseContext.removeSysUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 响应208状态码给前端
|
|
||||||
private void responseNoLoginInfo(HttpServletResponse response) {
|
|
||||||
Result<ResultCodeEnum> result = Result.error(ResultCodeEnum.LOGIN_AUTH);
|
|
||||||
response.setCharacterEncoding("UTF-8");
|
|
||||||
response.setContentType("text/html; charset=utf-8");
|
|
||||||
try (PrintWriter writer = response.getWriter()) {
|
|
||||||
writer.print(JSON.toJSONString(result));
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error("出错了===>{}", e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -24,11 +24,6 @@
|
||||||
<artifactId>spzx-model</artifactId>
|
<artifactId>spzx-model</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- <dependency> -->
|
|
||||||
<!-- <groupId>com.atguigu</groupId> -->
|
|
||||||
<!-- <artifactId>common-service</artifactId> -->
|
|
||||||
<!-- <version>1.0-SNAPSHOT</version> -->
|
|
||||||
<!-- </dependency> -->
|
|
||||||
<!-- Spring-Web -->
|
<!-- Spring-Web -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
FROM openjdk:18
|
||||||
|
|
||||||
|
#系统编码
|
||||||
|
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
|
||||||
|
|
||||||
|
# 设置时区,构建镜像时执行的命令
|
||||||
|
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||||
|
RUN echo "Asia/Shanghai" > /etc/timezone
|
||||||
|
|
||||||
|
# 设定工作目录
|
||||||
|
WORKDIR /home/bunny
|
||||||
|
|
||||||
|
# 复制jar包
|
||||||
|
COPY target/sky-server-1.0-SNAPSHOT.jar /home/bunny/app.jar
|
||||||
|
|
||||||
|
#启动容器时的进程
|
||||||
|
ENTRYPOINT ["java","-jar","/home/bunny/app.jar"]
|
||||||
|
|
||||||
|
#暴露 8080 端口
|
||||||
|
EXPOSE 8080
|
|
@ -25,7 +25,6 @@ logging:
|
||||||
com.atguigu.mapper: debug
|
com.atguigu.mapper: debug
|
||||||
com.atguigu.controller: info
|
com.atguigu.controller: info
|
||||||
com.atguigu.service: info
|
com.atguigu.service: info
|
||||||
com.github.pagehelper: debug
|
|
||||||
pattern:
|
pattern:
|
||||||
dateformat: HH:mm:ss:SSS
|
dateformat: HH:mm:ss:SSS
|
||||||
file:
|
file:
|
||||||
|
|
|
@ -25,7 +25,6 @@ logging:
|
||||||
com.atguigu.mapper: debug
|
com.atguigu.mapper: debug
|
||||||
com.atguigu.controller: info
|
com.atguigu.controller: info
|
||||||
com.atguigu.service: info
|
com.atguigu.service: info
|
||||||
com.github.pagehelper: debug
|
|
||||||
pattern:
|
pattern:
|
||||||
dateformat: HH:mm:ss:SSS
|
dateformat: HH:mm:ss:SSS
|
||||||
file:
|
file:
|
||||||
|
|
Loading…
Reference in New Issue