From a74eb9e22711353c1786fe776110617d2f07e4cb Mon Sep 17 00:00:00 2001
From: eight <641137800@qq.com>
Date: 星期五, 09 八月 2024 16:24:41 +0800
Subject: [PATCH] 调用平台接口 openfeign pass

---
 jh-server/src/main/java/cn/lihu/jh/server/JhServerApplication.java                                                          |    2 
 jh-server/src/main/resources/application-local.yaml                                                                         |    6 +-
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/appointment/AppointmentController.java |   18 ++++++
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/feign/RemoteDataService.java                            |   16 +++++
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/feign/RestApiReqParamVo.java                            |   34 +++++++++++
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/feign/RestApiResult.java                                |   65 +++++++++++++++++++++
 jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/feign/RestApiReqBodyVo.java                             |    9 +++
 jh-server/pom.xml                                                                                                           |    6 ++
 pom.xml                                                                                                                     |    1 
 jh-module-ecg/jh-module-ecg-biz/pom.xml                                                                                     |    7 ++
 10 files changed, 161 insertions(+), 3 deletions(-)

diff --git a/jh-module-ecg/jh-module-ecg-biz/pom.xml b/jh-module-ecg/jh-module-ecg-biz/pom.xml
index 582771c..7f3765e 100644
--- a/jh-module-ecg/jh-module-ecg-biz/pom.xml
+++ b/jh-module-ecg/jh-module-ecg-biz/pom.xml
@@ -119,6 +119,13 @@
             <groupId>com.xingyuv</groupId>
             <artifactId>spring-boot-starter-captcha-plus</artifactId> <!-- 楠岃瘉鐮侊紝涓�鑸敤浜庣櫥褰曚娇鐢� -->
         </dependency>
+
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-openfeign</artifactId>
+            <version>${openfeign.version}</version>
+        </dependency>
+
     </dependencies>
 
 </project>
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/appointment/AppointmentController.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/appointment/AppointmentController.java
index 8c1a4a5..9303784 100644
--- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/appointment/AppointmentController.java
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/appointment/AppointmentController.java
@@ -1,5 +1,9 @@
 package cn.lihu.jh.module.ecg.controller.admin.appointment;
 
+import cn.lihu.jh.module.ecg.feign.RemoteDataService;
+import cn.lihu.jh.module.ecg.feign.RestApiReqBodyVo;
+import cn.lihu.jh.module.ecg.feign.RestApiReqParamVo;
+import cn.lihu.jh.module.ecg.feign.RestApiResult;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -37,6 +41,9 @@
 
     @Resource
     private AppointmentService appointmentService;
+
+    @Resource
+    private RemoteDataService remoteDataService;
 
     @PostMapping("/create")
     @Operation(summary = "鍒涘缓棰勭害")
@@ -99,6 +106,17 @@
         //TODO 澶勭悊鎺掗槦閫昏緫
         //AppointmentDO appointment = appointmentService.getAppointment(id);
         //return success(BeanUtils.toBean(appointment, AppointmentRespVO.class));
+
+        RestApiReqParamVo reqParamVo = new RestApiReqParamVo();
+        reqParamVo.setService("queryEcgRequest");  // queryEcgRequest   QueryRisReportList
+        reqParamVo.setUrid("ECG");
+        reqParamVo.setPwd("ECG");
+        RestApiReqBodyVo reqBodyVo = new RestApiReqBodyVo();
+        reqBodyVo.setSfzh("121");
+        reqBodyVo.setMzzyh("A34343");
+
+        RestApiResult<Object> result = remoteDataService.httpApi("queryEcgRequest", "ECG", "ECG", reqBodyVo);
+
         return success("hello");
     }
 }
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/feign/RemoteDataService.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/feign/RemoteDataService.java
new file mode 100644
index 0000000..3cebbfd
--- /dev/null
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/feign/RemoteDataService.java
@@ -0,0 +1,16 @@
+package cn.lihu.jh.module.ecg.feign;
+
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+
+@FeignClient(name = "remote-data-service", url = "http://127.0.0.1:8080")
+public interface RemoteDataService {
+    @PostMapping(value="/hai/HttpEntry/", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
+    public RestApiResult<Object> httpApi( @RequestParam("service") String service,
+                                          @RequestParam("urid") String urid,
+                                          @RequestParam("pwd") String pwd,
+                                          @RequestBody RestApiReqBodyVo bodyVo);
+}
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/feign/RestApiReqBodyVo.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/feign/RestApiReqBodyVo.java
new file mode 100644
index 0000000..6471369
--- /dev/null
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/feign/RestApiReqBodyVo.java
@@ -0,0 +1,9 @@
+package cn.lihu.jh.module.ecg.feign;
+
+import lombok.Data;
+
+@Data
+public class RestApiReqBodyVo {
+    String sfzh;
+    String mzzyh;
+}
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/feign/RestApiReqParamVo.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/feign/RestApiReqParamVo.java
new file mode 100644
index 0000000..35430ee
--- /dev/null
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/feign/RestApiReqParamVo.java
@@ -0,0 +1,34 @@
+package cn.lihu.jh.module.ecg.feign;
+
+import lombok.Data;
+
+@Data
+public class RestApiReqParamVo {
+    String service;
+    String urid;
+    String pwd;
+
+    public String getService() {
+        return service;
+    }
+
+    public void setService(String service) {
+        this.service = service;
+    }
+
+    public String getUrid() {
+        return urid;
+    }
+
+    public void setUrid(String urid) {
+        this.urid = urid;
+    }
+
+    public String getPwd() {
+        return pwd;
+    }
+
+    public void setPwd(String pwd) {
+        this.pwd = pwd;
+    }
+}
diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/feign/RestApiResult.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/feign/RestApiResult.java
new file mode 100644
index 0000000..32388ab
--- /dev/null
+++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/feign/RestApiResult.java
@@ -0,0 +1,65 @@
+package cn.lihu.jh.module.ecg.feign;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 閫氱敤杩斿洖
+ *
+ * @param <T> 鏁版嵁娉涘瀷
+ */
+@Data
+public class RestApiResult<T> implements Serializable {
+
+    private Integer code;
+    /**
+     * 杩斿洖鏁版嵁
+     */
+    private T data;
+
+    private List<T> row;
+    /**
+     * 閿欒鎻愮ず锛岀敤鎴峰彲闃呰
+     *
+     */
+    private String msg;
+
+    /**
+     * 灏嗕紶鍏ョ殑 result 瀵硅薄锛岃浆鎹㈡垚鍙﹀涓�涓硾鍨嬬粨鏋滅殑瀵硅薄
+     *
+     * 鍥犱负 A 鏂规硶杩斿洖鐨� CommonResult 瀵硅薄锛屼笉婊¤冻璋冪敤鍏剁殑 B 鏂规硶鐨勮繑鍥烇紝鎵�浠ラ渶瑕佽繘琛岃浆鎹€��
+     *
+     * @param result 浼犲叆鐨� result 瀵硅薄
+     * @param <T>    杩斿洖鐨勬硾鍨�
+     * @return 鏂扮殑 CommonResult 瀵硅薄
+     */
+    public static <T> RestApiResult<T> error(RestApiResult<?> result) {
+        return error(result.getCode(), result.getMsg());
+    }
+
+    public static <T> RestApiResult<T> error(Integer code, String message) {
+        RestApiResult<T> result = new RestApiResult<>();
+        result.code = code;
+        result.msg = message;
+        return result;
+    }
+
+    public static <T> RestApiResult<T> success(T data) {
+        RestApiResult<T> result = new RestApiResult<>();
+        result.code = 0;
+        result.data = data;
+        result.msg = "";
+        return result;
+    }
+
+    public static <T> RestApiResult<T> success(List<T> list) {
+        RestApiResult<T> result = new RestApiResult<>();
+        result.code = 0;
+        result.row = list;
+        result.msg = "";
+        return result;
+    }
+
+}
diff --git a/jh-server/pom.xml b/jh-server/pom.xml
index 6f373bb..3041afa 100644
--- a/jh-server/pom.xml
+++ b/jh-server/pom.xml
@@ -129,6 +129,12 @@
         </dependency>
 
         <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-openfeign</artifactId>
+            <version>${openfeign.version}</version>
+        </dependency>
+
+        <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-devtools</artifactId>
             <scope>runtime</scope>
diff --git a/jh-server/src/main/java/cn/lihu/jh/server/JhServerApplication.java b/jh-server/src/main/java/cn/lihu/jh/server/JhServerApplication.java
index c888d65..c4cd3a1 100644
--- a/jh-server/src/main/java/cn/lihu/jh/server/JhServerApplication.java
+++ b/jh-server/src/main/java/cn/lihu/jh/server/JhServerApplication.java
@@ -2,6 +2,7 @@
 
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.openfeign.EnableFeignClients;
 
 /**
  * 椤圭洰鐨勫惎鍔ㄧ被
@@ -14,6 +15,7 @@
  */
 @SuppressWarnings("SpringComponentScan") // 蹇界暐 IDEA 鏃犳硶璇嗗埆 ${jh.info.base-package}
 @SpringBootApplication(scanBasePackages = {"${jh.info.base-package}.server", "${jh.info.base-package}.module"})
+@EnableFeignClients(basePackages = "cn.lihu.jh.module.ecg.feign")
 public class JhServerApplication {
 
     public static void main(String[] args) {
diff --git a/jh-server/src/main/resources/application-local.yaml b/jh-server/src/main/resources/application-local.yaml
index a65dc2b..6b51c89 100644
--- a/jh-server/src/main/resources/application-local.yaml
+++ b/jh-server/src/main/resources/application-local.yaml
@@ -70,10 +70,10 @@
 
   # Redis 閰嶇疆銆俁edisson 榛樿鐨勯厤缃冻澶熶娇鐢紝涓�鑸笉闇�瑕佽繘琛岃皟浼�
   redis:
-    host: r-bp1zyjl0g07e1ry08rpd.redis.rds.aliyuncs.com # 鍦板潃
-    port: 6379 # 绔彛
+    host: 116.62.18.175   #r-bp1zyjl0g07e1ry08rpd.redis.rds.aliyuncs.com # 鍦板潃
+    port: 6020            #绔彛 6379
     database: 2 # 鏁版嵁搴撶储寮�
-    password: Root@yinyu # 瀵嗙爜锛屽缓璁敓浜х幆澧冨紑鍚�
+    password: Smartor    #Root@yinyu # 瀵嗙爜锛屽缓璁敓浜х幆澧冨紑鍚�
 
 --- #################### 瀹氭椂浠诲姟鐩稿叧閰嶇疆 ####################
 
diff --git a/pom.xml b/pom.xml
index 6da604b..06aa563 100644
--- a/pom.xml
+++ b/pom.xml
@@ -43,6 +43,7 @@
         <!-- 鐪嬬湅鍜嬫斁鍒� bom 閲� -->
         <lombok.version>1.18.34</lombok.version>
         <spring.boot.version>2.7.18</spring.boot.version>
+        <openfeign.version>3.1.3</openfeign.version>
         <mapstruct.version>1.5.5.Final</mapstruct.version>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     </properties>

--
Gitblit v1.9.3