package com.usoftchina.uas.office.qywx.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpHeaders;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author yingp
 * @date 2018/11/7
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOrigins("*")
                .allowedMethods("*")
                .allowedHeaders("*")
                .allowCredentials(true)
                .exposedHeaders(HttpHeaders.SET_COOKIE).maxAge(3600L);
    }

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/index").setViewName("dc.html");
        registry.addViewController("/").setViewName("dc.html");
        registry.addViewController("/login").setViewName("/login.html");
        registry.addViewController("/agent").setViewName("agent.html");
        registry.addViewController("/addrbook").setViewName("addrbook.html");
        registry.addViewController("/corp").setViewName("corp.html");
    }
}


