From 6f260b13671fcef843d3ed0fdb73636d3f91693a Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期三, 17 七月 2024 10:17:01 +0800 Subject: [PATCH] 1 --- src/main/java/com/se/simu/helper/WebHelper.java | 2 src/main/java/com/se/simu/controller/WaterController.java | 15 +++++++ src/main/java/com/se/simu/SimuApplication.java | 9 ++++ src/main/java/com/se/simu/service/WaterService.java | 7 ++- pom.xml | 12 ++++- src/main/java/com/se/simu/config/WebConfig.java | 41 ++++++++++++++++++++ 6 files changed, 78 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index b42b6f8..d4b09d1 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ <groupId>com.se</groupId> <artifactId>simu</artifactId> <version>1.0.0</version> - <name>simuserver</name> + <name>SimuServer</name> <description>鍐呮稘浠跨湡鏈嶅姟</description> <properties> @@ -32,6 +32,7 @@ <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> + <version>1.18.34</version> <optional>true</optional> </dependency> <!--hutool--> @@ -40,12 +41,17 @@ <artifactId>hutool-all</artifactId> <version>5.8.29</version> </dependency> - <!--fastjson2--> + <!--fastjson--> <dependency> + <groupId>com.alibaba</groupId> + <artifactId>fastjson</artifactId> + <version>1.2.83</version> + </dependency> + <!--dependency> <groupId>com.alibaba.fastjson2</groupId> <artifactId>fastjson2</artifactId> <version>2.0.52</version> - </dependency> + </dependency--> </dependencies> <build> diff --git a/src/main/java/com/se/simu/SimuApplication.java b/src/main/java/com/se/simu/SimuApplication.java index 0ce7a55..3d99701 100644 --- a/src/main/java/com/se/simu/SimuApplication.java +++ b/src/main/java/com/se/simu/SimuApplication.java @@ -3,6 +3,8 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; /** * 鍚姩绋嬪簭绫� @@ -11,8 +13,13 @@ * @date 2024-07-16 */ @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}, scanBasePackages = {"com.se.simu"}) -public class SimuApplication { +public class SimuApplication extends SpringBootServletInitializer { public static void main(String[] args) { SpringApplication.run(SimuApplication.class, args); } + + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder springApplicationBuilder) { + return springApplicationBuilder.sources(SimuApplication.class); + } } diff --git a/src/main/java/com/se/simu/config/WebConfig.java b/src/main/java/com/se/simu/config/WebConfig.java new file mode 100644 index 0000000..723e497 --- /dev/null +++ b/src/main/java/com/se/simu/config/WebConfig.java @@ -0,0 +1,41 @@ +package com.se.simu.config; + +import com.alibaba.fastjson.serializer.SerializerFeature; +import com.alibaba.fastjson.support.config.FastJsonConfig; +import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; + +import java.nio.charset.StandardCharsets; +import java.util.List; + +/** + * Web閰嶇疆绫� + * + * @author WWW + * @date 2024-07-17 + */ +@Configuration +public class WebConfig extends WebMvcConfigurationSupport { + /** + * 澶勭悊json鏍煎紡锛屽�糿ull鐨勮浆鎹负"" + */ + @Override + public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { + FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter(); + FastJsonConfig config = new FastJsonConfig(); + config.setSerializerFeatures( + SerializerFeature.WriteNullListAsEmpty, + SerializerFeature.WriteMapNullValue, + SerializerFeature.WriteNullStringAsEmpty, + SerializerFeature.WriteNullNumberAsZero, + SerializerFeature.WriteNullBooleanAsFalse); + // 缁撴灉鏄惁鏍煎紡鍖�,榛樿涓篺alse + //SerializerFeature.PrettyFormat); + + converter.setFastJsonConfig(config); + converter.setDefaultCharset(StandardCharsets.UTF_8); + converters.add(converter); + } +} diff --git a/src/main/java/com/se/simu/controller/WaterController.java b/src/main/java/com/se/simu/controller/WaterController.java index c40b73b..bbe6232 100644 --- a/src/main/java/com/se/simu/controller/WaterController.java +++ b/src/main/java/com/se/simu/controller/WaterController.java @@ -33,11 +33,17 @@ private final static long Y2000 = 949334400000L; + /** + * 鑾峰彇褰撳墠鏃堕棿 + */ @GetMapping("/getTime") public Object getTime() { return System.currentTimeMillis(); } + /** + * 鑾峰彇鍏冩暟鎹俊鎭� + */ @GetMapping("/{serviceName}/layer.json") public void getLayer(@PathVariable String serviceName, HttpServletResponse res) { try { @@ -54,6 +60,9 @@ } } + /** + * 鑾峰彇鍦板舰楂樺害鍥� + */ @GetMapping("/{serviceName}/terrain") public void getTerraMap(@PathVariable String serviceName, Integer width, Integer height, HttpServletResponse res) { try { @@ -69,6 +78,9 @@ } } + /** + * 鑾峰彇姘撮潰楂樺害鍥� + */ @GetMapping("/{serviceName}/waterMap") public void getWaterMap(@PathVariable String serviceName, Integer width, Integer height, Long timestamp, HttpServletResponse res) { try { @@ -84,6 +96,9 @@ } } + /** + * 鑾峰彇姘存祦鍚戞祦閫熷浘 + */ @GetMapping("/{serviceName}/flowMap") public void getFlowMap(@PathVariable String serviceName, Integer width, Integer height, Long timestamp, HttpServletResponse res) { try { diff --git a/src/main/java/com/se/simu/helper/WebHelper.java b/src/main/java/com/se/simu/helper/WebHelper.java index 08db9f8..adc8d82 100644 --- a/src/main/java/com/se/simu/helper/WebHelper.java +++ b/src/main/java/com/se/simu/helper/WebHelper.java @@ -1,6 +1,6 @@ package com.se.simu.helper; -import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson.JSON; import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; import org.springframework.web.context.request.RequestContextHolder; diff --git a/src/main/java/com/se/simu/service/WaterService.java b/src/main/java/com/se/simu/service/WaterService.java index 04e408c..af77c40 100644 --- a/src/main/java/com/se/simu/service/WaterService.java +++ b/src/main/java/com/se/simu/service/WaterService.java @@ -21,9 +21,6 @@ @Value("${sys.ver}") String ver; - @Value("${sys.path.gdal}") - String gdalPath; - @Value("${sys.path.data}") String dataPath; @@ -49,6 +46,10 @@ } public String getFlowMap(String serviceName, Integer width, Integer height, Long timestamp) { + //com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter; + + + return null; } } -- Gitblit v1.9.3