| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.config;
|
1 |
package com.spice.profitmandi.web.config;
|
| 2 |
|
2 |
|
| 3 |
import java.io.IOException;
|
3 |
import java.io.IOException;
|
| 4 |
import java.sql.Timestamp;
|
4 |
import java.sql.Timestamp;
|
| 5 |
import java.time.LocalDateTime;
|
- |
|
| 6 |
import java.time.ZoneId;
|
5 |
import java.time.ZoneId;
|
| 7 |
import java.time.ZonedDateTime;
|
6 |
import java.time.ZonedDateTime;
|
| 8 |
import java.time.format.DateTimeFormatter;
|
7 |
import java.time.format.DateTimeFormatter;
|
| 9 |
import java.util.List;
|
- |
|
| 10 |
|
8 |
|
| 11 |
import org.springframework.beans.factory.annotation.Autowired;
|
9 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 12 |
import org.springframework.context.annotation.Bean;
|
10 |
import org.springframework.context.annotation.Bean;
|
| 13 |
import org.springframework.context.annotation.ComponentScan;
|
11 |
import org.springframework.context.annotation.ComponentScan;
|
| 14 |
import org.springframework.context.annotation.Configuration;
|
12 |
import org.springframework.context.annotation.Configuration;
|
| 15 |
import org.springframework.http.converter.HttpMessageConverter;
|
13 |
import org.springframework.context.annotation.Primary;
|
| 16 |
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
14 |
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
| 17 |
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
15 |
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
| 18 |
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
16 |
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
| 19 |
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
17 |
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
| 20 |
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
18 |
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
| 21 |
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
19 |
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
| 22 |
|
20 |
|
| 23 |
import com.fasterxml.jackson.core.JsonGenerator;
|
21 |
import com.fasterxml.jackson.core.JsonGenerator;
|
| 24 |
import com.fasterxml.jackson.core.JsonParser;
|
- |
|
| 25 |
import com.fasterxml.jackson.databind.DeserializationContext;
|
- |
|
| 26 |
import com.fasterxml.jackson.databind.JsonDeserializer;
|
- |
|
| 27 |
import com.fasterxml.jackson.databind.JsonSerializer;
|
22 |
import com.fasterxml.jackson.databind.JsonSerializer;
|
| 28 |
import com.fasterxml.jackson.databind.ObjectMapper;
|
23 |
import com.fasterxml.jackson.databind.ObjectMapper;
|
| 29 |
import com.fasterxml.jackson.databind.SerializationFeature;
|
24 |
import com.fasterxml.jackson.databind.SerializationFeature;
|
| 30 |
import com.fasterxml.jackson.databind.SerializerProvider;
|
25 |
import com.fasterxml.jackson.databind.SerializerProvider;
|
| 31 |
import com.fasterxml.jackson.databind.ser.std.DateSerializer;
|
- |
|
| 32 |
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
- |
|
| 33 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
26 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 34 |
import com.spice.profitmandi.common.web.interceptor.SimpleCORSInterceptor;
|
27 |
import com.spice.profitmandi.common.web.interceptor.SimpleCORSInterceptor;
|
| 35 |
import com.spice.profitmandi.web.interceptor.AuthenticationInterceptor;
|
28 |
import com.spice.profitmandi.web.interceptor.AuthenticationInterceptor;
|
| 36 |
|
29 |
|
| 37 |
import springfox.documentation.builders.PathSelectors;
|
30 |
import springfox.documentation.builders.PathSelectors;
|
| Line 100... |
Line 93... |
| 100 |
"License of API",
|
93 |
"License of API",
|
| 101 |
"API license URL");
|
94 |
"API license URL");
|
| 102 |
return apiInfo;
|
95 |
return apiInfo;
|
| 103 |
}
|
96 |
}
|
| 104 |
|
97 |
|
| 105 |
@Override
|
98 |
/* @Override
|
| 106 |
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
|
99 |
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
|
| 107 |
|
100 |
|
| 108 |
converters.add(new MappingJackson2HttpMessageConverter(objectMapper()));
|
101 |
converters.add(new MappingJackson2HttpMessageConverter(objectMapper()));
|
| 109 |
super.configureMessageConverters(converters);
|
102 |
super.configureMessageConverters(converters);
|
| 110 |
}
|
103 |
}
|
| Line 115... |
Line 108... |
| 115 |
JavaTimeModule javaTimeModule = new JavaTimeModule();
|
108 |
JavaTimeModule javaTimeModule = new JavaTimeModule();
|
| 116 |
javaTimeModule.addSerializer(java.sql.Date.class, new DateSerializer());
|
109 |
javaTimeModule.addSerializer(java.sql.Date.class, new DateSerializer());
|
| 117 |
//javaTimeModule.addDeserializer(Timestamp.class, new LocalDateDeserializer());
|
110 |
//javaTimeModule.addDeserializer(Timestamp.class, new LocalDateDeserializer());
|
| 118 |
objectMapper.registerModule(javaTimeModule);
|
111 |
objectMapper.registerModule(javaTimeModule);
|
| 119 |
return objectMapper;
|
112 |
return objectMapper;
|
| - |
|
113 |
}*/
|
| - |
|
114 |
|
| - |
|
115 |
@Bean
|
| - |
|
116 |
@Primary
|
| - |
|
117 |
public ObjectMapper objectMapper(Jackson2ObjectMapperBuilder builder) {
|
| - |
|
118 |
ObjectMapper objectMapper = builder.build();
|
| - |
|
119 |
objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
|
| - |
|
120 |
return objectMapper;
|
| 120 |
}
|
121 |
}
|
| 121 |
|
122 |
|
| 122 |
public class LocalDateSerializer extends JsonSerializer<Timestamp> {
|
123 |
public class LocalDateSerializer extends JsonSerializer<Timestamp> {
|
| 123 |
|
124 |
|
| 124 |
@Override
|
125 |
@Override
|