| 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;
|
| - |
|
4 |
import java.sql.Timestamp;
|
| - |
|
5 |
import java.time.ZoneId;
|
| - |
|
6 |
import java.time.ZonedDateTime;
|
| 3 |
import java.time.format.DateTimeFormatter;
|
7 |
import java.time.format.DateTimeFormatter;
|
| 4 |
import java.util.List;
|
8 |
import java.util.List;
|
| 5 |
|
9 |
|
| 6 |
import org.springframework.beans.factory.annotation.Autowired;
|
10 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 7 |
import org.springframework.context.annotation.Bean;
|
11 |
import org.springframework.context.annotation.Bean;
|
| Line 13... |
Line 17... |
| 13 |
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
17 |
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
| 14 |
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
18 |
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
| 15 |
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
19 |
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
| 16 |
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
20 |
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
| 17 |
|
21 |
|
| - |
|
22 |
import com.fasterxml.jackson.core.JsonGenerator;
|
| - |
|
23 |
import com.fasterxml.jackson.databind.JsonSerializer;
|
| 18 |
import com.fasterxml.jackson.databind.ObjectMapper;
|
24 |
import com.fasterxml.jackson.databind.ObjectMapper;
|
| 19 |
import com.fasterxml.jackson.databind.SerializationFeature;
|
25 |
import com.fasterxml.jackson.databind.SerializationFeature;
|
| - |
|
26 |
import com.fasterxml.jackson.databind.SerializerProvider;
|
| - |
|
27 |
import com.fasterxml.jackson.databind.ser.std.DateSerializer;
|
| 20 |
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
28 |
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
| 21 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
29 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 22 |
import com.spice.profitmandi.common.web.interceptor.SimpleCORSInterceptor;
|
30 |
import com.spice.profitmandi.common.web.interceptor.SimpleCORSInterceptor;
|
| 23 |
import com.spice.profitmandi.web.interceptor.AuthenticationInterceptor;
|
31 |
import com.spice.profitmandi.web.interceptor.AuthenticationInterceptor;
|
| 24 |
|
32 |
|
| Line 88... |
Line 96... |
| 88 |
"License of API",
|
96 |
"License of API",
|
| 89 |
"API license URL");
|
97 |
"API license URL");
|
| 90 |
return apiInfo;
|
98 |
return apiInfo;
|
| 91 |
}
|
99 |
}
|
| 92 |
|
100 |
|
| 93 |
@Override
|
101 |
/*@Override
|
| 94 |
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
|
102 |
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
|
| 95 |
MappingJackson2HttpMessageConverter jacksonMessageConverter = new MappingJackson2HttpMessageConverter();
|
103 |
MappingJackson2HttpMessageConverter jacksonMessageConverter = new MappingJackson2HttpMessageConverter();
|
| 96 |
ObjectMapper objectMapper = jacksonMessageConverter.getObjectMapper();
|
104 |
ObjectMapper objectMapper = jacksonMessageConverter.getObjectMapper();
|
| 97 |
|
- |
|
| - |
|
105 |
JavaTimeModule javaTimeModule = new JavaTimeModule();
|
| - |
|
106 |
javaTimeModule.addSerializer(java.sql.Date.class, new DateSerializer());
|
| 98 |
objectMapper.registerModule(new JavaTimeModule());
|
107 |
objectMapper.registerModule(javaTimeModule);
|
| 99 |
objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, true);
|
108 |
objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, true);
|
| 100 |
converters.add(jacksonMessageConverter);
|
109 |
converters.add(jacksonMessageConverter);
|
| 101 |
}
|
110 |
}
|
| 102 |
|
111 |
|
| 103 |
/* private ObjectMapper objectMapper() {
|
- |
|
| 104 |
ObjectMapper objectMapper = new ObjectMapper();
|
- |
|
| 105 |
objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
|
- |
|
| 106 |
JavaTimeModule javaTimeModule = new JavaTimeModule();
|
- |
|
| 107 |
javaTimeModule.addSerializer(java.sql.Date.class, new DateSerializer());
|
- |
|
| 108 |
//javaTimeModule.addDeserializer(Timestamp.class, new LocalDateDeserializer());
|
- |
|
| 109 |
objectMapper.registerModule(javaTimeModule);
|
- |
|
| 110 |
return objectMapper;
|
- |
|
| 111 |
}
|
- |
|
| 112 |
|
- |
|
| 113 |
public class LocalDateSerializer extends JsonSerializer<Timestamp> {
|
112 |
public class LocalDateSerializer extends JsonSerializer<Timestamp> {
|
| 114 |
|
113 |
|
| 115 |
@Override
|
114 |
@Override
|
| 116 |
public void serialize(Timestamp value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
115 |
public void serialize(Timestamp value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
| 117 |
|
116 |
|
| 118 |
ZonedDateTime z = value.toInstant().atZone(ZoneId.systemDefault());
|
117 |
ZonedDateTime z = value.toInstant().atZone(ZoneId.systemDefault());
|
| 119 |
String str = FORMATTER.format(z);
|
118 |
String str = FORMATTER.format(z);
|
| 120 |
gen.writeString(str);
|
119 |
gen.writeString(str);
|
| 121 |
}
|
120 |
}
|
| 122 |
}
|
- |
|
| 123 |
*/
|
- |
|
| 124 |
/* public class LocalDateDeserializer extends JsonDeserializer<Timestamp> {
|
- |
|
| 125 |
|
- |
|
| 126 |
@Override
|
- |
|
| 127 |
public Timestamp deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
|
- |
|
| 128 |
LocalDateTime dt = LocalDateTime.parse(p.getText(), FORMATTER);
|
- |
|
| 129 |
// the date/time is in the default timezone
|
- |
|
| 130 |
return Timestamp.from(dt.atZone(ZoneId.systemDefault()).toInstant());
|
- |
|
| 131 |
}
|
- |
|
| 132 |
}*/
|
121 |
}*/
|
| 133 |
|
122 |
|
| 134 |
|
123 |
|
| 135 |
}
|
124 |
}
|
| 136 |
|
125 |
|