From debc7d47107b1fc4509593d942d775f4374a3416 Mon Sep 17 00:00:00 2001
From: wyu <kknd09321@nate.com>
Date: 금, 10 12월 2021 13:29:20 +0900
Subject: [PATCH] 권한 수정 완료

---
 src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java |  105 +++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 95 insertions(+), 10 deletions(-)

diff --git a/src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java b/src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java
index f0022e5..7300590 100644
--- a/src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java
+++ b/src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java
@@ -5,10 +5,7 @@
 import kr.wisestone.owl.common.ExcelConditionCheck;
 import kr.wisestone.owl.common.IssueCustomFieldValueFormComparator;
 import kr.wisestone.owl.config.CommonConfiguration;
-import kr.wisestone.owl.constant.Constants;
-import kr.wisestone.owl.constant.ElasticSearchConstants;
-import kr.wisestone.owl.constant.MsgConstants;
-import kr.wisestone.owl.constant.UsePartner;
+import kr.wisestone.owl.constant.*;
 import kr.wisestone.owl.data.CheckIssueData;
 import kr.wisestone.owl.domain.*;
 import kr.wisestone.owl.domain.enumType.CustomFieldType;
@@ -152,6 +149,9 @@
 
     @Autowired
     private UserWorkspaceService userWorkspaceService;
+
+    @Autowired
+    private UserLevelService userLevelService;
 
     @Autowired
     private WorkflowDepartmentService workflowDepartmentService;
@@ -745,10 +745,13 @@
         issueCondition.setWorkspaceId(this.userService.getUser(this.webAppUtil.getLoginId()).getLastWorkspaceId());
         User user = this.webAppUtil.getLoginUserObject();
 
+
         List<Map<String, Object>> results = Lists.newArrayList();
         Long totalCount = 0L;
+        UserLevel userLevel = this.userLevelService.getUserLevel(user.getUserLevel().getId());
 
-        if (this.userWorkspaceService.checkWorkspaceManager(user)) {
+        if (this.userWorkspaceService.checkWorkspaceManager(user)
+                || MngPermission.checkMngPermission(userLevel.getPermission(), MngPermission.USER_PERMISSION_MNG_ISSUE_PROJECT_ALL)) {
             results = this.issueMapper.find(issueCondition);
             totalCount = this.issueMapper.count(issueCondition);
         } else{
@@ -768,6 +771,7 @@
 
         int totalPage = (int) Math.ceil((totalCount - 1) / pageable.getPageSize()) + 1;
         //  �씠�뒋 �븘�씠�뵒 珥덇린�솕
+        issueCondition.setIsApi(issueCondition.getIsApi());
         issueCondition.setIssueIds(Lists.newArrayList());
         //  Map �뿉 �엳�뒗 �뜲�씠�꽣瑜� IssueVo �뜲�씠�꽣濡� 蹂��솚�븳�떎.
         this.setMapToIssueVo(results, issueVos, issueCondition, user);
@@ -1034,6 +1038,7 @@
         condition.setWorkspaceId(this.userService.getUser(this.webAppUtil.getLoginId()).getLastWorkspaceId());
         projectCondition.setWorkspaceId(condition.getWorkspaceId());
 
+
         //  �봽濡쒖젥�듃 �궎媛� 議댁옱�븷 寃쎌슦 �봽濡쒖젥�듃 �궎�뿉 �빐�떦�븯�뒗 �봽濡쒖젥�듃瑜� 議고쉶�븯怨� 寃��깋 議곌굔�뿉 �뀑�똿�븳�떎.
         if (!this.getProjectByProjectKey(condition.getProjectKey(), condition)) {
             return false;
@@ -1042,7 +1047,9 @@
         //  �봽濡쒖젥�듃瑜� �꽑�깮�븯吏� �븡�븯�쑝硫� �빐�떦 �뾽臾� 怨듦컙�뿉�꽌 李몄뿬�븯怨� �엳�뒗 �봽濡쒖젥�듃瑜� 李얜뒗�떎.
         if (condition.getProjectIds().size() < 1) {
             List<Map<String, Object>> projects = null;
-            if (this.userWorkspaceService.checkWorkspaceManager(user)) {
+            UserLevel userLevel = this.userLevelService.getUserLevel(user.getUserLevel().getId());
+            if (this.userWorkspaceService.checkWorkspaceManager(user)
+                    || MngPermission.checkMngPermission(userLevel.getPermission(), MngPermission.USER_PERMISSION_MNG_ISSUE_PROJECT_ALL)) {
                 projects = this.projectMapper.findByWorkspaceManagerAll(projectCondition);
             } else  {
                 projects = this.projectService.findByWorkspaceIdAndIncludeProjectAll(projectCondition);
@@ -1872,6 +1879,9 @@
         //hasPermission = this.checkIssueModifyPermission(hasPermission, Issue.ASSIGNEE, issueVo, issueUserVos);
         //  �떞�떦�옄媛� �뾾�쑝硫� 紐⑤뱺 �궗�슜�옄媛� �닔�젙 沅뚰븳�쓣 媛뽯뒗�떎.
 
+        hasPermission = this.checkIssueModifyPermission(hasPermission, Issue.ALL_ISSUE_MANAGER, issueVo, null, null, user);
+        hasPermission = this.checkIssueModifyPermission(hasPermission, Issue.ALL_PROJECT_MANAGER, issueVo, null, null, user);
+
         return hasPermission;
     }
 
@@ -2068,20 +2078,95 @@
         List<Issue> removeIssues = Lists.newArrayList();
 
         for (Long issueId : issueForm.getRemoveIds()) {
+            //�븯�쐞�씠�뒋 泥댄겕
+            List<Issue> downIssues = this.issueRepository.findByParentIssueId(issueId);
+            if(downIssues != null && downIssues.size() > 0){
+                for(Issue downIssue : downIssues){
+                    if(downIssue.getParentIssue() != null){
+                        downIssue.setParentIssue(null);
+                    }
+                }
+            }
+
             Issue issue = this.issueRemoves(issueId, user);
             removeIssues.add(issue);
         }
 
-        if (removeIssues.size() > 0) {
-            //this.issueRepository.deleteAll(removeIssues);
-        }
+        /*if (removeIssues.size() > 0) {
+            this.issueRepository.deleteAll(removeIssues);
+        }*/
 
         //  �궗�슜�옄 �떆�뒪�뀥 湲곕뒫 �궗�슜 �젙蹂� �닔吏�
         log.info(ElasticSearchUtil.makeUserActiveHistoryMessage(this.webAppUtil.getLoginUser(), ElasticSearchConstants.ISSUE_REMOVE));
     }
 
+    //  �씠�뒋瑜� �궘�젣�븳�떎.
+    @Override
+    @Transactional
+    public void removeAllIssues(IssueForm issueForm) {
+        //  �궗�슜�븯怨� �엳�뒗 �뾽臾� 怨듦컙�씠 �솢�꽦 �긽�깭�씤吏� �솗�씤�븳�떎. �궗�슜 怨듦컙�뿉�꽌 濡쒓렇�씤�븳 �궗�슜�옄媛� 鍮꾪솢�꽦�씤吏� �솗�씤�븳�떎.
+        User user = this.webAppUtil.getLoginUserObject();
+        this.workspaceService.checkUseWorkspace();
+
+        if (issueForm.getRemoveIds().size() < 1) {
+            throw new OwlRuntimeException(
+                    this.messageAccessor.getMessage(MsgConstants.ISSUE_REMOVE_NOT_SELECT));
+        }
+
+        List<Issue> removeIssues = Lists.newArrayList();
+
+        for (Long issueId : issueForm.getRemoveIds()) {
+            //�븯�쐞�씠�뒋 泥댄겕
+            List<Issue> downIssues = this.issueRepository.findByParentIssueId(issueId);
+            if(downIssues != null && downIssues.size() > 0){
+                for(Issue downIssue : downIssues){
+                    Long downIssueId = downIssue.getId();
+                    downIssue = this.issueRemoves(downIssueId, user);
+                    removeIssues.add(downIssue);
+                }
+            }
+            Issue issue = this.issueRemoves(issueId, user);
+            removeIssues.add(issue);
+        }
+        //  �궗�슜�옄 �떆�뒪�뀥 湲곕뒫 �궗�슜 �젙蹂� �닔吏�
+        log.info(ElasticSearchUtil.makeUserActiveHistoryMessage(this.webAppUtil.getLoginUser(), ElasticSearchConstants.ISSUE_REMOVE));
+    }
+
+    //  �븯�쐞�씠�뒋瑜� �궘�젣�븳�떎.
+    @Override
+    @Transactional
+    public void removeDownIssues(IssueForm issueForm) {
+        //  �궗�슜�븯怨� �엳�뒗 �뾽臾� 怨듦컙�씠 �솢�꽦 �긽�깭�씤吏� �솗�씤�븳�떎. �궗�슜 怨듦컙�뿉�꽌 濡쒓렇�씤�븳 �궗�슜�옄媛� 鍮꾪솢�꽦�씤吏� �솗�씤�븳�떎.
+        User user = this.webAppUtil.getLoginUserObject();
+        this.workspaceService.checkUseWorkspace();
+
+        if (issueForm.getRemoveIds().size() < 1) {
+            throw new OwlRuntimeException(
+                    this.messageAccessor.getMessage(MsgConstants.ISSUE_REMOVE_NOT_SELECT));
+        }
+
+        List<Issue> removeIssues = Lists.newArrayList();
+        Long downIssueId = 0L;
+        for (Long issueId : issueForm.getRemoveIds()) {
+            //�궘�젣 �븷 �씠�뒋�쓽 �븯�쐞�씠�뒋 泥댄겕
+            List<Issue> downIssues = this.issueRepository.findByParentIssueId(issueId);
+            if(downIssues != null && downIssues.size() > 0){
+                for(Issue downIssue : downIssues){
+                    downIssueId = downIssue.getId();
+                }
+            }
+            Issue issue = this.issueRemoves(downIssueId, user);
+            removeIssues.add(issue);
+        }
+        //  �궗�슜�옄 �떆�뒪�뀥 湲곕뒫 �궗�슜 �젙蹂� �닔吏�
+        log.info(ElasticSearchUtil.makeUserActiveHistoryMessage(this.webAppUtil.getLoginUser(), ElasticSearchConstants.ISSUE_REMOVE));
+    }
+
     private Issue issueRemoves(Long issueId, User user) {
-        Issue issue = this.getIssue(issueId);
+        Issue issue = null;
+        if(issueId != null){
+            issue = this.getIssue(issueId);
+        }
         //  �씠�뒋 �닔�젙 沅뚰븳�쓣 媛뽮퀬 �엳�뒗吏� �솗�씤
         this.verifyIssueModifyPermission(issue, user);
 

--
Gitblit v1.8.0