From 1bf54ac4463cc9a821bb818f6c8cfb01d981e91a Mon Sep 17 00:00:00 2001
From: 이민희 <mhlee@maprex.co.kr>
Date: 목, 23 12월 2021 15:51:29 +0900
Subject: [PATCH] - '이슈관리' 권한은 내가 속해있는 프로젝트의 이슈에 대해서만 관리 권한이 있음 - 일반 사용자 검색 문제 해결 - 이슈리스트 툴팁 재추가

---
 src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java |   78 ++++++++++++++++++++++++++++-----------
 1 files changed, 56 insertions(+), 22 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 549ac90..5521106 100644
--- a/src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java
+++ b/src/main/java/kr/wisestone/owl/service/impl/IssueServiceImpl.java
@@ -375,10 +375,11 @@
         IssueForm issueForm = this.convertToIssueForm(issueApiForm, user);
 
         List<Issue> issues = Lists.newArrayList();
-        if (issueForm.getParentIssueId() != null) {
+        if (issueForm.getParentIssueId() != null    // 湲곗〈 異붽��맂 �긽�쐞 �씪媛먯씠 �뾾嫄곕굹 �꽕�젙�맂 以묐났 �씠�뒋 id媛� �뾾�쓣�븣
+                || issueApiForm.getUseIssueCustomFieldIds().size() == 0) {
             issues.add(addIssue(user, issueForm, issueApiForm.getMultipartFiles()));
         } else {
-            // �긽�쐞 �씠�뒋 異붽�
+            // 媛��긽 �긽�쐞 �씠�뒋 異붽�
             IssueForm parentIssueForm = issueForm.clone();
             parentIssueForm.setUseIssueCustomFields(issueApiForm.getUseIssueCustomFieldIds());
             Issue issue = addIssue(user, parentIssueForm, null);
@@ -891,7 +892,6 @@
     @Override
     @Transactional(readOnly = true)
     public List<IssueVo> findIssue(Map<String, Object> resJsonData, IssueCondition issueCondition, Pageable pageable) {
-
         //  寃��깋 議곌굔�쓣 留뚮뱺�떎
         if (!this.makeIssueSearchCondition(issueCondition, Lists.newArrayList("01", "02", "03"), pageable)) {
             //  �씠�뒋 紐⑸줉�쓣 李얠� 紐삵븷 寃쎌슦 湲곕낯 �젙蹂대줈 由ы꽩�븳�떎.
@@ -925,14 +925,14 @@
         Long totalCount = 0L;
         UserLevel userLevel = this.userLevelService.getUserLevel(user.getUserLevel().getId());
 
-        if (this.userWorkspaceService.checkWorkspaceManager(user)
-                || MngPermission.checkMngPermission(userLevel.getPermission(), MngPermission.USER_PERMISSION_MNG_ISSUE)) {
-            this.SetAllDepartmentId(issueCondition);
-        } else{
-            this.SetMyDepartmentId(issueCondition);
-            /*results = this.issueMapper.findByDepartment(issueCondition);
-            totalCount = this.issueMapper.countByDepartment(issueCondition);*/
-        }
+//        if (!this.userWorkspaceService.checkWorkspaceManager(user)
+//                && !MngPermission.checkMngPermission(userLevel.getPermission(), MngPermission.USER_PERMISSION_MNG_ISSUE)) { //理쒓퀬愿�由ъ옄 & �봽濡쒖젥�듃,�씠�뒋 愿�由ъ옄 �씪 寃쎌슦 紐⑤뱺 �씠�뒋 蹂닿린
+//            this.SetMyDepartmentId(issueCondition);
+            //this.SetAllDepartmentId(issueCondition);
+//        } /*else{
+//            results = this.issueMapper.findByDepartment(issueCondition);
+//            totalCount = this.issueMapper.countByDepartment(issueCondition);
+//        }*/
         results = this.issueMapper.find(issueCondition);
         totalCount = this.issueMapper.count(issueCondition);
 
@@ -1239,6 +1239,9 @@
         condition.setLoginUserId(this.webAppUtil.getLoginId());
         condition.setWorkspaceId(this.userService.getUser(this.webAppUtil.getLoginId()).getLastWorkspaceId());
 
+        User user = this.webAppUtil.getLoginUserObject();
+        UserLevel userLevel = this.userLevelService.getUserLevel(user.getUserLevel().getId());
+
         //  �봽濡쒖젥�듃 �궎媛� 議댁옱�븷 寃쎌슦 �봽濡쒖젥�듃 �궎�뿉 �빐�떦�븯�뒗 �봽濡쒖젥�듃瑜� 議고쉶�븯怨� 寃��깋 議곌굔�뿉 �뀑�똿�븳�떎.
         if (!this.getProjectByProjectKey(condition.getProjectKey(), condition)) {
             return false;
@@ -1246,9 +1249,17 @@
 
         //  �봽濡쒖젥�듃瑜� �꽑�깮�븯吏� �븡�븯�쑝硫� �빐�떦 �뾽臾� 怨듦컙�뿉�꽌 李몄뿬�븯怨� �엳�뒗 �봽濡쒖젥�듃瑜� 李얜뒗�떎.
         if (condition.getProjectIds().size() < 1) {
-            List<Map<String, Object>> projects = this.projectService.findByWorkspaceIdAndIncludeProjectAll(projectStatues, condition.getProjectType());
-            List<Long> projectIds = Lists.newArrayList();
+            List<Map<String, Object>> projects = Lists.newArrayList();
+            if (this.userWorkspaceService.checkWorkspaceManager(user) || MngPermission.checkMngPermission(userLevel.getPermission(), MngPermission.USER_PERMISSION_MNG_PROJECT)){
+                return true;
+            }/*else if (MngPermission.checkMngPermission(userLevel.getPermission(), MngPermission.USER_PERMISSION_MNG_ISSUE)){
+                projects = this.projectService.findByWorkspaceIdAndIncludeProjectAll(projectStatues, condition.getProjectType());
+            }*/
+            else {
+                projects = this.projectService.findByWorkspaceIdAndIncludeProject(projectStatues, condition.getProjectType());
+            }
 
+            List<Long> projectIds = Lists.newArrayList();
             for (Map<String, Object> result : projects) {
                 Long projectId = MapUtil.getLong(result, "id");
 
@@ -1288,7 +1299,8 @@
             List<Map<String, Object>> projects = null;
             UserLevel userLevel = this.userLevelService.getUserLevel(user.getUserLevel().getId());
             if (this.userWorkspaceService.checkWorkspaceManager(user)
-                    || MngPermission.checkMngPermission(userLevel.getPermission(), MngPermission.USER_PERMISSION_MNG_ISSUE)) {
+                    || (MngPermission.checkMngPermission(userLevel.getPermission(), MngPermission.USER_PERMISSION_MNG_PROJECT) &&
+                    MngPermission.checkMngPermission(userLevel.getPermission(), MngPermission.USER_PERMISSION_MNG_ISSUE))) {
                 projects = this.projectMapper.findByWorkspaceManagerAll(projectCondition);
             } else  {
                 projects = this.projectService.findByWorkspaceIdAndIncludeProjectAll(projectCondition);
@@ -1521,6 +1533,8 @@
                 this.setRegister(downIssue, downIssueVo); // �벑濡앹옄
                 this.setIssueDepartment(downIssue, downIssueVo);  //  �떞�떦遺��꽌 �젙蹂� �뀑�똿
                 this.setIssueCustomFields(downIssue, downIssueVo);   // �궗�슜�옄�젙�쓽�븘�뱶 �젙蹂� �꽭�똿
+                this.setIssueHistory(downIssue, downIssueVo);   //  �씠�뒋 湲곕줉 �젙蹂� �뀑�똿
+                this.setIssueComments(downIssue, downIssueVo);  //  �뙎湲� �젙蹂� �뀑�똿
 
                 resultList.add(downIssueVo);
             }
@@ -1544,10 +1558,10 @@
         this.setIssueDepartment(issue, issueVo);  //  �떞�떦遺��꽌 �젙蹂� �뀑�똿
         this.setAttachedFiles(issue, issueVo);  //  泥⑤� �뙆�씪 �젙蹂� �뀑�똿
         this.setIssueCustomFields(issue, issueVo);  //  �궗�슜�옄 �젙�쓽 �븘�뱶 媛� �젙蹂� �뀑�똿
-        this.setIssueComments(issue, issueVo);  //  �뙎湲� �젙蹂� �뀑�똿
-        this.setIssueHistory(issue, issueVo);   //  �씠�뒋 湲곕줉 �젙蹂� �뀑�똿
         this.setRelationIssue(issue, issueVo);        //�뿰愿� �씪媛� �뀑�똿
         this.setDownIssues(issue, issueVo); //�븯�쐞 �씪媛� �꽭�똿
+        this.setIssueComments(issue, issueVo);  //  �뙎湲� �젙蹂� �뀑�똿
+        this.setIssueHistory(issue, issueVo);   //  �씠�뒋 湲곕줉 �젙蹂� �뀑�똿
 
         IssueType issueType = this.issueTypeService.getIssueType(issueVo.getIssueTypeVo().getId()); // �씠�뒋�쓽 �씠�뒋�쑀�삎 媛앹껜
         Integer using = issueType.getUsePartner() != null ? issueType.getUsePartner().intValue() : 0; // �씠�뒋�쑀�삎蹂꾨줈 �궗�슜以묒씤 �뾽泥�/ISP/�샇�뒪�똿 媛�
@@ -1729,7 +1743,7 @@
 
     //  �씠�뒋 湲곕줉 �젙蹂대�� �뀑�똿�븳�떎.
     private void setIssueHistory(Issue issue, IssueVo issueVo) {
-        issueVo.setIssueHistoryVos(this.issueHistoryService.findIssueHistory(issue.getId()));
+        issueVo.setIssueHistoryVos(this.issueHistoryService.findIssueHistory(issue));
     }
 
     // �궗�슜�옄 �젙�쓽 �븘�뱶 媛믪씠 媛숈� �씠�뒋 李얘린
@@ -1793,16 +1807,22 @@
                 Issue modifyIssue = this.modifyIssueForApi(user, issueForm, files);
                 Issue parentIssue = modifyIssue.getParentIssue();
                 IssueType issueType = modifyIssue.getIssueType();
-                IssueStatus issueStatus = issueType.getIssueStatus();
+
+                Set<IssueTypeApiEndStatus> issueTypeApiEndStatuses = issueType.getIssueTypeApiEndStatuses();
+                IssueTypeApiEndStatus issueStatus = null;
+                if (issueTypeApiEndStatuses != null && issueTypeApiEndStatuses.size() > 0) {
+                    issueStatus = issueTypeApiEndStatuses.iterator().next();
+                } else {
+                    throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.API_COMPLETE_ISSUE_STATUS_NOT_EXIST));
+                }
+
                 if (parentIssue != null) {
-                    if (issueStatus == null) {
-                        throw new OwlRuntimeException(this.messageAccessor.getMessage(MsgConstants.API_COMPLETE_ISSUE_STATUS_NOT_EXIST));
-                    }
+
                     IssueCondition issueCondition = new IssueCondition(issueVo.getId(), parentIssue.getId());
                     List<Map<String, Object>> results = this.issueMapper.findNotCompleteByParentIssueId(issueCondition);
                     // �븯�쐞 �씪媛먯씠 紐⑤몢 醫낅즺 �긽�깭�씪�븣 �긽�쐞 �씪媛먮룄 醫낅즺 泥섎━
                     if (results == null || results.size() == 0) {
-                        parentIssue.setIssueStatus(issueType.getIssueStatus());
+                        parentIssue.setIssueStatus(issueStatus.getIssueStatus());
                         this.issueRepository.saveAndFlush(parentIssue);
                     }
                 }
@@ -3794,4 +3814,18 @@
             resJsonData.put(Constants.RES_KEY_CONTENTS, usePartnerVos);
         }
     }
+
+    @Override
+    public void findReadyDepartments(Map<String, Object> resJsonData, DepartmentCondition condition, Pageable pageable) {
+        Integer issueStatusId = 1;
+        condition.setIssueStatusId(issueStatusId);
+
+        IssueType issueType = this.issueTypeService.getIssueType(condition.getIssueTypeId());
+        if (issueType != null) {
+            condition.setWorkflowId(issueType.getWorkflow().getId());
+        }
+
+        List<Map<String, Object>> departmentVos = this.departmentMapper.findByIssueStatusId(condition);
+        resJsonData.put(Constants.RES_KEY_CONTENTS, departmentVos);
+    }
 }
\ No newline at end of file

--
Gitblit v1.8.0