浏览代码

Ai语音识别(文件上传)解决URL硬编码

panzhilin 4 天之前
父节点
当前提交
e7e28eb8f3

+ 6 - 1
alien-store/src/main/java/shop/alien/store/controller/AiUploadController.java

@@ -11,6 +11,7 @@ import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.CrossOrigin;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
 import shop.alien.entity.result.R;
@@ -28,7 +29,11 @@ public class AiUploadController {
     @ApiOperation("AI语音识别")
     @ApiOperationSupport(order = 1)
     @PostMapping("/GetAIUpload")
-    public R<JSONObject> getAiUpload(MultipartFile file, String language, String use_itn, String merge_vad ) {
+    public R<JSONObject> getAiUpload(
+            @RequestParam("file") MultipartFile file,
+            @RequestParam(value = "language", required = false) String language,
+            @RequestParam(value = "use_itn", required = false) String use_itn,
+            @RequestParam(value = "merge_vad", required = false) String merge_vad) {
         // 检查文件是否为空
         if (file == null || file.isEmpty()) {
             return R.fail("音频文件不能为空");

+ 4 - 4
alien-store/src/main/java/shop/alien/store/util/ai/AiFeedbackAssignUtils.java

@@ -31,10 +31,10 @@ public class AiFeedbackAssignUtils {
     @Value("${ai.service.login-url}")
     private String loginUrl;
 
-    @Value("${ai.service.username:UdUser}")
+    @Value("${ai.aiAccount}")
     private String userName;
 
-    @Value("${ai.service.password:123456}")
+    @Value("${ai.aiPassword}")
     private String passWord;
 
     @Value("${ai.service.assign-staff-url}")
@@ -153,8 +153,8 @@ public class AiFeedbackAssignUtils {
     public String getAccessToken() {
         log.info("登录AI服务获取token...{}", loginUrl);
         MultiValueMap<String, String> formData = new LinkedMultiValueMap<>();
-        formData.add("username","admin");
-        formData.add("password", "123456");
+        formData.add("username", userName);
+        formData.add("password", passWord);
 
         HttpHeaders headers = new HttpHeaders();
         headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);