| @@ -50,7 +50,7 @@ public class ActiveLearnController extends BaseController { | |||||
| @DeleteMapping("{id}") | @DeleteMapping("{id}") | ||||
| @ApiOperation("删除主动学习") | @ApiOperation("删除主动学习") | ||||
| public GenericsAjaxResult<String> deleteActiveLearn(@PathVariable("id") Long id) { | |||||
| public GenericsAjaxResult<String> deleteActiveLearn(@PathVariable("id") Long id) throws Exception { | |||||
| return genericsSuccess(this.activeLearnService.delete(id)); | return genericsSuccess(this.activeLearnService.delete(id)); | ||||
| } | } | ||||
| @@ -50,7 +50,7 @@ public class RayController extends BaseController { | |||||
| @DeleteMapping("{id}") | @DeleteMapping("{id}") | ||||
| @ApiOperation("删除自动超参数寻优") | @ApiOperation("删除自动超参数寻优") | ||||
| public GenericsAjaxResult<String> deleteRay(@PathVariable("id") Long id) { | |||||
| public GenericsAjaxResult<String> deleteRay(@PathVariable("id") Long id) throws Exception { | |||||
| return genericsSuccess(this.rayService.delete(id)); | return genericsSuccess(this.rayService.delete(id)); | ||||
| } | } | ||||
| @@ -16,7 +16,7 @@ public interface ActiveLearnService { | |||||
| ActiveLearnVo getActiveLearnDetail(Long id) throws IOException; | ActiveLearnVo getActiveLearnDetail(Long id) throws IOException; | ||||
| String delete(Long id); | |||||
| String delete(Long id) throws Exception; | |||||
| String runActiveLearnIns (Long id) throws Exception; | String runActiveLearnIns (Long id) throws Exception; | ||||
| } | } | ||||
| @@ -16,7 +16,7 @@ public interface RayService { | |||||
| RayVo getRayDetail(Long id) throws IOException; | RayVo getRayDetail(Long id) throws IOException; | ||||
| String delete(Long id); | |||||
| String delete(Long id) throws Exception; | |||||
| String runRayIns(Long id) throws Exception; | String runRayIns(Long id) throws Exception; | ||||
| } | } | ||||
| @@ -117,15 +117,20 @@ public class ActiveLearnServiceImpl implements ActiveLearnService { | |||||
| @Override | @Override | ||||
| @Transactional | @Transactional | ||||
| public String delete(Long id) { | |||||
| public String delete(Long id) throws Exception { | |||||
| ActiveLearn activeLearn = activeLearnDao.getActiveLearnById(id); | ActiveLearn activeLearn = activeLearnDao.getActiveLearnById(id); | ||||
| if (activeLearn == null) { | if (activeLearn == null) { | ||||
| throw new RuntimeException("实验不存在"); | |||||
| throw new Exception("实验不存在"); | |||||
| } | } | ||||
| String username = SecurityUtils.getLoginUser().getUsername(); | String username = SecurityUtils.getLoginUser().getUsername(); | ||||
| String createBy = activeLearn.getCreateBy(); | String createBy = activeLearn.getCreateBy(); | ||||
| if (!(StringUtils.equals(username, "admin") || StringUtils.equals(username, createBy))) { | if (!(StringUtils.equals(username, "admin") || StringUtils.equals(username, createBy))) { | ||||
| throw new RuntimeException("无权限删除该实验"); | |||||
| throw new Exception("无权限删除该实验"); | |||||
| } | |||||
| List<ActiveLearnIns> insList = activeLearnInsDao.getByActiveLearnId(id); | |||||
| if (!insList.isEmpty()) { | |||||
| throw new Exception("该实验存在实例,无法删除"); | |||||
| } | } | ||||
| activeLearn.setState(Constant.State_invalid); | activeLearn.setState(Constant.State_invalid); | ||||
| resourceOccupyService.deleteTaskState(Constant.TaskType_ActiveLearn, id, null); | resourceOccupyService.deleteTaskState(Constant.TaskType_ActiveLearn, id, null); | ||||
| @@ -137,15 +137,19 @@ public class RayServiceImpl implements RayService { | |||||
| @Override | @Override | ||||
| @Transactional | @Transactional | ||||
| public String delete(Long id) { | |||||
| public String delete(Long id) throws Exception { | |||||
| Ray ray = rayDao.getRayById(id); | Ray ray = rayDao.getRayById(id); | ||||
| if (ray == null) { | if (ray == null) { | ||||
| throw new RuntimeException("实验不存在"); | |||||
| throw new Exception("实验不存在"); | |||||
| } | } | ||||
| String username = SecurityUtils.getLoginUser().getUsername(); | String username = SecurityUtils.getLoginUser().getUsername(); | ||||
| String createBy = ray.getCreateBy(); | String createBy = ray.getCreateBy(); | ||||
| if (!(StringUtils.equals(username, "admin") || StringUtils.equals(username, createBy))) { | if (!(StringUtils.equals(username, "admin") || StringUtils.equals(username, createBy))) { | ||||
| throw new RuntimeException("无权限删除该实验"); | |||||
| throw new Exception("无权限删除该实验"); | |||||
| } | |||||
| List<RayIns> insList = rayInsDao.getByRayId(id); | |||||
| if (!insList.isEmpty()) { | |||||
| throw new Exception("该实验存在实例,无法删除"); | |||||
| } | } | ||||
| ray.setState(Constant.State_invalid); | ray.setState(Constant.State_invalid); | ||||
| resourceOccupyService.deleteTaskState(Constant.TaskType_Ray, id, null); | resourceOccupyService.deleteTaskState(Constant.TaskType_Ray, id, null); | ||||