算法创建(暂无分布式存储
This commit is contained in:
@ -1,15 +1,20 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.controller;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.AlgorithmInfo;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.OptResult;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.service.AlgorithmInfoService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Tag(name ="算法创建相关接口")
|
||||
@RestController
|
||||
@RequestMapping("/api/algorithm")
|
||||
@Slf4j
|
||||
public class AlgorithmInfoController {
|
||||
|
||||
@Autowired
|
||||
@ -57,4 +62,16 @@ public class AlgorithmInfoController {
|
||||
ResponseEntity.ok("Delete successful") :
|
||||
ResponseEntity.badRequest().body("Delete failed");
|
||||
}
|
||||
|
||||
/**
|
||||
* 算法创建
|
||||
*/
|
||||
@PostMapping
|
||||
@Operation(summary ="算法创建")
|
||||
public OptResult save(@RequestBody AlgorithmInfo algorithmInfo){
|
||||
log.info("新增算法",algorithmInfo);
|
||||
algorithmInfoService.save(algorithmInfo);
|
||||
return OptResult.success("算法创建成功");
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +1,16 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AlgorithmInfo {
|
||||
private Long id;
|
||||
private String algorithmName;
|
||||
|
@ -11,4 +11,7 @@ public interface AlgorithmInfoService {
|
||||
boolean update(AlgorithmInfo algorithmInfo);
|
||||
boolean delete(Long id);
|
||||
boolean validateAlgorithmInfo(AlgorithmInfo algorithmInfo);
|
||||
|
||||
void save(AlgorithmInfo algorithmInfo);
|
||||
|
||||
}
|
@ -60,4 +60,23 @@ public class AlgorithmInfoServiceImpl implements AlgorithmInfoService {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 算法创建
|
||||
* @param algorithmInfo
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void save(AlgorithmInfo algorithmInfo) {
|
||||
String algorithmName = algorithmInfo.getAlgorithmName();
|
||||
//查找表里是否有重复的算法,如果有则报错
|
||||
AlgorithmInfo duplicateName = algorithmInfoMapper.selectByName(algorithmName);
|
||||
if (duplicateName != null){
|
||||
throw new RuntimeException("算法已存在");
|
||||
}
|
||||
//todo 算法文件分布式存入分布式存储中
|
||||
|
||||
|
||||
algorithmInfoMapper.insert(algorithmInfo);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user