package com.winsun.item.modular.config;


import com.winsun.intercept.AuthIntercept;
import com.winsun.item.modular.intercept.ChangePwdInterceptor;
import com.winsun.item.modular.intercept.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

import java.util.ArrayList;
import java.util.List;


/**
 * @Author xuede
 * @Date 2020/2/29 16:11
 * @Version 1.0
 */
@Configuration
public class LoginApplicaionConfig extends WebMvcConfigurationSupport {

    @Autowired
    private LoginInterceptor loginInterceptor;

    @Autowired
    private ChangePwdInterceptor changePwdInterceptor;

    @Autowired
    private AuthIntercept authIntercept;



    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        // login changePwd路径进行拦截
        registry.addInterceptor(loginInterceptor).addPathPatterns("/login");
        registry.addInterceptor(changePwdInterceptor).addPathPatterns("/mgr/changePwd");
        registry.addInterceptor(changePwdInterceptor).addPathPatterns("/mgr/changeOtherPwd");
        List<String> s = new ArrayList<>();
        s.add("/login");
        s.add("/getPhoneCode");
        registry.addInterceptor(authIntercept).excludePathPatterns(s);
        super.addInterceptors(registry);
    }

}
