2026-01-07 10:14:04 +08:00

40 lines
1.7 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.designhub.config;
import com.designhub.interceptor.PermissionInterceptor;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* Web配置类
*/
@Configuration
@RequiredArgsConstructor
public class WebConfig implements WebMvcConfigurer {
private final PermissionInterceptor permissionInterceptor;
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(permissionInterceptor)
.addPathPatterns("/api/**") // 拦截所有API请求
.excludePathPatterns(
"/api/auth/**", // 排除认证相关接口(包含注册)
"/api/departments", // 排除部门列表接口(注册页面需要)
"/api/hello", // 排除测试接口
"/api/system/health", // 排除健康检查接口
"/api/system-config/group/site", // 排除公开的网站设置API(登录页面需要)
"/api/system-config/key/site.name", // 排除公开的网站设置API(按key获取)
"/api/system-config/key/site.logo", // 排除公开的网站设置API(按key获取)
"/api/system-config/map/group/site", // 排除公开的网站设置API(Map格式)
"/api/dingtalk/config/public", // 排除钉钉公开配置API(免登需要)
"/doc.html", // 排除Swagger文档
"/swagger-ui/**",
"/v3/api-docs/**",
"/webjars/**"
);
}
}