package com.onemap.overlap.config; import com.onemap.common.core.web.domain.RequestResult; import com.onemap.overlap.utils.SpatialiteUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; import org.springframework.stereotype.Component; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import java.io.File; import java.sql.Connection; import java.sql.ResultSet; import java.sql.Statement; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /** * 通用映射配置 * * @author onemap */ //@Configuration @Component public class ResourcesConfig implements WebMvcConfigurer { // @Value("${spatialite.filepath}") // String dbpath; @Value("${file.temp}") String tempfilepath; @Value("${file.proxy}") String proxypath; // private ResourceHandlerRegistry curregistry; // @Autowired // public ResourcesConfig(ResourceHandlerRegistry registry) { // this.curregistry = registry; // } @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler(proxypath + "/**") .addResourceLocations("file:" + tempfilepath + File.separator); // this.curregistry = registry; // try { // Connection connection = SpatialiteUtils.getSpatialiteConnection(dbpath); // Statement statement = connection.createStatement(); // String querySQL = "select * from t_analyse_vector"; // ResultSet resultSet = statement.executeQuery(querySQL); // while (resultSet.next()) { // registry.addResourceHandler(resultSet.getString("tablename") + "/**") // .addResourceLocations("file:" + resultSet.getString("path") + File.separator); // } // connection.close(); // } catch (Exception e) { // e.printStackTrace(); // } } // 动态添加新的资源映射 // public void addDynamicResourceMapping(String pathPattern, String location) { // curregistry.addResourceHandler(pathPattern + "/**") // .addResourceLocations("file:" + location + File.separator); // } }