From acf463cd48ba5e1af5ffdf555e7328476b3d4a7d Mon Sep 17 00:00:00 2001 From: liu Date: Mon, 23 Oct 2023 15:40:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- virtual-patient-common/pom.xml | 4 +++- virtual-patient-web/pom.xml | 17 +++++++++++++++++ .../supervision/controller/AskController.java | 18 +++++++++++++----- .../websocket/config/WebSocketConfig.java | 3 +-- .../src/main/resources/application.yml | 2 ++ 5 files changed, 36 insertions(+), 8 deletions(-) diff --git a/virtual-patient-common/pom.xml b/virtual-patient-common/pom.xml index b9b4926b..ca7bf0c8 100644 --- a/virtual-patient-common/pom.xml +++ b/virtual-patient-common/pom.xml @@ -55,10 +55,12 @@ com.github.xiaoymin knife4j-spring-boot-starter - 2.0.9 + 3.0.3 + + \ No newline at end of file diff --git a/virtual-patient-web/pom.xml b/virtual-patient-web/pom.xml index 7a3a3b07..c6b9d5d9 100644 --- a/virtual-patient-web/pom.xml +++ b/virtual-patient-web/pom.xml @@ -37,4 +37,21 @@ + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.projectlombok + lombok + + + + + + diff --git a/virtual-patient-web/src/main/java/com/supervision/controller/AskController.java b/virtual-patient-web/src/main/java/com/supervision/controller/AskController.java index 1489cb54..1d2b896e 100644 --- a/virtual-patient-web/src/main/java/com/supervision/controller/AskController.java +++ b/virtual-patient-web/src/main/java/com/supervision/controller/AskController.java @@ -2,13 +2,14 @@ package com.supervision.controller; import com.supervision.websocket.cache.WebSocketUserCache; import io.swagger.annotations.Api; -import org.springframework.messaging.simp.SimpMessagingTemplate; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; import org.springframework.web.socket.TextMessage; import org.springframework.web.socket.WebSocketSession; -import javax.annotation.Resource; import java.io.IOException; @Api(tags = "问诊") @@ -16,11 +17,18 @@ import java.io.IOException; @RequestMapping("/ask/") public class AskController { - @RequestMapping("/send") - public void sendMessage(String message,String id) throws IOException { - WebSocketSession session = WebSocketUserCache.getSession(id); + @GetMapping("/sendMessage") + public void sendMessage(String message, String sessionId) throws IOException { + WebSocketSession session = WebSocketUserCache.getSession(sessionId); session.sendMessage(new TextMessage(message)); } + @PostMapping("/receiveVoiceFile") + public void receiveVoiceFile(MultipartFile file){ + long size = file.getSize(); + System.out.println(size); + + } + } diff --git a/virtual-patient-web/src/main/java/com/supervision/websocket/config/WebSocketConfig.java b/virtual-patient-web/src/main/java/com/supervision/websocket/config/WebSocketConfig.java index eee31bf9..f923b623 100644 --- a/virtual-patient-web/src/main/java/com/supervision/websocket/config/WebSocketConfig.java +++ b/virtual-patient-web/src/main/java/com/supervision/websocket/config/WebSocketConfig.java @@ -4,7 +4,6 @@ import com.supervision.websocket.handler.AskWebSocketHandler; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.socket.WebSocketHandler; -import org.springframework.web.socket.config.annotation.EnableWebSocket; import org.springframework.web.socket.config.annotation.WebSocketConfigurer; import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry; @@ -13,7 +12,7 @@ public class WebSocketConfig implements WebSocketConfigurer { @Override public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { - registry.addHandler(askWebSocketHandler(), "/websocket") + registry.addHandler(askWebSocketHandler(), "/askSocket") .setAllowedOrigins("*"); } diff --git a/virtual-patient-web/src/main/resources/application.yml b/virtual-patient-web/src/main/resources/application.yml index 7bc70714..fa6d2cf9 100644 --- a/virtual-patient-web/src/main/resources/application.yml +++ b/virtual-patient-web/src/main/resources/application.yml @@ -1,6 +1,8 @@ #服务器端口 server: port: 8899 + servlet: + context-path: / spring: profiles: