diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/RollCallServer/src/main/java/cc/aspark/config/MybatisPlusConfiguration.java b/RollCallServer/src/main/java/cc/aspark/config/MybatisPlusConfiguration.java new file mode 100644 index 0000000..cebbb24 --- /dev/null +++ b/RollCallServer/src/main/java/cc/aspark/config/MybatisPlusConfiguration.java @@ -0,0 +1,19 @@ +package cc.aspark.config; + +import com.baomidou.mybatisplus.annotation.DbType; +import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; +import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class MybatisPlusConfiguration { + + @Bean + public MybatisPlusInterceptor mybatisPlusInterceptor() { + MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); + interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); + return interceptor; + } + +} \ No newline at end of file diff --git a/RollCallServer/src/main/java/cc/aspark/config/SwaggerConfiguration.java b/RollCallServer/src/main/java/cc/aspark/config/SwaggerConfiguration.java new file mode 100644 index 0000000..6c43ad9 --- /dev/null +++ b/RollCallServer/src/main/java/cc/aspark/config/SwaggerConfiguration.java @@ -0,0 +1,24 @@ +package cc.aspark.config; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Contact; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class SwaggerConfiguration { + + // 设置 openapi 基础参数 + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .info(new Info() + .title("SpringBoot API 管理") + .contact(new Contact().name("spark")) + .version("1.0") + .description("SpringBoot 集成 Knife4j 示例") + .license(new License().name("Apache 2.0"))); + } +} diff --git a/RollCallServer/src/main/java/cc/aspark/config/WebMvcConfiguration.java b/RollCallServer/src/main/java/cc/aspark/config/WebMvcConfiguration.java new file mode 100644 index 0000000..c3c6fc1 --- /dev/null +++ b/RollCallServer/src/main/java/cc/aspark/config/WebMvcConfiguration.java @@ -0,0 +1,36 @@ +package cc.aspark.config; + + +import cc.aspark.interceptor.LoginCheckInterceptor; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +/** + * 配置类,注册web层相关组件 + */ +@Configuration +@Slf4j +@EnableWebMvc +@RequiredArgsConstructor +public class WebMvcConfiguration implements WebMvcConfigurer { + + private final LoginCheckInterceptor loginCheckInterceptor; + + /** + * 注册自定义拦截器 + * + * @param registry + */ + @Override + public void addInterceptors(InterceptorRegistry registry) { + log.info("开始注册自定义拦截器..."); + registry.addInterceptor(loginCheckInterceptor) + .excludePathPatterns("/admin/login") + .excludePathPatterns("/admin/register"); + + } +}