package com.athena.meerkat.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.format.FormatterRegistry;
import org.springframework.format.datetime.DateFormatter;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.view.InternalResourceViewResolver;

import com.athena.meerkat.controller.web.common.converter.JsonHttpMessageConverter;
import com.athena.meerkat.controller.web.common.converter.StringToNumberConverterFactory;

/**
 * Spring MVC Configuration
 * @author BongJin Kwon
 * 
 */
@Configuration
@EnableAsync
public class WebMvcConfig extends WebMvcConfigurerAdapter {
	
	@Autowired
	private JsonHttpMessageConverter jsonCustomConverter;

	
	@Override
	public void addFormatters(FormatterRegistry registry) {
		
		// 'yyyy-MM-dd' format string to Date converting.
		registry.addFormatter(new DateFormatter("yyyy-MM-dd"));
		
		registry.removeConvertible(String.class, Number.class);// remove default converter.
		registry.addConverterFactory(new StringToNumberConverterFactory());
	}


	@Override
	public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
		
		converters.add(jsonCustomConverter);
	}
	
	
	
	


}

@@ -481,16 +481,92 @@
 Async;%0D%0A
+import org.springframework.web.multipart.commons.CommonsMultipartResolver;%0D%0A
 import o
@@ -1074,16 +1074,21 @@
 ration%0D%0A
+ * %0D%0A
  * @auth
@@ -1205,17 +1205,16 @@
 pter %7B%0D%0A
-%09
 %0D%0A%09@Auto
@@ -1278,19 +1278,16 @@
 ter;%0D%0A%0D%0A
-%09%0D%0A
 %09@Overri
@@ -1344,26 +1344,24 @@
 egistry) %7B%0D%0A
-%09%09
 %0D%0A%09%09// 'yyyy
@@ -1462,18 +1462,16 @@
 dd%22));%0D%0A
-%09%09
 %0D%0A%09%09regi
@@ -1538,16 +1538,36 @@
  default
+%0D%0A%09%09%09%09%09%09%09%09%09%09%09%09%09%09%09%09//
  convert
@@ -1648,18 +1648,16 @@
 %0D%0A%09%7D%0D%0A%0D%0A
-%0D%0A
 %09@Overri
@@ -1700,16 +1700,21 @@
 verters(
+%0D%0A%09%09%09
 List%3CHtt
@@ -1750,18 +1750,16 @@
 ers) %7B%0D%0A
-%09%09
 %0D%0A%09%09conv
@@ -1800,20 +1800,197 @@
 %09%7D%0D%0A
-%09%0D%0A%09%0D%0A%09%0D%0A%09%0D%0A
+%0D%0A%09@Bean(name = %22multipartResolver%22)%0D%0A%09public CommonsMultipartResolver multipartResolver() %7B%0D%0A%0D%0A%09%09CommonsMultipartResolver resolver = new CommonsMultipartResolver();%0D%0A%09%09return resolver;%0D%0A%09%7D
 %0D%0A%0D%0A

deploy app