|
@@ -7,7 +7,7 @@ import com.fdkankan.common.exception.BusinessException;
|
|
|
import com.fdkankan.common.user.SSOLoginHelper;
|
|
|
import com.fdkankan.common.util.BASE64DecodedMultipartFile;
|
|
|
import com.fdkankan.common.util.FileUtil;
|
|
|
-import com.fdkankan.fyun.oss.OssFilePath;
|
|
|
+import com.fdkankan.fyun.oss.UploadFilePath;
|
|
|
import com.fdkankan.fyun.oss.UploadToOssUtil;
|
|
|
import com.fdkankan.scene.entity.SceneUpload;
|
|
|
import com.fdkankan.scene.mapper.ISceneUploadMapper;
|
|
@@ -54,7 +54,7 @@ public class SceneUploadServiceImpl extends ServiceImpl<ISceneUploadMapper, Scen
|
|
|
private SSOLoginHelper ssoLoginHelper;
|
|
|
|
|
|
@Override
|
|
|
- public List<String> uploads(String imgData,MultipartFile[] files,String sceneCode,Integer type) throws Exception{
|
|
|
+ public String uploads(String imgData,String fileName,MultipartFile[] files,String sceneCode,Integer type) throws Exception{
|
|
|
List<MultipartFile> multipartFiles = new ArrayList<>();
|
|
|
if(StringUtils.isNotBlank(imgData)){
|
|
|
MultipartFile file = BASE64DecodedMultipartFile.base64ToMultipart(imgData);
|
|
@@ -63,10 +63,10 @@ public class SceneUploadServiceImpl extends ServiceImpl<ISceneUploadMapper, Scen
|
|
|
if(files !=null && files.length >0){
|
|
|
multipartFiles.addAll(Arrays.asList(files));
|
|
|
}
|
|
|
- return this.uploadFiles(multipartFiles,sceneCode,type);
|
|
|
+ return this.uploadFiles(fileName,multipartFiles,sceneCode,type);
|
|
|
}
|
|
|
|
|
|
- public List<String> uploadFiles(List<MultipartFile> files, String sceneCode, Integer type) throws Exception{
|
|
|
+ public String uploadFiles(String sendFileName,List<MultipartFile> files, String sceneCode, Integer type) throws Exception{
|
|
|
if (StringUtils.isEmpty(sceneCode) || files == null || files.size() <= 0) {
|
|
|
throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
}
|
|
@@ -89,21 +89,32 @@ public class SceneUploadServiceImpl extends ServiceImpl<ISceneUploadMapper, Scen
|
|
|
prefix = fileName.substring(fileName.lastIndexOf("."));
|
|
|
File newFile = File.createTempFile(UUID.randomUUID().toString() ,prefix);
|
|
|
file.transferTo(newFile);
|
|
|
- String ossPath = String.format(OssFilePath.USER_EDIT_PATH ,sceneCode) + fileName;
|
|
|
+ String realFileName = fileName;
|
|
|
+ if(files.size() ==1 && StringUtils.isNotBlank(sendFileName)){
|
|
|
+ realFileName = sendFileName ;
|
|
|
+ }
|
|
|
+ String ossPath = String.format(UploadFilePath.USER_EDIT_PATH ,sceneCode) + realFileName;
|
|
|
try {
|
|
|
uploadToOssUtil.upload2(newFile.getPath(),ossPath);
|
|
|
}catch (Exception e){
|
|
|
log.error(ossPath+"上传文件失败"+e);
|
|
|
throw new BusinessException(-1,"上传文件失败");
|
|
|
}
|
|
|
- String url =String.format("http://%s.%s/%s", bucket, point.replace("http://",""), ossPath);
|
|
|
- urlList.add(url);
|
|
|
+ //String url =String.format("http://%s.%s/%s", bucket, point.replace("http://",""), ossPath);
|
|
|
+ urlList.add(realFileName);
|
|
|
|
|
|
FileUtil.delFile(newFile.getPath());
|
|
|
//添加记录
|
|
|
this.saveData(sceneCode,ossPath,prefix);
|
|
|
}
|
|
|
- return urlList;
|
|
|
+ StringBuilder returnString = new StringBuilder();
|
|
|
+ for (String res : urlList) {
|
|
|
+ if(StringUtils.isNotBlank(returnString)){
|
|
|
+ returnString.append(",");
|
|
|
+ }
|
|
|
+ returnString.append(res);
|
|
|
+ }
|
|
|
+ return returnString.toString();
|
|
|
}
|
|
|
|
|
|
private void updateFileByPreFix(String sceneCode, String prefix) {
|