Sfoglia il codice sorgente

吉事办中个人中心

tchao 3 anni fa
commit
0f811e3c8b

+ 33 - 0
.gitignore

@@ -0,0 +1,33 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/

+ 58 - 0
pom.xml

@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.3.3.RELEASE</version>
+        <relativePath/> <!-- lookup parent from repository -->
+    </parent>
+    <groupId>com.example</groupId>
+    <artifactId>sp_api</artifactId>
+    <packaging>war</packaging>
+    <version>0.0.1-SNAPSHOT</version>
+    <name>sp_api</name>
+    <description>Demo project for Spring Boot</description>
+
+    <properties>
+        <java.version>1.8</java.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>com.trs.dongbei</groupId>
+            <artifactId>gov-common-core</artifactId>
+            <version>1.0.0.RELEASE</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.junit.vintage</groupId>
+                    <artifactId>junit-vintage-engine</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+    </dependencies>
+
+    <repositories>
+        <repository>
+            <id>jsecode-maven-central</id>
+            <name>jsecode maven</name>
+            <url>http://2a0924x410.51mypc.cn:51334/repository/java/</url>
+        </repository>
+    </repositories>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

+ 14 - 0
src/main/java/com/example/sp_api/SpApiApplication.java

@@ -0,0 +1,14 @@
+package com.example.sp_api;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class SpApiApplication {
+
+    public static void main(String[] args) {
+
+        SpringApplication.run(SpApiApplication.class, args);
+    }
+
+}

+ 13 - 0
src/main/java/com/example/sp_api/SpringBootStartApplication.java

@@ -0,0 +1,13 @@
+package com.example.sp_api;
+
+import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
+
+public class SpringBootStartApplication  extends SpringBootServletInitializer {
+
+    @Override
+    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
+        // 注意这里要指向原先用main方法执行的Application启动类
+        return builder.sources(SpApiApplication.class);
+    }
+}

+ 48 - 0
src/main/java/com/example/sp_api/service/MyApiService.java

@@ -0,0 +1,48 @@
+package com.example.sp_api.service;
+
+import com.trs.dongbei.gov.common.core.ApiService;
+import com.trs.dongbei.gov.common.core.GovInteractiveVo;
+import com.trs.dongbei.gov.common.core.Page;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.http.converter.StringHttpMessageConverter;
+import org.springframework.stereotype.Service;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
+import org.springframework.web.client.RestOperations;
+import org.springframework.web.client.RestTemplate;
+
+import java.nio.charset.Charset;
+import java.util.HashMap;
+import java.util.Map;
+
+/******************************
+ * TODO
+ * @author yanhongliang
+ * @date 2020-08-14 15:43
+ ******************************/
+
+@Service
+public class MyApiService implements ApiService {
+    @Value("${system.http.host}")
+    private String httpHost;
+
+
+    @Override
+    public Page<GovInteractiveVo> interactive(String userId, Integer pageNo, Integer pageSize) {
+
+        RestTemplate restTemplate=new RestTemplate();
+        Page page=new Page();
+        Map map=new HashMap();
+        map.put("userId",userId);
+        map.put("pageNo",pageNo);
+        map.put("pageSize",pageSize);
+        HttpHeaders headers = new HttpHeaders();
+        restTemplate.getMessageConverters().add(new StringHttpMessageConverter(Charset.forName("utf-8")));
+        page=(Page)restTemplate.postForObject( httpHost+"/api/interactive", map , Page.class );
+        return page;
+    }
+}

+ 38 - 0
src/main/java/com/example/sp_api/service/MyConvenienceService.java

@@ -0,0 +1,38 @@
+package com.example.sp_api.service;
+
+import com.trs.dongbei.gov.common.core.ApiService;
+import com.trs.dongbei.gov.common.core.GovInteractiveVo;
+import com.trs.dongbei.gov.common.core.Page;
+import com.trs.dongbei.gov.common.core.covenience.ConvenienceService;
+import com.trs.dongbei.gov.common.core.covenience.ConvenienceServicesInfoVo;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.converter.StringHttpMessageConverter;
+import org.springframework.stereotype.Service;
+import org.springframework.web.client.RestTemplate;
+
+import java.nio.charset.Charset;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/******************************
+ * TODO
+ * @author yanhongliang
+ * @date 2020-08-14 15:43
+ ******************************/
+
+@Service
+public class MyConvenienceService implements ConvenienceService {
+    @Value("${system.http.host}")
+    private String httpHost;
+    @Override
+    public List<ConvenienceServicesInfoVo> queryServices() {
+        RestTemplate restTemplate=new RestTemplate();
+        Map map=new HashMap();
+        HttpHeaders headers = new HttpHeaders();
+        restTemplate.getMessageConverters().add(new StringHttpMessageConverter(Charset.forName("utf-8")));
+        List list=(List) restTemplate.postForObject(httpHost+"/cities/queryConvenienceServices" ,map, List.class);
+        return list;
+    }
+}

+ 2 - 0
src/main/resources/application.properties

@@ -0,0 +1,2 @@
+system.http.host=http://58.244.255.109:9092/mybatis
+

+ 13 - 0
src/test/java/com/example/sp_api/SpApiApplicationTests.java

@@ -0,0 +1,13 @@
+package com.example.sp_api;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class SpApiApplicationTests {
+
+    @Test
+    void contextLoads() {
+    }
+
+}