|
@@ -28,6 +28,7 @@ import com.fdkankan.fyun.oss.UploadToOssUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.tools.zip.ZipFile;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
@@ -48,9 +49,13 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
|
|
|
ICaseNumService caseNumService;
|
|
|
@Autowired
|
|
|
IFusionNumService fusionNumService;
|
|
|
+ @Value("${local.obj_path}")
|
|
|
+ private String OBJ_PATH;
|
|
|
+ @Value("${local.glb_path}")
|
|
|
+ private String GLB_PATH;
|
|
|
|
|
|
@Override
|
|
|
- public void uploadObj(MultipartFile file, String username) {
|
|
|
+ public void uploadObj(MultipartFile file, String username) throws Exception {
|
|
|
if(file.isEmpty()){
|
|
|
throw new BusinessException(ResultCode.UPLOAD_FILE_NO_EXIST);
|
|
|
}
|
|
@@ -63,7 +68,7 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
|
|
|
if(StringUtils.isEmpty(fileName)){
|
|
|
throw new BusinessException(ResultCode.UPLOAD_FILE_NO_EXIST);
|
|
|
}
|
|
|
- if(fileName.toLowerCase().contains("zip") || fileName.toLowerCase().contains("rar")){
|
|
|
+ if(!fileName.toLowerCase().contains("zip") && !fileName.toLowerCase().contains("rar")){
|
|
|
throw new BusinessException(ResultCode.UPLOAD_FILE_TYPE_ERROR);
|
|
|
}
|
|
|
//获取文件后缀名
|
|
@@ -75,10 +80,9 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
|
|
|
model.setModelSize(file.getSize());
|
|
|
model.setUserName(username);
|
|
|
this.save(model);
|
|
|
- Integer createStatus = -1;
|
|
|
try {
|
|
|
- String objPath = FilePath.OBJ_PATH +"/" + model.getModelId();
|
|
|
- String glbPath = FilePath.GLB_PATH +"/" + model.getModelId();
|
|
|
+ String objPath = String.format(OBJ_PATH , "modelId_"+model.getModelId());
|
|
|
+ String glbPath = String.format(GLB_PATH , "modelId_"+model.getModelId());
|
|
|
String glbOssPath = FilePath.GLB_OSS_PATH +"/" + model.getModelId();
|
|
|
model.setModelObjUrl(objPath);
|
|
|
model.setModelGlbUrl(glbPath);
|
|
@@ -97,13 +101,16 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
|
|
|
|
|
|
OBJToGLBUtil.objToGlb(objPath,glbPath);
|
|
|
uploadToOssUtil.upload(glbPath,glbOssPath);
|
|
|
- createStatus = 1; //上传成功
|
|
|
+
|
|
|
+ model.setCreateStatus(1); //上传成功
|
|
|
+ this.updateById(model);
|
|
|
}catch (Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- }finally {
|
|
|
- model.setCreateStatus(createStatus);
|
|
|
+ model.setCreateStatus(-1);
|
|
|
this.updateById(model);
|
|
|
+ e.printStackTrace();
|
|
|
+ throw e;
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|