eight
2024-08-09 a74eb9e22711353c1786fe776110617d2f07e4cb
调用平台接口 openfeign pass
已添加4个文件
已修改6个文件
164 ■■■■■ 文件已修改
jh-module-ecg/jh-module-ecg-biz/pom.xml 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/controller/admin/appointment/AppointmentController.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/feign/RemoteDataService.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/feign/RestApiReqBodyVo.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/feign/RestApiReqParamVo.java 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/feign/RestApiResult.java 65 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jh-server/pom.xml 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jh-server/src/main/java/cn/lihu/jh/server/JhServerApplication.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
jh-server/src/main/resources/application-local.yaml 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pom.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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>
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");
    }
}
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);
}
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;
}
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;
    }
}
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;
    }
}
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>
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) {
jh-server/src/main/resources/application-local.yaml
@@ -70,10 +70,10 @@
  # Redis é…ç½®ã€‚Redisson é»˜è®¤çš„配置足够使用,一般不需要进行调优
  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 # å¯†ç ï¼Œå»ºè®®ç”Ÿäº§çŽ¯å¢ƒå¼€å¯
--- #################### å®šæ—¶ä»»åŠ¡ç›¸å…³é…ç½® ####################
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>