Browse Source

check definitions is null when delete project.

pull/2/head
baoliang 6 years ago
parent
commit
a0eb84f667
  1. 1
      escheduler-api/src/main/java/cn/escheduler/api/enums/Status.java
  2. 11
      escheduler-api/src/main/java/cn/escheduler/api/service/ProjectService.java

1
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_NULL(10134,"name must be not null"),
NAME_EXIST(10135, "name {0} already exists"), NAME_EXIST(10135, "name {0} already exists"),
SAVE_ERROR(10136, "save error"), SAVE_ERROR(10136, "save error"),
DELETE_PROJECT_ERROR_DEFINES_NOT_NULL(10137, "please delete the process definitions in project first!"),

11
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.Constants;
import cn.escheduler.api.utils.PageInfo; import cn.escheduler.api.utils.PageInfo;
import cn.escheduler.common.enums.UserType; import cn.escheduler.common.enums.UserType;
import cn.escheduler.dao.mapper.ProcessDefinitionMapper;
import cn.escheduler.dao.mapper.ProjectMapper; import cn.escheduler.dao.mapper.ProjectMapper;
import cn.escheduler.dao.mapper.ProjectUserMapper; import cn.escheduler.dao.mapper.ProjectUserMapper;
import cn.escheduler.dao.mapper.UserMapper; import cn.escheduler.dao.mapper.UserMapper;
import cn.escheduler.dao.model.ProcessDefinition;
import cn.escheduler.dao.model.Project; import cn.escheduler.dao.model.Project;
import cn.escheduler.dao.model.ProjectUser; import cn.escheduler.dao.model.ProjectUser;
import cn.escheduler.dao.model.User; import cn.escheduler.dao.model.User;
@ -55,6 +57,9 @@ public class ProjectService extends BaseService{
@Autowired @Autowired
private ProjectUserMapper projectUserMapper; private ProjectUserMapper projectUserMapper;
@Autowired
private ProcessDefinitionMapper processDefinitionMapper;
/** /**
* create project * create project
* *
@ -199,6 +204,12 @@ public class ProjectService extends BaseService{
if (checkResult != null) { if (checkResult != null) {
return checkResult; return checkResult;
} }
List<ProcessDefinition> processDefinitionList = processDefinitionMapper.queryAllDefinitionList(projectId);
if(processDefinitionList.size() > 0){
putMsg(result, Status.DELETE_PROJECT_ERROR_DEFINES_NOT_NULL);
return result;
}
int delete = projectMapper.delete(projectId); int delete = projectMapper.delete(projectId);
if (delete > 0) { if (delete > 0) {

Loading…
Cancel
Save