package com.ruoyi.web.modules.openstats.config;

import javax.servlet.DispatcherType;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import com.ruoyi.web.modules.openstats.filter.OpenStatsTokenFilter;

/**
 * 商城数据统计 Open API Filter 注册
 */
@Configuration
public class OpenStatsFilterConfig
{
    @SuppressWarnings({ "rawtypes", "unchecked" })
    @Bean
    public FilterRegistrationBean openStatsTokenFilterRegistration(OpenStatsTokenFilter filter)
    {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setDispatcherTypes(DispatcherType.REQUEST);
        registration.setFilter(filter);
        registration.addUrlPatterns("/api/open/stats/*");
        registration.setName("openStatsTokenFilter");
        registration.setOrder(Ordered.HIGHEST_PRECEDENCE + 20);
        return registration;
    }
}
