diff --git a/community-8073/src/main/resources/application-dep.properties b/community-8073/src/main/resources/application-dep.properties index 56e2304..ba52002 100644 --- a/community-8073/src/main/resources/application-dep.properties +++ b/community-8073/src/main/resources/application-dep.properties @@ -1,9 +1,10 @@ wx.miniapp.configs[0].appid=wx0d4fdb5c7bf3b12b wx.miniapp.configs[0].secret=989f155fcc3aee616568473faf1b1d3b -spring.data.redis.host=127.0.0.1 +spring.data.redis.host=redis spring.data.redis.port=6379 spring.data.redis.database=0 +spring.data.redis.password=Shuodedaoli114514 spring.application.name=community @@ -13,13 +14,27 @@ server.port=8073 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.username=root spring.datasource.password=123456 -spring.datasource.url=jdbc:mysql://127.0.0.1:3306/tutorial?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai +spring.datasource.url=jdbc:mysql://mysql:3306/tutorial?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true -spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848 +spring.cloud.nacos.discovery.server-addr=nacos:8848 spring.cloud.nacos.discovery.enabled=true management.zipkin.tracing.endpoint=http://127.0.0.1:9411/api/v2/spans management.tracing.sampling.probability=1.0 +dubbo.application.qos-enable=false + +mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl + +minio.endpoint=120.26.243.81 +minio.port=9000 +minio.accessKey=minio_root +minio.secretKey=minio_123456 +minio.bucketName=haixia + +spring.data.redis.lettuce.pool.max-active=32 +spring.data.redis.lettuce.pool.max-idle=16 +spring.data.redis.lettuce.pool.min-idle=8 + diff --git a/navigate-8432/pom.xml b/navigate-8432/pom.xml index 12f507a..d87b9f9 100644 --- a/navigate-8432/pom.xml +++ b/navigate-8432/pom.xml @@ -38,7 +38,7 @@ com.mysql mysql-connector-j - runtime + 8.2.0 org.projectlombok @@ -134,6 +134,26 @@ 1.9.1 runtime - + + + + + org.springframework.boot + spring-boot-maven-plugin + 3.0.13 + + com.ivmiku.tutorial.Main8432 + JAR + + + + + repackage + + + + + + \ No newline at end of file diff --git a/navigate-8432/src/main/java/com/ivmiku/tutorial/controller/AssistantController.java b/navigate-8432/src/main/java/com/ivmiku/tutorial/controller/AssistantController.java index 8cd9a8d..0b13380 100644 --- a/navigate-8432/src/main/java/com/ivmiku/tutorial/controller/AssistantController.java +++ b/navigate-8432/src/main/java/com/ivmiku/tutorial/controller/AssistantController.java @@ -1,12 +1,15 @@ package com.ivmiku.tutorial.controller; import cn.dev33.satoken.annotation.SaCheckLogin; +import com.ivmiku.tutorial.entity.AssistantQuery; import com.ivmiku.tutorial.response.Result; import com.ivmiku.tutorial.service.AssistantService; import jakarta.annotation.Resource; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; -import java.util.HashMap; import java.util.Map; @RestController @@ -16,10 +19,10 @@ public class AssistantController { @Resource private AssistantService assistantService; - @GetMapping("/response") - public Object getResponse(@RequestParam String input, @RequestParam int size, @RequestParam String language) { - String userInput = assistantService.speechRecognition(input, size, language); - Map map = assistantService.getResponse(userInput, language); + @PostMapping("/response") + public Object getResponse(@RequestBody AssistantQuery query) { + String userInput = assistantService.speechRecognition(query.getContent(), query.getSize(), query.getLanguage()); + Map map = assistantService.getResponse(userInput, query.getLanguage()); if (map == null) { return Result.error("请求出错"); } diff --git a/navigate-8432/src/main/java/com/ivmiku/tutorial/entity/AssistantQuery.java b/navigate-8432/src/main/java/com/ivmiku/tutorial/entity/AssistantQuery.java new file mode 100644 index 0000000..b5fed03 --- /dev/null +++ b/navigate-8432/src/main/java/com/ivmiku/tutorial/entity/AssistantQuery.java @@ -0,0 +1,10 @@ +package com.ivmiku.tutorial.entity; + +import lombok.Data; + +@Data +public class AssistantQuery { + private String content; + private Integer size; + private String language; +} diff --git a/navigate-8432/src/main/java/com/ivmiku/tutorial/service/AssistantService.java b/navigate-8432/src/main/java/com/ivmiku/tutorial/service/AssistantService.java index da0e312..22b486b 100644 --- a/navigate-8432/src/main/java/com/ivmiku/tutorial/service/AssistantService.java +++ b/navigate-8432/src/main/java/com/ivmiku/tutorial/service/AssistantService.java @@ -65,10 +65,11 @@ public class AssistantService { } JSONArray choices = result.getJSONArray("choices"); JSONObject message = choices.getJSONObject(0); - return message.getString("message"); + JSONObject content = message.getJSONObject("message"); + return content.getString("content"); } - public String textToSpeech(String content) { + public String textToSpeech(String content, String language) { try{ Credential cred = new Credential(secretId, secretKey); HttpProfile httpProfile = new HttpProfile(); @@ -80,6 +81,9 @@ public class AssistantService { req.setText(content); req.setSessionId(SnowflakeUtil.getNext()); req.setVoiceType(101006L); + if (language.equals("English")) { + req.setPrimaryLanguage(2L); + } TextToVoiceResponse resp = client.TextToVoice(req); return resp.getAudio(); } catch (TencentCloudSDKException e) { @@ -159,7 +163,7 @@ public class AssistantService { content = getAiResponse(query, language); } Map map = new HashMap<>(); - map.put("content", textToSpeech(content)); + map.put("content", textToSpeech(content, language)); return map; } } diff --git a/navigate-8432/src/main/java/com/ivmiku/tutorial/service/NavigateService.java b/navigate-8432/src/main/java/com/ivmiku/tutorial/service/NavigateService.java index 57cad45..10575e5 100644 --- a/navigate-8432/src/main/java/com/ivmiku/tutorial/service/NavigateService.java +++ b/navigate-8432/src/main/java/com/ivmiku/tutorial/service/NavigateService.java @@ -53,7 +53,7 @@ public class NavigateService { } public Map scanTicket(BufferedImage image) { - String base64Img = ImgUtil.toBase64(image, "jpg"); + String base64Img = ImgUtil.toBase64(image, "png"); SmartStructuralOCRV2Response resp; try { Credential cred = new Credential(secretId, secretKey); diff --git a/navigate-8432/src/main/resources/application-dep.properties b/navigate-8432/src/main/resources/application-dep.properties index 79803be..fd1d10a 100644 --- a/navigate-8432/src/main/resources/application-dep.properties +++ b/navigate-8432/src/main/resources/application-dep.properties @@ -10,7 +10,7 @@ server.port=8432 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.username=root spring.datasource.password=Shuodedaoli114514 -spring.datasource.url=jdbc:mysql://mysql:4514/tutorial?useUnicode=true&characterEncoding=utf8&useSSL=false&ServerTimezone=Asia/Shanghai +spring.datasource.url=jdbc:mysql://mysql:3306/tutorial?useUnicode=true&characterEncoding=utf8&useSSL=false&ServerTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true spring.cloud.nacos.discovery.server-addr=nacos:8848 spring.cloud.nacos.discovery.enabled=true \ No newline at end of file diff --git a/user-8072/pom.xml b/user-8072/pom.xml index 65a641f..535c4a9 100644 --- a/user-8072/pom.xml +++ b/user-8072/pom.xml @@ -65,16 +65,6 @@ org.apache.commons commons-pool2 - - - org.apache.dubbo - dubbo-spring-boot-starter - - - - org.apache.dubbo - dubbo-registry-nacos - org.springframework.cloud spring-cloud-starter-loadbalancer diff --git a/user-8072/src/main/resources/application-dep.properties b/user-8072/src/main/resources/application-dep.properties index 1e528a4..4e8c98b 100644 --- a/user-8072/src/main/resources/application-dep.properties +++ b/user-8072/src/main/resources/application-dep.properties @@ -12,8 +12,8 @@ server.port=8072 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.username=root -spring.datasource.password=123456 -spring.datasource.url=jdbc:mysql://mysql:3306/tutorial?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai +spring.datasource.password=Shuodedaoli114514 +spring.datasource.url=jdbc:mysql://mysql:3306/tutorial?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true spring.cloud.nacos.discovery.server-addr=nacos:8848 spring.cloud.nacos.discovery.enabled=true diff --git a/user-8072/src/main/resources/application.properties b/user-8072/src/main/resources/application.properties index 257b306..0896b37 100644 --- a/user-8072/src/main/resources/application.properties +++ b/user-8072/src/main/resources/application.properties @@ -1 +1 @@ -spring.profiles.active=dev \ No newline at end of file +spring.profiles.active=dep \ No newline at end of file