package com.yaoai.admin.config;

import cn.dev33.satoken.interceptor.SaInterceptor;
import com.yaoai.admin.auth.StpAdminUtil;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class SaTokenAdminConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new SaInterceptor(handle -> StpAdminUtil.INSTANCE.checkLogin()))
                .addPathPatterns("/admin-api/**")
                .excludePathPatterns("/admin-api/auth/login");
    }
}
