|
@@ -29,10 +29,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.HashMap;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
@Service
|
|
@Service
|
|
@@ -69,35 +66,38 @@ public class AlgorithmServiceImpl implements AlgorithmService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@SneakyThrows
|
|
@SneakyThrows
|
|
- public ResponseBodyVO<String> addOrUpdate(AlgorithmParameter param) {
|
|
|
|
-
|
|
|
|
|
|
+ public ResponseBodyVO<Void> addOrUpdate(AlgorithmParameter param) {
|
|
String currentUserId = AuthUtil.getCurrentUserId();
|
|
String currentUserId = AuthUtil.getCurrentUserId();
|
|
param.setCreateUserId(currentUserId);
|
|
param.setCreateUserId(currentUserId);
|
|
|
|
+ // 公有另存为私有,设置 share 为 0
|
|
|
|
+ if (Objects.equals(DictConstants.IS_SHARED, param.getShare())) {
|
|
|
|
+ param.setShare(DictConstants.IS_NOT_SHARED);
|
|
|
|
+ }
|
|
List<AlgorithmPO> algorithmPOS = algorithmMapper.selectAlgorithmName(param);
|
|
List<AlgorithmPO> algorithmPOS = algorithmMapper.selectAlgorithmName(param);
|
|
if (algorithmPOS != null && algorithmPOS.size() > 0) {
|
|
if (algorithmPOS != null && algorithmPOS.size() > 0) {
|
|
- return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE, "该算法名称已存在!");
|
|
|
|
|
|
+ return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE, "该算法名称已存在。");
|
|
} else {
|
|
} else {
|
|
String uploadMode = param.getUploadMode();
|
|
String uploadMode = param.getUploadMode();
|
|
if (DictConstants.FILE.equals(uploadMode)) {
|
|
if (DictConstants.FILE.equals(uploadMode)) {
|
|
String minioPath = param.getMinioPath();
|
|
String minioPath = param.getMinioPath();
|
|
ResponseBodyVO<String> checkRes = schedulerService.check(minioPath);
|
|
ResponseBodyVO<String> checkRes = schedulerService.check(minioPath);
|
|
if (ObjectUtil.isNull(checkRes)) {
|
|
if (ObjectUtil.isNull(checkRes)) {
|
|
- return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE, "算法校验服务异常,请联系管理人员!");
|
|
|
|
|
|
+ return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE, "算法校验服务异常,请联系管理人员。");
|
|
}
|
|
}
|
|
if (!checkRes.isStatus()) {//校验失败
|
|
if (!checkRes.isStatus()) {//校验失败
|
|
MinioParameter minioParameter = new MinioParameter();
|
|
MinioParameter minioParameter = new MinioParameter();
|
|
minioParameter.setObjectName(minioPath);
|
|
minioParameter.setObjectName(minioPath);
|
|
fileDownService.remove(minioParameter);
|
|
fileDownService.remove(minioParameter);
|
|
- return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE, "该算法经校验不可用,无法保存!");
|
|
|
|
|
|
+ return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE, "该算法经校验不可用,无法保存。");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return doAddOrUpdate(param);
|
|
return doAddOrUpdate(param);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private ResponseBodyVO doAddOrUpdate(AlgorithmParameter param) {
|
|
|
|
|
|
+ private ResponseBodyVO<Void> doAddOrUpdate(AlgorithmParameter param) {
|
|
if (isEmpty(param.getId())) {
|
|
if (isEmpty(param.getId())) {
|
|
- //添加
|
|
|
|
|
|
+ // 添加
|
|
String algorithmId = StringUtil.getRandomUUID();
|
|
String algorithmId = StringUtil.getRandomUUID();
|
|
param.setId(algorithmId);
|
|
param.setId(algorithmId);
|
|
String algorithmCode = StringUtil.getRandomCode();
|
|
String algorithmCode = StringUtil.getRandomCode();
|
|
@@ -106,19 +106,19 @@ public class AlgorithmServiceImpl implements AlgorithmService {
|
|
int add = algorithmMapper.add(po);
|
|
int add = algorithmMapper.add(po);
|
|
if (add > 0) {
|
|
if (add > 0) {
|
|
LogUtil.insert();
|
|
LogUtil.insert();
|
|
- return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
|
|
|
|
|
|
+ return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS);
|
|
} else {
|
|
} else {
|
|
- return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE, "添加失败");
|
|
|
|
|
|
+ return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE, "添加失败");
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- //编辑
|
|
|
|
|
|
+ // 编辑
|
|
AlgorithmPO po = setPo(param, true);
|
|
AlgorithmPO po = setPo(param, true);
|
|
int add = algorithmMapper.update(po);
|
|
int add = algorithmMapper.update(po);
|
|
if (add > 0) {
|
|
if (add > 0) {
|
|
LogUtil.update();
|
|
LogUtil.update();
|
|
- return new ResponseBodyVO(ResponseBodyVO.Response.SUCCESS);
|
|
|
|
|
|
+ return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS);
|
|
} else {
|
|
} else {
|
|
- return new ResponseBodyVO(ResponseBodyVO.Response.SERVER_FAILURE, "编辑失败");
|
|
|
|
|
|
+ return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE, "编辑失败");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|