2025-09-18 11:40:12 +08:00
|
|
|
|
package com.fuyuanshen.app.controller;
|
|
|
|
|
|
|
2025-10-24 11:22:35 +08:00
|
|
|
|
import com.fuyuanshen.app.service.AudioProcessService;
|
|
|
|
|
|
import com.fuyuanshen.app.service.VideoProcessService;
|
2025-09-18 11:40:12 +08:00
|
|
|
|
import com.fuyuanshen.common.core.domain.R;
|
2025-10-27 09:00:36 +08:00
|
|
|
|
import com.fuyuanshen.common.idempotent.annotation.RepeatSubmit;
|
2025-09-18 11:40:12 +08:00
|
|
|
|
import com.fuyuanshen.common.web.core.BaseController;
|
2025-11-21 16:24:07 +08:00
|
|
|
|
import com.fuyuanshen.equipment.utils.FileHashUtil;
|
2025-09-18 11:40:12 +08:00
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
|
import org.springframework.http.MediaType;
|
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
2025-10-24 11:22:35 +08:00
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
2025-09-18 11:40:12 +08:00
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
2025-10-24 11:22:35 +08:00
|
|
|
|
import java.io.IOException;
|
2025-09-18 11:40:12 +08:00
|
|
|
|
import java.util.List;
|
2025-10-27 09:00:36 +08:00
|
|
|
|
import java.util.concurrent.TimeUnit;
|
2025-09-18 11:40:12 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
2025-10-24 11:22:35 +08:00
|
|
|
|
* APP 视频处理控制器
|
2025-09-18 11:40:12 +08:00
|
|
|
|
*/
|
|
|
|
|
|
@Validated
|
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
|
@RestController
|
|
|
|
|
|
@RequestMapping("/app/video")
|
|
|
|
|
|
public class AppVideoController extends BaseController {
|
|
|
|
|
|
|
2025-10-24 11:22:35 +08:00
|
|
|
|
private final VideoProcessService videoProcessService;
|
|
|
|
|
|
private final AudioProcessService audioProcessService;
|
2025-11-21 16:24:07 +08:00
|
|
|
|
private final FileHashUtil fileHashUtil;
|
|
|
|
|
|
|
2025-09-18 11:40:12 +08:00
|
|
|
|
|
2025-10-24 11:22:35 +08:00
|
|
|
|
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
2025-11-21 16:24:07 +08:00
|
|
|
|
@RepeatSubmit(interval = 2, timeUnit = TimeUnit.SECONDS, message = "请勿重复提交!")
|
|
|
|
|
|
public R<List<String>> uploadVideo(@RequestParam("file") MultipartFile file) throws IOException {
|
|
|
|
|
|
// 输出文件基本信息
|
|
|
|
|
|
System.out.println("FileName: " + file.getOriginalFilename());
|
|
|
|
|
|
System.out.println("FileSize: " + file.getSize());
|
|
|
|
|
|
System.out.println("ContentType: " + file.getContentType());
|
|
|
|
|
|
|
|
|
|
|
|
String fileHash = fileHashUtil.hash(file);
|
|
|
|
|
|
System.out.println("fileHash:" + fileHash);
|
|
|
|
|
|
|
|
|
|
|
|
// 可以添加更多视频属性检查
|
2025-10-24 11:22:35 +08:00
|
|
|
|
return R.ok(videoProcessService.processVideo(file));
|
2025-09-18 11:40:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-21 16:24:07 +08:00
|
|
|
|
|
2025-09-18 11:40:12 +08:00
|
|
|
|
/**
|
2025-10-24 11:22:35 +08:00
|
|
|
|
* 上传音频文件并转码
|
2025-09-18 11:40:12 +08:00
|
|
|
|
*/
|
2025-10-24 11:22:35 +08:00
|
|
|
|
@PostMapping(value = "/audio", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
2025-11-21 16:24:07 +08:00
|
|
|
|
@RepeatSubmit(interval = 2, timeUnit = TimeUnit.SECONDS, message = "请勿重复提交!")
|
2025-10-24 11:22:35 +08:00
|
|
|
|
public R<List<String>> uploadAudio(@RequestParam("file") MultipartFile file) {
|
|
|
|
|
|
return R.ok(audioProcessService.processAudio(file));
|
2025-09-18 11:40:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-10-24 11:22:35 +08:00
|
|
|
|
* 文字转音频TTS服务
|
2025-09-18 11:40:12 +08:00
|
|
|
|
*/
|
2025-10-24 11:22:35 +08:00
|
|
|
|
@GetMapping("/audioTTS")
|
2025-11-21 16:24:07 +08:00
|
|
|
|
@RepeatSubmit(interval = 2, timeUnit = TimeUnit.SECONDS, message = "请勿重复提交!")
|
2025-10-24 11:22:35 +08:00
|
|
|
|
public R<List<String>> uploadAudioTTS(@RequestParam String text) throws IOException {
|
|
|
|
|
|
return R.ok(audioProcessService.generateStandardPcmData(text));
|
2025-09-18 11:40:12 +08:00
|
|
|
|
}
|
2025-11-07 16:59:07 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 提取文本内容(只支持txt/docx)
|
|
|
|
|
|
*/
|
|
|
|
|
|
@PostMapping(value = "/extract", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
2025-11-21 16:24:07 +08:00
|
|
|
|
@RepeatSubmit(interval = 2, timeUnit = TimeUnit.SECONDS, message = "请勿重复提交!")
|
2025-11-07 16:59:07 +08:00
|
|
|
|
public R<String> extract(@RequestParam("file") MultipartFile file) throws Exception {
|
2025-11-21 16:24:07 +08:00
|
|
|
|
return R.ok("Success", audioProcessService.extract(file));
|
2025-11-07 16:59:07 +08:00
|
|
|
|
}
|
2025-11-25 14:51:10 +08:00
|
|
|
|
|
2025-09-18 11:40:12 +08:00
|
|
|
|
}
|