Skip to content

Commit e33ff8b

Browse files
committed
refactor: 命名优化
1 parent 02e621a commit e33ff8b

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

framework/src/main/java/top/cadecode/uniboot/framework/controller/CommonController.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import top.cadecode.uniboot.common.core.util.AssertUtil;
1616
import top.cadecode.uniboot.framework.annotation.ApiFormat;
1717
import top.cadecode.uniboot.framework.enums.FrameErrorEnum;
18-
import top.cadecode.uniboot.framework.manager.FileUploadManager;
18+
import top.cadecode.uniboot.framework.util.FileUploadUtil;
1919

2020
import javax.servlet.http.HttpServletRequest;
2121
import javax.servlet.http.HttpServletResponse;
@@ -39,10 +39,10 @@ public class CommonController {
3939
@PostMapping("common/upload")
4040
public boolean upload(@RequestPart("file") MultipartFile file) {
4141
String originalFilename = file.getOriginalFilename();
42-
boolean checked = FileUploadManager.checkAllowedExtension(originalFilename);
42+
boolean checked = FileUploadUtil.checkAllowedExtension(originalFilename);
4343
AssertUtil.isFalse(checked, FrameErrorEnum.EXTENSION_NOT_ALLOWED, originalFilename + "不被允许");
44-
String renamedFileName = FileUploadManager.renameByUUID(originalFilename);
45-
String targetFilePath = FileUploadManager.uploadPath() + renamedFileName;
44+
String renamedFileName = FileUploadUtil.renameByUUID(originalFilename);
45+
String targetFilePath = FileUploadUtil.uploadPath() + renamedFileName;
4646
try {
4747
File targetFile = FileUtil.file(targetFilePath);
4848
FileUtil.mkParentDirs(targetFile);
@@ -65,22 +65,22 @@ public int uploadFiles(@RequestPart("files") MultipartFile[] files) {
6565
}
6666

6767
@ApiOperation("下载文件")
68-
@GetMapping(FileUploadManager.DEFAULT_DOWNLOAD_API)
68+
@GetMapping(FileUploadUtil.DEFAULT_DOWNLOAD_API)
6969
public void download(HttpServletRequest request, HttpServletResponse response, String fileName) throws IOException {
70-
boolean checked = FileUploadManager.checkAllowedExtension(fileName);
70+
boolean checked = FileUploadUtil.checkAllowedExtension(fileName);
7171
AssertUtil.isFalse(checked, FrameErrorEnum.EXTENSION_NOT_ALLOWED, fileName + "不被允许");
7272
// 写文件流
73-
String targetFilePath = FileUploadManager.downloadPath() + fileName;
73+
String targetFilePath = FileUploadUtil.downloadPath() + fileName;
7474
boolean exist = FileUtil.exist(targetFilePath);
7575
AssertUtil.isFalse(exist, FrameErrorEnum.FILE_NOT_FOUND, fileName + "不存在");
7676
ServletUtil.write(response, new File(targetFilePath));
7777
}
7878

7979
@ApiOperation("下载临时文件")
80-
@GetMapping(FileUploadManager.DEFAULT_DOWNLOAD_TEMP_API)
80+
@GetMapping(FileUploadUtil.DEFAULT_DOWNLOAD_TEMP_API)
8181
public void downloadTemp(HttpServletRequest request, HttpServletResponse response, String fileName) throws IOException {
8282
download(request, response, fileName);
83-
String targetFilePath = FileUploadManager.downloadPath() + fileName;
83+
String targetFilePath = FileUploadUtil.downloadPath() + fileName;
8484
FileUtil.del(targetFilePath);
8585
}
8686

framework/src/main/java/top/cadecode/uniboot/framework/manager/FileUploadManager.java renamed to framework/src/main/java/top/cadecode/uniboot/framework/util/FileUploadUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package top.cadecode.uniboot.framework.manager;
1+
package top.cadecode.uniboot.framework.util;
22

33
import cn.hutool.core.collection.CollUtil;
44
import cn.hutool.core.io.file.FileNameUtil;
@@ -21,7 +21,7 @@
2121
@Slf4j
2222
@RequiredArgsConstructor
2323
@Component
24-
public class FileUploadManager implements InitializingBean {
24+
public class FileUploadUtil implements InitializingBean {
2525

2626
private final UniBootConfig uniBootConfig;
2727

0 commit comments

Comments
 (0)