BUGFIX:library upload;
This commit is contained in:
@@ -174,26 +174,37 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
|||||||
throw new BusinessException("unknown level1_type");
|
throw new BusinessException("unknown level1_type");
|
||||||
}
|
}
|
||||||
//保存element元素
|
//保存element元素
|
||||||
if (libraryUploadDTO.getModelType().equals(ModelType.LIBRARY.getValue())) {
|
if (libraryUploadDTO.getModelType() != null) {
|
||||||
|
if (libraryUploadDTO.getModelType().equals(ModelType.LIBRARY.getValue())) {
|
||||||
|
String filePath = minioUtil.upload(bucketName, path, libraryUploadDTO.getFile());
|
||||||
|
String newFilePath = processMannequins(filePath);
|
||||||
|
Library library = resolveData(libraryUploadDTO, userInfo, newFilePath);
|
||||||
|
LibraryUpdateVo libraryUpdateVo = CopyUtil.copyObject(library, LibraryUpdateVo.class);
|
||||||
|
libraryUpdateVo.setMinIOPath(libraryUpdateVo.getUrl());
|
||||||
|
libraryUpdateVo.setUrl(minioUtil.getPresignedUrl(newFilePath, 480));
|
||||||
|
return libraryUpdateVo;
|
||||||
|
}else if (libraryUploadDTO.getModelType().equals(ModelType.SYSTEM.getValue())) {
|
||||||
|
bucketName = "aida-sys-image";
|
||||||
|
path = "models/" + libraryUploadDTO.getModelSex();
|
||||||
|
String filePath = minioUtil.upload(bucketName, path, libraryUploadDTO.getFile());
|
||||||
|
String newFilePath = processMannequins(filePath);
|
||||||
|
Library library = resolveData(libraryUploadDTO, userInfo, newFilePath);
|
||||||
|
LibraryUpdateVo libraryUpdateVo = CopyUtil.copyObject(library, LibraryUpdateVo.class);
|
||||||
|
libraryUpdateVo.setMinIOPath(libraryUpdateVo.getUrl());
|
||||||
|
libraryUpdateVo.setUrl(minioUtil.getPresignedUrl(newFilePath, 480));
|
||||||
|
return libraryUpdateVo;
|
||||||
|
}else {
|
||||||
|
throw new BusinessException("unknown modelType");
|
||||||
|
}
|
||||||
|
}else {
|
||||||
String filePath = minioUtil.upload(bucketName, path, libraryUploadDTO.getFile());
|
String filePath = minioUtil.upload(bucketName, path, libraryUploadDTO.getFile());
|
||||||
String newFilePath = bucketName + "/" + processMannequins(filePath);
|
//保存element元素
|
||||||
Library library = resolveData(libraryUploadDTO, userInfo, newFilePath);
|
Library library = resolveData(libraryUploadDTO, userInfo, filePath);
|
||||||
LibraryUpdateVo libraryUpdateVo = CopyUtil.copyObject(library, LibraryUpdateVo.class);
|
LibraryUpdateVo libraryUpdateVo = CopyUtil.copyObject(library, LibraryUpdateVo.class);
|
||||||
libraryUpdateVo.setMinIOPath(libraryUpdateVo.getUrl());
|
libraryUpdateVo.setMinIOPath(libraryUpdateVo.getUrl());
|
||||||
libraryUpdateVo.setUrl(minioUtil.getPresignedUrl(newFilePath, 480));
|
libraryUpdateVo.setUrl(minioUtil.getPresignedUrl(libraryUpdateVo.getUrl(), 480));
|
||||||
return libraryUpdateVo;
|
|
||||||
}else if (libraryUploadDTO.getModelType().equals(ModelType.SYSTEM.getValue())) {
|
|
||||||
bucketName = "aida-sys-image";
|
|
||||||
path = "models/" + libraryUploadDTO.getModelSex();
|
|
||||||
String filePath = minioUtil.upload(bucketName, path, libraryUploadDTO.getFile());
|
|
||||||
String newFilePath = bucketName + "/" + processMannequins(filePath);
|
|
||||||
Library library = resolveData(libraryUploadDTO, userInfo, newFilePath);
|
|
||||||
LibraryUpdateVo libraryUpdateVo = CopyUtil.copyObject(library, LibraryUpdateVo.class);
|
|
||||||
libraryUpdateVo.setMinIOPath(libraryUpdateVo.getUrl());
|
|
||||||
libraryUpdateVo.setUrl(minioUtil.getPresignedUrl(newFilePath, 480));
|
|
||||||
return libraryUpdateVo;
|
return libraryUpdateVo;
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String processMannequins(String filePath) {
|
private String processMannequins(String filePath) {
|
||||||
@@ -244,7 +255,7 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Library resolveData(LibraryUploadDTO uploadDTO, AuthPrincipalVo userInfo, String filePath) {
|
private Library resolveData(LibraryUploadDTO uploadDTO, AuthPrincipalVo userInfo, String filePath) {
|
||||||
if (uploadDTO.getModelType().equals(ModelType.LIBRARY.getValue())) {
|
if (StringUtils.isEmpty(uploadDTO.getModelType()) || uploadDTO.getModelType().equals(ModelType.LIBRARY.getValue())) {
|
||||||
Library library = CopyUtil.copyObject(uploadDTO, Library.class);
|
Library library = CopyUtil.copyObject(uploadDTO, Library.class);
|
||||||
library.setAccountId(userInfo.getId());
|
library.setAccountId(userInfo.getId());
|
||||||
library.setName(DateUtil.dateToStr(new Date(),DateUtil.YYYY_MM_DD));
|
library.setName(DateUtil.dateToStr(new Date(),DateUtil.YYYY_MM_DD));
|
||||||
@@ -275,7 +286,7 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
|||||||
library.setUrl(sysFile.getUrl());
|
library.setUrl(sysFile.getUrl());
|
||||||
return library;
|
return library;
|
||||||
}else {
|
}else {
|
||||||
throw new BusinessException("unknown model type");
|
throw new BusinessException("system error!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user