From 51365e66857e4b7a1d783b0309e20e855e393ae5 Mon Sep 17 00:00:00 2001
From: 이민희 <mhlee@maprex.co.kr>
Date: 금, 10 12월 2021 10:10:26 +0900
Subject: [PATCH] 이슈전체보기/프로젝트전체보기 권한 설정

---
 src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java |  100 +++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 91 insertions(+), 9 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..76e1126 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_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);
@@ -1872,6 +1876,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 +2075,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