Browse Source

优化主动学习

pull/227/head
chenzhihang 8 months ago
parent
commit
57296d364e
6 changed files with 19 additions and 10 deletions
  1. +1
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/activeLearn/ActiveLearnController.java
  2. +1
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/ray/RayController.java
  3. +1
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ActiveLearnService.java
  4. +1
    -1
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/RayService.java
  5. +8
    -3
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ActiveLearnServiceImpl.java
  6. +7
    -3
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/RayServiceImpl.java

+ 1
- 1
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/activeLearn/ActiveLearnController.java View File

@@ -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));
} }




+ 1
- 1
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/ray/RayController.java View File

@@ -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));
} }




+ 1
- 1
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ActiveLearnService.java View File

@@ -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;
} }

+ 1
- 1
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/RayService.java View File

@@ -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;
} }

+ 8
- 3
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ActiveLearnServiceImpl.java View File

@@ -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);


+ 7
- 3
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/RayServiceImpl.java View File

@@ -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);


Loading…
Cancel
Save