| @@ -49,7 +49,7 @@ public class AutoMlInsController extends BaseController { | |||||
| @PutMapping("{id}") | @PutMapping("{id}") | ||||
| @ApiOperation("终止实验实例") | @ApiOperation("终止实验实例") | ||||
| public GenericsAjaxResult<Boolean> terminateAutoMlIns(@PathVariable("id") Long id) { | |||||
| public GenericsAjaxResult<Boolean> terminateAutoMlIns(@PathVariable("id") Long id) throws Exception { | |||||
| return genericsSuccess(this.autoMLInsService.terminateAutoMlIns(id)); | return genericsSuccess(this.autoMLInsService.terminateAutoMlIns(id)); | ||||
| } | } | ||||
| @@ -21,7 +21,7 @@ public interface AutoMlInsService { | |||||
| AutoMlIns queryStatusFromArgo(AutoMlIns autoMlIns); | AutoMlIns queryStatusFromArgo(AutoMlIns autoMlIns); | ||||
| boolean terminateAutoMlIns(Long id); | |||||
| boolean terminateAutoMlIns(Long id) throws Exception; | |||||
| AutoMlIns getDetailById(Long id); | AutoMlIns getDetailById(Long id); | ||||
| @@ -57,7 +57,7 @@ public class AutoMlInsServiceImpl implements AutoMlInsService { | |||||
| if (StringUtils.isEmpty(autoMlIns.getStatus())) { | if (StringUtils.isEmpty(autoMlIns.getStatus())) { | ||||
| autoMlIns = queryStatusFromArgo(autoMlIns); | autoMlIns = queryStatusFromArgo(autoMlIns); | ||||
| } | } | ||||
| if (StringUtils.equals(autoMlIns.getStatus(), "Running")) { | |||||
| if (StringUtils.equals(autoMlIns.getStatus(), Constant.Running)) { | |||||
| return "实验实例正在运行,不可删除"; | return "实验实例正在运行,不可删除"; | ||||
| } | } | ||||
| @@ -156,7 +156,7 @@ public class AutoMlInsServiceImpl implements AutoMlInsService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public boolean terminateAutoMlIns(Long id) { | |||||
| public boolean terminateAutoMlIns(Long id) throws Exception { | |||||
| AutoMlIns autoMlIns = autoMlInsDao.queryById(id); | AutoMlIns autoMlIns = autoMlInsDao.queryById(id); | ||||
| if (autoMlIns == null) { | if (autoMlIns == null) { | ||||
| throw new IllegalStateException("实验实例未查询到,id: " + id); | throw new IllegalStateException("实验实例未查询到,id: " + id); | ||||
| @@ -172,7 +172,7 @@ public class AutoMlInsServiceImpl implements AutoMlInsService { | |||||
| } | } | ||||
| // 只有状态是"Running"时才能终止实例 | // 只有状态是"Running"时才能终止实例 | ||||
| if (!currentStatus.equalsIgnoreCase(Constant.Running)) { | if (!currentStatus.equalsIgnoreCase(Constant.Running)) { | ||||
| return false; // 如果不是"Running"状态,则不执行终止操作 | |||||
| throw new Exception("终止错误,只有运行状态的实例才能终止"); // 如果不是"Running"状态,则不执行终止操作 | |||||
| } | } | ||||
| // 创建请求数据map | // 创建请求数据map | ||||
| @@ -102,13 +102,13 @@ public class AutoMlServiceImpl implements AutoMlService { | |||||
| public String delete(Long id) { | public String delete(Long id) { | ||||
| AutoMl autoMl = autoMlDao.getAutoMlById(id); | AutoMl autoMl = autoMlDao.getAutoMlById(id); | ||||
| if (autoMl == null) { | if (autoMl == null) { | ||||
| throw new RuntimeException("服务不存在"); | |||||
| throw new RuntimeException("实验不存在"); | |||||
| } | } | ||||
| String username = SecurityUtils.getLoginUser().getUsername(); | String username = SecurityUtils.getLoginUser().getUsername(); | ||||
| String createBy = autoMl.getCreateBy(); | String createBy = autoMl.getCreateBy(); | ||||
| if (!(StringUtils.equals(username, "admin") || StringUtils.equals(username, createBy))) { | if (!(StringUtils.equals(username, "admin") || StringUtils.equals(username, createBy))) { | ||||
| throw new RuntimeException("无权限删除该服务"); | |||||
| throw new RuntimeException("无权限删除该实验"); | |||||
| } | } | ||||
| autoMl.setState(Constant.State_invalid); | autoMl.setState(Constant.State_invalid); | ||||