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;


/**
 *
 * @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("/sys/logout");
        s.add("/logout");
        s.add("/GetPermissionList");
        s.add("/menu/getMenus");
        s.add("/getPhoneCode");
        s.add("/getPhoneCodeY");
        s.add("/cloud/**");
        s.add("/appInfo/**");
        s.add("/mgr/queryUserInuse");
        s.add("/mgr/getUserListByRoleIdAndDeptId");
        s.add("/mgr/userByUerId");
        s.add("/mgr/releaseUser");
        s.add("/mgr/codemessage");
        s.add("/mgr/changePwd");
        s.add("/dept/selectDeptList");
        s.add("/dept/selectDept");
        s.add("/role/roleLable");
        s.add("/area/selectTaskAreaRel");
        s.add("/forgerpw/verificationCode");
        s.add("/forgerpw/changePwd");
        s.add("/forgerpw/bindingAccount");
        s.add("/forgerpw/defaultLogin");
        s.add("/forgerpw/weixinLogin");
        s.add("/forgerpw/weixinUnbundling");
        s.add("/forgerpw/selectAddress");
        s.add("/forgerpw/selectSchool");
        s.add("/forgerpw/openHall");
        s.add("/forgerpw/registeredAccount");
        s.add("/Personal/**");
        registry.addInterceptor(authIntercept).excludePathPatterns(s);
        super.addInterceptors(registry);
    }

}
