48 lines
2.0 KiB
Java
48 lines
2.0 KiB
Java
package com.kamco.cd.kamcoback.config;
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.databind.module.SimpleModule;
|
|
import com.kamco.cd.kamcoback.common.utils.geometry.GeometryDeserializer;
|
|
import com.kamco.cd.kamcoback.common.utils.geometry.GeometrySerializer;
|
|
import org.locationtech.jts.geom.Geometry;
|
|
import org.locationtech.jts.geom.Point;
|
|
import org.locationtech.jts.geom.Polygon;
|
|
import org.springframework.context.annotation.Bean;
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
|
@Configuration
|
|
public class WebConfig implements WebMvcConfigurer {
|
|
|
|
private final FileDownloadInteceptor fileDownloadInteceptor;
|
|
|
|
public WebConfig(FileDownloadInteceptor fileDownloadInteceptor) {
|
|
this.fileDownloadInteceptor = fileDownloadInteceptor;
|
|
}
|
|
|
|
@Bean
|
|
public ObjectMapper objectMapper() {
|
|
SimpleModule module = new SimpleModule();
|
|
module.addSerializer(Geometry.class, new GeometrySerializer<>(Geometry.class));
|
|
module.addDeserializer(Geometry.class, new GeometryDeserializer<>(Geometry.class));
|
|
|
|
module.addSerializer(Polygon.class, new GeometrySerializer<>(Polygon.class));
|
|
module.addDeserializer(Polygon.class, new GeometryDeserializer<>(Polygon.class));
|
|
|
|
module.addSerializer(Point.class, new GeometrySerializer<>(Point.class));
|
|
module.addDeserializer(Point.class, new GeometryDeserializer<>(Point.class));
|
|
|
|
return Jackson2ObjectMapperBuilder.json().modulesToInstall(module).build();
|
|
}
|
|
|
|
@Override
|
|
public void addInterceptors(InterceptorRegistry registry) {
|
|
registry
|
|
.addInterceptor(fileDownloadInteceptor)
|
|
.addPathPatterns("/api/inference/download/**") // 추론 파일 다운로드
|
|
.addPathPatterns("/api/training-data/stage/download/**"); // 학습데이터 다운로드
|
|
}
|
|
}
|