|
@@ -69,30 +69,35 @@ public class AlgorithmServiceImpl implements AlgorithmService {
|
|
|
public ResponseBodyVO<Void> addOrUpdate(AlgorithmParameter param) {
|
|
|
String currentUserId = AuthUtil.getCurrentUserId();
|
|
|
param.setCreateUserId(currentUserId);
|
|
|
- // 公有另存为私有,设置 share 为 0
|
|
|
+
|
|
|
+ //* -------------------------------- 校验算法名称 --------------------------------
|
|
|
+ // 公有另存为私有
|
|
|
if (Objects.equals(DictConstants.IS_SHARED, param.getShare())) {
|
|
|
+ // 设置 share 为 0
|
|
|
+ // 设置创建人为当前用户
|
|
|
param.setShare(DictConstants.IS_NOT_SHARED);
|
|
|
+ param.setCreateUserId(AuthUtil.getCurrentUserId());
|
|
|
}
|
|
|
List<AlgorithmPO> algorithmPOS = algorithmMapper.selectAlgorithmName(param);
|
|
|
- if (algorithmPOS != null && algorithmPOS.size() > 0) {
|
|
|
- return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE, "该算法名称已存在。");
|
|
|
- } else {
|
|
|
- String uploadMode = param.getUploadMode();
|
|
|
- if (DictConstants.FILE.equals(uploadMode)) {
|
|
|
- String minioPath = param.getMinioPath();
|
|
|
- ResponseBodyVO<String> checkRes = schedulerService.check(minioPath);
|
|
|
- if (ObjectUtil.isNull(checkRes)) {
|
|
|
- return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE, "算法校验服务异常,请联系管理人员。");
|
|
|
- }
|
|
|
- if (!checkRes.isStatus()) {//校验失败
|
|
|
- MinioParameter minioParameter = new MinioParameter();
|
|
|
- minioParameter.setObjectName(minioPath);
|
|
|
- fileDownService.remove(minioParameter);
|
|
|
- return new ResponseBodyVO<>(ResponseBodyVO.Response.SERVER_FAILURE, "该算法经校验不可用,无法保存。");
|
|
|
- }
|
|
|
+ if (CollectionUtil.isNotEmpty(algorithmPOS)) {
|
|
|
+ throw new RuntimeException("该算法名称已存在。");
|
|
|
+ }
|
|
|
+ //* -------------------------------- comment --------------------------------
|
|
|
+ String uploadMode = param.getUploadMode();
|
|
|
+ if (DictConstants.FILE.equals(uploadMode)) {
|
|
|
+ String minioPath = param.getMinioPath();
|
|
|
+ ResponseBodyVO<String> checkRes = schedulerService.check(minioPath);
|
|
|
+ if (ObjectUtil.isNull(checkRes)) {
|
|
|
+ throw new RuntimeException("算法校验服务异常,请联系管理人员。");
|
|
|
+ }
|
|
|
+ if (!checkRes.isStatus()) { //校验失败
|
|
|
+ MinioParameter minioParameter = new MinioParameter();
|
|
|
+ minioParameter.setObjectName(minioPath);
|
|
|
+ fileDownService.remove(minioParameter);
|
|
|
+ throw new RuntimeException("该算法经校验不可用,无法保存。");
|
|
|
}
|
|
|
- return doAddOrUpdate(param);
|
|
|
}
|
|
|
+ return doAddOrUpdate(param);
|
|
|
}
|
|
|
|
|
|
private ResponseBodyVO<Void> doAddOrUpdate(AlgorithmParameter param) {
|