OWL ITS + 탐지시스템(인터넷 진흥원)
이민희
2022-03-17 916a3cbabe4e50062fce61ff6f2f5d46c05dfbd1
src/main/java/kr/wisestone/owl/service/impl/DepartmentServiceImpl.java
@@ -41,7 +41,7 @@
    private DepartmentRepository departmentRepository;
    @Autowired
    private UserDepartmentRepository userDepartmentRepository;
    private UserDepartmentService userDepartmentService;
    @Autowired
    private DepartmentMapper departmentMapper;
@@ -54,6 +54,9 @@
    @Autowired
    private ProjectRoleDepartmentService projectRoleDepartmentService;
    @Autowired
    private IssueDepartmentService issueDepartmentService;
    @Autowired
    private ProjectRoleService projectRoleService;
@@ -125,11 +128,28 @@
        }
        for (Long id : departmentForm.getRemoveIds()) {
            if (!this.departmentService.countInDepartment(id)) {
                this.departmentRepository.deleteById(id);
            } else {
            if (this.departmentService.countInDepartment(id)) {
                //  사용자가 부서에 속해 있는지 체크
                throw new OwlRuntimeException(
                        this.messageAccessor.getMessage(MsgConstants.DEPARTMENT_ALREADY_IN_USE));
            } else if (this.workflowDepartmentService.usingDepartment(id)) {
                //  워크플로우에서 해당 부서를 사용하고 있는지 체크
                throw new OwlRuntimeException(
                        this.messageAccessor.getMessage(MsgConstants.DEPARTMENT_ALREADY_IN_USE_IN_WORKFLOW));
            } else if (this.projectRoleDepartmentService.usingDepartment(id)) {
                //  프로젝트의 담당부서인지 체크
                throw new OwlRuntimeException(
                        this.messageAccessor.getMessage(MsgConstants.DEPARTMENT_ALREADY_IN_USE_IN_PROJECT));
            } else if (this.issueDepartmentService.usingDepartment(id)) {
                //  이슈의 담당부서로 되어있는지 체크
                throw new OwlRuntimeException(
                        this.messageAccessor.getMessage(MsgConstants.DEPARTMENT_ALREADY_IN_USE_IN_ISSUE));
            } else {
                this.departmentRepository.deleteById(id);
            }
        }
        this.departmentRepository.flush();
@@ -238,7 +258,7 @@
    @Override
    public boolean countInDepartment(Long id) {
        boolean result = false;
        List<UserDepartment> usingDepartments = this.userDepartmentRepository.findByDepartmentId(id);
        List<UserDepartment> usingDepartments = this.userDepartmentService.findByDepartmentId(id);
        if(usingDepartments != null && usingDepartments.size() > 0){
            result = true;
        }