修改删除报错接口
This commit is contained in:
parent
35e40fdf0b
commit
9a7898df96
|
@ -97,7 +97,7 @@ public class ExperimentController {
|
|||
*/
|
||||
@DeleteMapping("{id}")
|
||||
@ApiOperation("删除流水线")
|
||||
public AjaxResult deleteById(@PathVariable("id") Integer id) {
|
||||
public AjaxResult deleteById(@PathVariable("id") Integer id) throws Exception {
|
||||
return AjaxResult.success(this.experimentService.removeById(id));
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ public interface ExperimentService {
|
|||
* @return 是否成功
|
||||
*/
|
||||
boolean deleteById(Integer id);
|
||||
String removeById(Integer id);
|
||||
String removeById(Integer id) throws Exception;
|
||||
Experiment runExperiment(Integer id) throws Exception;
|
||||
|
||||
Experiment addAndRunExperiment(Experiment experiment);
|
||||
|
|
|
@ -165,10 +165,10 @@ public class ExperimentServiceImpl implements ExperimentService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String removeById(Integer id) {
|
||||
public String removeById(Integer id) throws Exception {
|
||||
Experiment experiment = experimentDao.queryById(id);
|
||||
if (experiment==null){
|
||||
return "实验不存在";
|
||||
throw new Exception("实验不存在");
|
||||
}
|
||||
|
||||
//判断权限,只有admin和创建者本身可以删除该实验
|
||||
|
@ -176,12 +176,12 @@ public class ExperimentServiceImpl implements ExperimentService {
|
|||
String username = loginUser.getUsername();
|
||||
String createdBy = experiment.getCreateBy();
|
||||
if (!(StringUtils.equals(username,"admin") || StringUtils.equals(username,createdBy))){
|
||||
return "无权限删除该实验";
|
||||
throw new Exception("无权限删除该实验");
|
||||
}
|
||||
|
||||
List<ExperimentIns> experimentInsList = experimentInsService.queryByExperimentId(experiment.getId());
|
||||
if (experimentInsList!=null&&experimentInsList.size()>0){
|
||||
return "该实验存在实例,无法删除";
|
||||
throw new Exception("该实验存在实例,无法删除");
|
||||
}
|
||||
experiment.setState(0);
|
||||
return this.experimentDao.update(experiment)>0?"删除成功":"删除失败";
|
||||
|
|
Loading…
Reference in New Issue