From 0b9b8875ca9b3c0cf4d0edb3b49eba6c7bff3b72 Mon Sep 17 00:00:00 2001
From: 이민희 <mhlee@maprex.co.kr>
Date: 수, 16 2월 2022 17:54:03 +0900
Subject: [PATCH] - 부서 삭제 시 워크플로우, 프로젝트, 이슈의 담당부서에 속해 있으면 삭제 못하도록 수정

---
 src/main/java/kr/wisestone/owl/service/impl/DepartmentServiceImpl.java |   26 +++++++++++++++++++++++---
 1 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/src/main/java/kr/wisestone/owl/service/impl/DepartmentServiceImpl.java b/src/main/java/kr/wisestone/owl/service/impl/DepartmentServiceImpl.java
index c7e7000..67d7586 100644
--- a/src/main/java/kr/wisestone/owl/service/impl/DepartmentServiceImpl.java
+++ b/src/main/java/kr/wisestone/owl/service/impl/DepartmentServiceImpl.java
@@ -56,6 +56,9 @@
     private ProjectRoleDepartmentService projectRoleDepartmentService;
 
     @Autowired
+    private IssueDepartmentService issueDepartmentService;
+
+    @Autowired
     private ProjectRoleService projectRoleService;
 
     @Autowired
@@ -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();

--
Gitblit v1.8.0