|
@@ -35,71 +35,79 @@ public class AlgorithmServiceImpl implements AlgorithmService {
|
|
|
|
|
|
@Override
|
|
|
public ResponseBodyVO addOrUpdate(AlgorithmParameter param) throws IOException {
|
|
|
- if(isEmpty(param.getId())){
|
|
|
- //添加
|
|
|
- String algorithmId = StringUtil.getRandomUUID();
|
|
|
- String uploadMode = param.getUploadMode();
|
|
|
- if("1".equals(uploadMode)){
|
|
|
- MultipartFile file = param.getFile();
|
|
|
- String fileName = file.getOriginalFilename();
|
|
|
- String linuxPath = "/opt/simulation-cloud/algorithm/" + algorithmId + "/" + fileName;
|
|
|
- String minioPath = "algorithm/" + algorithmId + "/" + fileName;
|
|
|
- boolean uploadSuccess = uploadFile(file, linuxPath, minioPath);
|
|
|
- if(uploadSuccess) {
|
|
|
+
|
|
|
+ String currentUserId = AuthUtil.getCurrentUserId();
|
|
|
+ param.setCreateUserId(currentUserId);
|
|
|
+ List<AlgorithmPO> algorithmPOS = algorithmMapper.selectAlgorithmName(param);
|
|
|
+ if(algorithmPOS != null && algorithmPOS.size() > 0){
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS,"该算法名称已存在!");
|
|
|
+ }else {
|
|
|
+ if(isEmpty(param.getId())){
|
|
|
+ //添加
|
|
|
+
|
|
|
+ String algorithmId = StringUtil.getRandomUUID();
|
|
|
+ String uploadMode = param.getUploadMode();
|
|
|
+ if("1".equals(uploadMode)){
|
|
|
+ MultipartFile file = param.getFile();
|
|
|
+ String fileName = file.getOriginalFilename();
|
|
|
+ String linuxPath = "/opt/simulation-cloud/algorithm/" + algorithmId + "/" + fileName;
|
|
|
+ String minioPath = "algorithm/" + algorithmId + "/" + fileName;
|
|
|
+ boolean uploadSuccess = uploadFile(file, linuxPath, minioPath);
|
|
|
+ if(uploadSuccess) {
|
|
|
+ param.setId(algorithmId);
|
|
|
+ AlgorithmPO po = setPo(param, fileName, linuxPath, minioPath, false);
|
|
|
+ int add = algorithmMapper.add(po);
|
|
|
+ if(add > 0){
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
|
|
|
+ }else {
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"添加失败");
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"添加失败");
|
|
|
+ }
|
|
|
+ }else {
|
|
|
param.setId(algorithmId);
|
|
|
- AlgorithmPO po = setPo(param, fileName, linuxPath, minioPath, false);
|
|
|
+ AlgorithmPO po = setPo(param, "", "", "", false);
|
|
|
int add = algorithmMapper.add(po);
|
|
|
if(add > 0){
|
|
|
return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
|
|
|
}else {
|
|
|
return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"添加失败");
|
|
|
}
|
|
|
- }else {
|
|
|
- return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"添加失败");
|
|
|
}
|
|
|
}else {
|
|
|
- param.setId(algorithmId);
|
|
|
- AlgorithmPO po = setPo(param, "", "", "", false);
|
|
|
- int add = algorithmMapper.add(po);
|
|
|
- if(add > 0){
|
|
|
- return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
|
|
|
+ //编辑
|
|
|
+ String uploadMode = param.getUploadMode();
|
|
|
+ String algorithmId = param.getId();
|
|
|
+ if("1".equals(uploadMode)) {
|
|
|
+ MultipartFile file = param.getFile();
|
|
|
+ String fileName = file.getOriginalFilename();
|
|
|
+ String linuxPath = "/opt/simulation-cloud/algorithm/" + algorithmId + "/" + fileName;
|
|
|
+ String minioPath = "algorithm/" + algorithmId + "/" + fileName;
|
|
|
+
|
|
|
+ boolean uploadSuccess = uploadFile(file, linuxPath, minioPath);
|
|
|
+ if (uploadSuccess) {
|
|
|
+ AlgorithmPO po = setPo(param, fileName, linuxPath, minioPath, true);
|
|
|
+ int add = algorithmMapper.update(po);
|
|
|
+ if (add > 0) {
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
|
|
|
+ }else {
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE, "编辑失败");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE, "编辑失败");
|
|
|
+ }
|
|
|
}else {
|
|
|
- return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"添加失败");
|
|
|
- }
|
|
|
- }
|
|
|
- }else {
|
|
|
- //编辑
|
|
|
- String uploadMode = param.getUploadMode();
|
|
|
- String algorithmId = param.getId();
|
|
|
- if("1".equals(uploadMode)) {
|
|
|
- MultipartFile file = param.getFile();
|
|
|
- String fileName = file.getOriginalFilename();
|
|
|
- String linuxPath = "/opt/simulation-cloud/algorithm/" + algorithmId + "/" + fileName;
|
|
|
- String minioPath = "algorithm/" + algorithmId + "/" + fileName;
|
|
|
-
|
|
|
- boolean uploadSuccess = uploadFile(file, linuxPath, minioPath);
|
|
|
- if (uploadSuccess) {
|
|
|
- AlgorithmPO po = setPo(param, fileName, linuxPath, minioPath, true);
|
|
|
+ AlgorithmPO po = setPo(param, "", "", "", true);
|
|
|
int add = algorithmMapper.update(po);
|
|
|
if (add > 0) {
|
|
|
return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
|
|
|
}else {
|
|
|
return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE, "编辑失败");
|
|
|
}
|
|
|
- } else {
|
|
|
- return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE, "编辑失败");
|
|
|
- }
|
|
|
- }else {
|
|
|
- AlgorithmPO po = setPo(param, "", "", "", true);
|
|
|
- int add = algorithmMapper.update(po);
|
|
|
- if (add > 0) {
|
|
|
- return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
|
|
|
- }else {
|
|
|
- return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE, "编辑失败");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -119,7 +127,6 @@ public class AlgorithmServiceImpl implements AlgorithmService {
|
|
|
|
|
|
@Override
|
|
|
public ResponseBodyVO selectSharedAlgorithmList(AlgorithmParameter param) {
|
|
|
- param.setIsDeleted("0");
|
|
|
param.setShare("1");
|
|
|
setPage(param.getPageNum()==null?1:param.getPageNum(), param.getPageSize()==null?10:param.getPageSize());
|
|
|
List<AlgorithmVO> vos = algorithmMapper.selectSharedAlgorithmList(param);
|
|
@@ -138,13 +145,19 @@ public class AlgorithmServiceImpl implements AlgorithmService {
|
|
|
return new ResponseBodyVO(ResponseBodyVO.Response.CLIENT_FAILURE);
|
|
|
}else {
|
|
|
AlgorithmPO po = algorithmMapper.selectDetailsById(param);
|
|
|
- po.setShare("1");
|
|
|
- po.setId(StringUtil.getRandomUUID());
|
|
|
- int add = algorithmMapper.add(po);
|
|
|
- if(add > 0){
|
|
|
- return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
|
|
|
+ List<AlgorithmPO> algorithmPOS = algorithmMapper.selectSharedAlgorithmName(po.getAlgorithmName());
|
|
|
+ if(algorithmPOS != null && algorithmPOS.size() > 0){
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS,"该算法名称已存在, 无法分享!");
|
|
|
+ }else {
|
|
|
+ po.setShare("1");
|
|
|
+ po.setId(StringUtil.getRandomUUID());
|
|
|
+ int add = algorithmMapper.add(po);
|
|
|
+ if(add > 0){
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS,"分享成功");
|
|
|
+ }
|
|
|
+ return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"分享失败");
|
|
|
+
|
|
|
}
|
|
|
- return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE,"分享失败");
|
|
|
}
|
|
|
}
|
|
|
|