package com.heketai.website.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * @author : yanBin
 * date :2022/5/17 11:50
 * introduction: 前置拦截器
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Resource
    private CheckTokenInterceptor checkTokenInterceptor;


    /**
     * 对接口的token拦截
     *  param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(checkTokenInterceptor)
                 .excludePathPatterns("/user/**") //表示放行的接口
                 .addPathPatterns("**/insert") //表示拦截的接口
                 .addPathPatterns("**/deleteById")
                 .addPathPatterns("**/update")
                 .addPathPatterns("/oss/removeFile")
                 .addPathPatterns("/cooperative/del")
                 .addPathPatterns("/cooperative/set-update")
                 .addPathPatterns("/job/update-search")
                 .addPathPatterns("/job/add-search")
                 .addPathPatterns("/job/delete-search")
                 .addPathPatterns("/product/importExcel")
                 .addPathPatterns("/product/updateApplication")
                 .addPathPatterns("/replacePicture/updateMyImg")
                 .addPathPatterns("/websiteContact/updateContact")
                 .addPathPatterns("/contactImage/delImage")
                 .addPathPatterns("/menuContent/updateById")
                 .addPathPatterns("/menuContent/batchUpdate")
                 .addPathPatterns("/menuContent/deleteImage");

    }
}
