diff --git a/escheduler-api/src/main/java/cn/escheduler/api/enums/Status.java b/escheduler-api/src/main/java/cn/escheduler/api/enums/Status.java index e569390127..6d57da2116 100644 --- a/escheduler-api/src/main/java/cn/escheduler/api/enums/Status.java +++ b/escheduler-api/src/main/java/cn/escheduler/api/enums/Status.java @@ -159,6 +159,7 @@ public enum Status { NAME_NULL(10134,"name must be not null"), NAME_EXIST(10135, "name {0} already exists"), SAVE_ERROR(10136, "save error"), + DELETE_PROJECT_ERROR_DEFINES_NOT_NULL(10137, "please delete the process definitions in project first!"), diff --git a/escheduler-api/src/main/java/cn/escheduler/api/service/ProjectService.java b/escheduler-api/src/main/java/cn/escheduler/api/service/ProjectService.java index 2be8ca4d51..c90d4da779 100644 --- a/escheduler-api/src/main/java/cn/escheduler/api/service/ProjectService.java +++ b/escheduler-api/src/main/java/cn/escheduler/api/service/ProjectService.java @@ -20,9 +20,11 @@ import cn.escheduler.api.enums.Status; import cn.escheduler.api.utils.Constants; import cn.escheduler.api.utils.PageInfo; import cn.escheduler.common.enums.UserType; +import cn.escheduler.dao.mapper.ProcessDefinitionMapper; import cn.escheduler.dao.mapper.ProjectMapper; import cn.escheduler.dao.mapper.ProjectUserMapper; import cn.escheduler.dao.mapper.UserMapper; +import cn.escheduler.dao.model.ProcessDefinition; import cn.escheduler.dao.model.Project; import cn.escheduler.dao.model.ProjectUser; import cn.escheduler.dao.model.User; @@ -55,6 +57,9 @@ public class ProjectService extends BaseService{ @Autowired private ProjectUserMapper projectUserMapper; + @Autowired + private ProcessDefinitionMapper processDefinitionMapper; + /** * create project * @@ -199,6 +204,12 @@ public class ProjectService extends BaseService{ if (checkResult != null) { return checkResult; } + List processDefinitionList = processDefinitionMapper.queryAllDefinitionList(projectId); + + if(processDefinitionList.size() > 0){ + putMsg(result, Status.DELETE_PROJECT_ERROR_DEFINES_NOT_NULL); + return result; + } int delete = projectMapper.delete(projectId); if (delete > 0) {