refactor(module-llm):优化 DatasetController 中的文件下载逻辑
- 更新导入语句,增加必要的异常处理 - 修改 downloadExampleFile 方法,优化代码格式 - 调整 getFileInfo 方法,统一代码风格
This commit is contained in:
parent
d4f84a5c6b
commit
479c4f56a2
@ -23,7 +23,9 @@ import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.*;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.List;
|
||||
|
||||
@ -102,7 +104,7 @@ public class DatasetController {
|
||||
|
||||
@GetMapping("/download-example")
|
||||
@Operation(summary = "下载示例文件")
|
||||
public ResponseEntity<InputStreamResource> downloadExampleFile(@RequestParam("type") int type, HttpServletResponse response) throws IOException {
|
||||
public ResponseEntity<InputStreamResource> downloadExampleFile (@RequestParam("type") int type, HttpServletResponse response) throws IOException {
|
||||
FileInfoVO fileInfo = getFileInfo(type);
|
||||
|
||||
// 从 resources/file/dataset_example 目录加载文件
|
||||
@ -121,7 +123,7 @@ public class DatasetController {
|
||||
.body(new InputStreamResource(inputStream));
|
||||
}
|
||||
|
||||
private FileInfoVO getFileInfo(int type) {
|
||||
private FileInfoVO getFileInfo (int type) {
|
||||
switch (type) {
|
||||
case 1:
|
||||
return new FileInfoVO("dataset_example_txt.txt", "text/plain");
|
||||
|
Loading…
x
Reference in New Issue
Block a user