|
@@ -23,6 +23,8 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.io.File;
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -44,7 +46,7 @@ public class SceneServiceImpl extends ServiceImpl<SceneMapper, Scene> implements
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public ResultData saveScene(SceneDto sceneDto) {
|
|
|
|
|
|
+ public ResultData saveScene(SceneDto sceneDto) throws UnsupportedEncodingException {
|
|
String num = sceneDto.getNum();
|
|
String num = sceneDto.getNum();
|
|
Scene scene = null;
|
|
Scene scene = null;
|
|
if(StrUtil.isNotEmpty(num)){
|
|
if(StrUtil.isNotEmpty(num)){
|
|
@@ -55,10 +57,12 @@ public class SceneServiceImpl extends ServiceImpl<SceneMapper, Scene> implements
|
|
}
|
|
}
|
|
scene.setTitle(sceneDto.getTitle());
|
|
scene.setTitle(sceneDto.getTitle());
|
|
|
|
|
|
- String paramPath = String.format(paramDir, num).concat("param.txt");
|
|
|
|
|
|
+ String paramPath = ossDir.concat(num).concat("/").concat("param.txt");
|
|
scene.setParamPath(paramPath);
|
|
scene.setParamPath(paramPath);
|
|
- FileUtil.mkParentDirs(paramPath);
|
|
|
|
- FileUtil.writeUtf8String(sceneDto.getParam().toJSONString(), paramPath);
|
|
|
|
|
|
+// FileUtil.mkParentDirs(paramPath);
|
|
|
|
+// FileUtil.writeUtf8String(sceneDto.getParam().toJSONString(), paramPath);
|
|
|
|
+
|
|
|
|
+ fileStorageTemplate.uploadFileBytes(paramPath,sceneDto.getParam().toJSONString().getBytes(StandardCharsets.UTF_8.name()));
|
|
|
|
|
|
this.saveOrUpdate(scene);
|
|
this.saveOrUpdate(scene);
|
|
|
|
|
|
@@ -71,12 +75,13 @@ public class SceneServiceImpl extends ServiceImpl<SceneMapper, Scene> implements
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public SceneDetailVo getDetail(String num) {
|
|
|
|
|
|
+ public SceneDetailVo getDetail(String num) throws IOException {
|
|
Scene scene = this.getByNum(num);
|
|
Scene scene = this.getByNum(num);
|
|
if(Objects.isNull(scene)){
|
|
if(Objects.isNull(scene)){
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
}
|
|
}
|
|
- String paramStr = FileUtil.readUtf8String(scene.getParamPath());
|
|
|
|
|
|
+// String paramStr = FileUtil.readUtf8String(scene.getParamPath());
|
|
|
|
+ String paramStr = fileStorageTemplate.getFileContent(scene.getParamPath());
|
|
return SceneDetailVo.builder().num(scene.getNum()).title(scene.getTitle()).createTime(scene.getCreateTime()).param(JSON.parseObject(paramStr)).build();
|
|
return SceneDetailVo.builder().num(scene.getNum()).title(scene.getTitle()).createTime(scene.getCreateTime()).param(JSON.parseObject(paramStr)).build();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -84,7 +89,7 @@ public class SceneServiceImpl extends ServiceImpl<SceneMapper, Scene> implements
|
|
public String uploadFile(MultipartFile file, String num) throws IOException {
|
|
public String uploadFile(MultipartFile file, String num) throws IOException {
|
|
|
|
|
|
String originalFilename = file.getOriginalFilename();
|
|
String originalFilename = file.getOriginalFilename();
|
|
- String key = ossDir.concat(num).concat(File.separator).concat(originalFilename);
|
|
|
|
|
|
+ String key = ossDir.concat(num).concat("/").concat(originalFilename);
|
|
String url = fileStorageTemplate.uploadFileStream(key, file.getInputStream());
|
|
String url = fileStorageTemplate.uploadFileStream(key, file.getInputStream());
|
|
|
|
|
|
return url;
|
|
return url;
|