|
@@ -102,55 +102,62 @@ public class SceneController {
|
|
|
|
|
|
|
|
|
|
|
|
- @ApiOperation(value = "上传到指定场景码目录", notes = "时间戳命名")
|
|
|
+ @ApiOperation(value = "上传到指定场景码目录", notes = "热点-时间戳命名")
|
|
|
@PostMapping(value = "upload/{sceneCode}", consumes = {"multipart/form-data"})
|
|
|
- public Result upload(MultipartFile file , @PathVariable String sceneCode) throws IOException {
|
|
|
-
|
|
|
- if (file == null) {
|
|
|
- log.error("文件不能为空");
|
|
|
- return Result.failure("文件不能为空");
|
|
|
- }
|
|
|
-
|
|
|
- SceneEntity entity = sceneService.findBySceneCode(sceneCode);
|
|
|
- if (entity == null) {
|
|
|
- log.error("场景不存在: {}", sceneCode);
|
|
|
- return Result.failure("场景不存在");
|
|
|
- }
|
|
|
-
|
|
|
- String fileName = file.getOriginalFilename();
|
|
|
- log.info("原始文件名: {}", fileName);
|
|
|
-// String time = DateUtil.format(LocalDateTime.now(), "yyyyMMdd_HHmmssSSS");
|
|
|
-// String suffix = StringUtils.substringAfterLast(fileName, ".");
|
|
|
-// suffix = StringUtils.lowerCase(suffix);
|
|
|
-
|
|
|
-// String newName = time + "." +suffix;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- // 去除特殊符号
|
|
|
- String pinyinName = RegexUtil.specificSymbol(fileName);
|
|
|
- pinyinName = PinyinUtil.getPinyin(pinyinName, "");
|
|
|
-
|
|
|
- // 转小写
|
|
|
- pinyinName = StringUtils.lowerCase(pinyinName);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- String basePath = configConstant.serverBasePath + sceneCode;
|
|
|
- String savePath = basePath + "/edit/" + pinyinName;
|
|
|
- log.info("文件保存位置:" + savePath);
|
|
|
- FileUtil.writeFromStream(file.getInputStream(), savePath);
|
|
|
-
|
|
|
-
|
|
|
- Object urlPath = entity.getPath() + "/edit/" + pinyinName;
|
|
|
-
|
|
|
- log.info("文件写入成功: {}", urlPath);
|
|
|
+ public Result upload(MultipartFile file , @PathVariable String sceneCode) {
|
|
|
+ return sceneService.upload(file, sceneCode);
|
|
|
+ }
|
|
|
|
|
|
- // 返回前端数据
|
|
|
- return Result.success(urlPath);
|
|
|
|
|
|
- }
|
|
|
+// @ApiOperation(value = "上传到指定场景码目录", notes = "时间戳命名")
|
|
|
+// @PostMapping(value = "upload/{sceneCode}", consumes = {"multipart/form-data"})
|
|
|
+// public Result upload(MultipartFile file , @PathVariable String sceneCode) throws IOException {
|
|
|
+//
|
|
|
+// if (file == null) {
|
|
|
+// log.error("文件不能为空");
|
|
|
+// return Result.failure("文件不能为空");
|
|
|
+// }
|
|
|
+//
|
|
|
+// SceneEntity entity = sceneService.findBySceneCode(sceneCode);
|
|
|
+// if (entity == null) {
|
|
|
+// log.error("场景不存在: {}", sceneCode);
|
|
|
+// return Result.failure("场景不存在");
|
|
|
+// }
|
|
|
+//
|
|
|
+// String fileName = file.getOriginalFilename();
|
|
|
+// log.info("原始文件名: {}", fileName);
|
|
|
+//// String time = DateUtil.format(LocalDateTime.now(), "yyyyMMdd_HHmmssSSS");
|
|
|
+//// String suffix = StringUtils.substringAfterLast(fileName, ".");
|
|
|
+//// suffix = StringUtils.lowerCase(suffix);
|
|
|
+//
|
|
|
+//// String newName = time + "." +suffix;
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+// // 去除特殊符号
|
|
|
+// String pinyinName = RegexUtil.specificSymbol(fileName);
|
|
|
+// pinyinName = PinyinUtil.getPinyin(pinyinName, "");
|
|
|
+//
|
|
|
+// // 转小写
|
|
|
+// pinyinName = StringUtils.lowerCase(pinyinName);
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+// String basePath = configConstant.serverBasePath + sceneCode;
|
|
|
+// String savePath = basePath + "/edit/" + pinyinName;
|
|
|
+// log.info("文件保存位置:" + savePath);
|
|
|
+// FileUtil.writeFromStream(file.getInputStream(), savePath);
|
|
|
+//
|
|
|
+//
|
|
|
+// Object urlPath = entity.getPath() + "/edit/" + pinyinName;
|
|
|
+//
|
|
|
+// log.info("文件写入成功: {}", urlPath);
|
|
|
+//
|
|
|
+// // 返回前端数据
|
|
|
+// return Result.success(urlPath);
|
|
|
+//
|
|
|
+// }
|
|
|
|
|
|
|
|
|
}
|