|
|
|
@@ -117,15 +117,20 @@ public class ActiveLearnServiceImpl implements ActiveLearnService { |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public String delete(Long id) { |
|
|
|
public String delete(Long id) throws Exception { |
|
|
|
ActiveLearn activeLearn = activeLearnDao.getActiveLearnById(id); |
|
|
|
if (activeLearn == null) { |
|
|
|
throw new RuntimeException("实验不存在"); |
|
|
|
throw new Exception("实验不存在"); |
|
|
|
} |
|
|
|
String username = SecurityUtils.getLoginUser().getUsername(); |
|
|
|
String createBy = activeLearn.getCreateBy(); |
|
|
|
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); |
|
|
|
resourceOccupyService.deleteTaskState(Constant.TaskType_ActiveLearn, id, null); |
|
|
|
|