浏览代码

通用远程设置配置

gaodm 5 年之前
父节点
当前提交
3397fc2325

+ 25 - 0
common-biz-client/.gitignore

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

+ 84 - 0
common-biz-client/pom.xml

@@ -0,0 +1,84 @@
+<?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>
+
+    <groupId>com.diagbot</groupId>
+    <artifactId>common-biz-client</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <packaging>jar</packaging>
+
+    <name>common-biz-client</name>
+    <description>common biz client project for Spring Boot</description>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <encoding>UTF-8</encoding>
+        <java.version>1.8</java.version>
+        <maven.compiler.source>1.8</maven.compiler.source>
+        <maven.compiler.target>1.8</maven.compiler.target>
+        <docker.image.prefix>192.168.2.236:5000/diagbotcloud</docker.image.prefix>
+        <registryUrl>http://192.168.2.236:5000/repository/diagbotcloud/</registryUrl>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+            <version>2.2.1.RELEASE</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-openfeign</artifactId>
+            <version>2.2.0.RELEASE</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
+            <version>2.2.0.RELEASE</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <version>1.18.10</version>
+            <scope>provided</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+            <!-- 添加docker-maven插件 -->
+            <plugin>
+                <groupId>com.spotify</groupId>
+                <artifactId>docker-maven-plugin</artifactId>
+                <version>1.1.1</version>
+                <configuration>
+                    <imageName>${docker.image.prefix}/${project.artifactId}:${project.version}</imageName>
+                    <pushImage>true</pushImage>
+                    <!--<forceTags>true</forceTags>-->
+                    <!--镜像的FROM,使用java官方镜像-->
+                    <baseImage>frolvlad/alpine-oraclejre8:slim</baseImage>
+                    <entryPoint>["java", "-jar", "-Xms256m", "-Xmx1024m", "-Duser.timezone=GMT+8", "/${project.build.finalName}.jar"]</entryPoint>
+                    <resources>
+                        <resource>
+                            <targetPath>/</targetPath>
+                            <directory>${project.build.directory}</directory>
+                            <include>${project.build.finalName}.jar</include>
+                        </resource>
+                    </resources>
+                    <serverId>docker-registry</serverId>
+                    <registryUrl>${registryUrl}</registryUrl>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

+ 22 - 0
common-biz-client/src/main/java/com/diagbot/client/MrqcServiceClient.java

@@ -0,0 +1,22 @@
+package com.diagbot.client;
+
+import com.diagbot.client.hystrix.MrqcServiceHystrix;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestHeader;
+import org.springframework.web.bind.annotation.RequestParam;
+
+/**
+ * @Description: 病历质控远程调用客户端
+ * @author: gaodm
+ * @time: 2019/12/23 9:40
+ */
+@FeignClient(name = "MRQC", url = "${mrqc.server.address}", fallback = MrqcServiceHystrix.class)
+public interface MrqcServiceClient {
+
+    @PostMapping(value = "/oauth/token")
+    String demo(@RequestHeader(value = "Authorization") String authorization, @RequestParam("grant_type") String type, @RequestParam("username") String username, @RequestParam("password") String password);
+}
+
+
+

+ 21 - 0
common-biz-client/src/main/java/com/diagbot/client/hystrix/MrqcServiceHystrix.java

@@ -0,0 +1,21 @@
+package com.diagbot.client.hystrix;
+
+import com.diagbot.client.MrqcServiceClient;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+/**
+ * @Description: 病历质控远程调用客户端(请求失败熔断)
+ * @author: gaodm
+ * @time: 2019/12/23 9:40
+ */
+@Component
+@Slf4j
+public class MrqcServiceHystrix implements MrqcServiceClient {
+
+    @Override
+    public String demo(String authorization, String type, String username, String password) {
+        log.error("【hystrix】调用{}异常", "getToken");
+        return null;
+    }
+}

+ 5 - 1
config-server/src/main/resources/shared/application-local.yml

@@ -75,4 +75,8 @@ syslog:
   enable: true
 
 bilog:
-  enable: false
+  enable: false
+
+mrqc:
+  server:
+    address: http://192.168.2.123:5008

+ 6 - 0
icss-service/pom.xml

@@ -24,6 +24,12 @@
             <artifactId>common</artifactId>
             <version>0.0.1-SNAPSHOT</version>
         </dependency>
+
+        <dependency>
+            <groupId>com.diagbot</groupId>
+            <artifactId>common-biz-client</artifactId>
+        </dependency>
+
         <dependency>
             <groupId>org.springframework.cloud</groupId>
             <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>

+ 7 - 0
pom.xml

@@ -32,6 +32,7 @@
         <module>data-service</module>
         <module>prec-service</module>
         <module>precman-service</module>
+        <module>common-biz-client</module>
     </modules>
 
     <parent>
@@ -179,6 +180,12 @@
                 <artifactId>okhttp</artifactId>
                 <version>${okhttp.version}</version>
             </dependency>
+
+            <dependency>
+                <groupId>com.diagbot</groupId>
+                <artifactId>common-biz-client</artifactId>
+                <version>0.0.1-SNAPSHOT</version>
+            </dependency>
         </dependencies>
     </dependencyManagement>