From b3cb2688f488639f6670883500c417235296cabc Mon Sep 17 00:00:00 2001
From: wyu <kknd09321@nate.com>
Date: 목, 09 12월 2021 17:00:02 +0900
Subject: [PATCH] favicon 수정 , 완료이슈 버튼 수정

---
 src/main/java/kr/wisestone/owl/service/impl/IssueTypeServiceImpl.java |   93 +++++++++++++++++++++++++++++++++++++---------
 1 files changed, 75 insertions(+), 18 deletions(-)

diff --git a/src/main/java/kr/wisestone/owl/service/impl/IssueTypeServiceImpl.java b/src/main/java/kr/wisestone/owl/service/impl/IssueTypeServiceImpl.java
index 0c425db..0c3b5b1 100644
--- a/src/main/java/kr/wisestone/owl/service/impl/IssueTypeServiceImpl.java
+++ b/src/main/java/kr/wisestone/owl/service/impl/IssueTypeServiceImpl.java
@@ -3,9 +3,8 @@
 import com.google.common.collect.Lists;
 import kr.wisestone.owl.common.ExcelConditionCheck;
 import kr.wisestone.owl.constant.Constants;
-import kr.wisestone.owl.constant.MngPermission;
 import kr.wisestone.owl.constant.MsgConstants;
-import kr.wisestone.owl.constant.UseCompany;
+import kr.wisestone.owl.constant.UsePartner;
 import kr.wisestone.owl.domain.*;
 import kr.wisestone.owl.domain.enumType.ProjectType;
 import kr.wisestone.owl.exception.OwlRuntimeException;
@@ -13,6 +12,7 @@
 import kr.wisestone.owl.repository.IssueTypeRepository;
 import kr.wisestone.owl.service.*;
 import kr.wisestone.owl.util.ConvertUtil;
+import kr.wisestone.owl.util.MapUtil;
 import kr.wisestone.owl.vo.*;
 import kr.wisestone.owl.web.condition.IssueTypeCondition;
 import kr.wisestone.owl.web.form.IssueTypeForm;
@@ -51,13 +51,7 @@
     private WorkspaceService workspaceService;
 
     @Autowired
-    private CompanyFieldService companyFieldService;
-
-    @Autowired
-    private IspFieldService ispFieldService;
-
-    @Autowired
-    private HostingFieldService hostingFieldService;
+    private IssueStatusService issueStatusService;
 
     @Autowired
     private IssueTypeMapper issueTypeMapper;
@@ -86,6 +80,8 @@
         for (ProjectType projectType : projectTypes) {
             List<IssueType> issueTypes = Lists.newArrayList();
             Workflow workflow = this.workflowService.findByWorkspaceIdAndProjectType(workspace.getId(), projectType);
+            //String projectKey = "BTS";
+            //Project project = this.projectService.findByProjectKey(projectKey);
 
             switch (projectType) {
                 case BTS_PROJECT:
@@ -125,7 +121,7 @@
         Project project = this.projectService.getProject(issueTypeForm.getProjectId());
         issueType.setProject(project);
 
-        issueType.setUseCompany(issueTypeForm.getUseCompany());
+        issueType.setUsePartner(issueTypeForm.getUsePartner());
 
         return this.issueTypeRepository.saveAndFlush(issueType);
     }
@@ -174,10 +170,30 @@
         condition.setPage(pageable.getPageNumber() * pageable.getPageSize());
         condition.setPageSize(pageable.getPageSize());
         condition.setWorkspaceId(this.userService.getUser(this.webAppUtil.getLoginId()).getLastWorkspaceId());
+
         List<Map<String, Object>> results = this.issueTypeMapper.find(condition);
+        for (Map<String, Object> result : results) {
+            Long projectId = MapUtil.getLong(result, "projectId");
+            if (projectId != null) {
+                Project project = this.projectService.getProject(projectId);
+                ProjectVo projectVo = ConvertUtil.copyProperties(project, ProjectVo.class);
+                result.put("projectVo", projectVo);
+
+            }
+            Long issueStatusId = MapUtil.getLong(result, "completeIssueStatusId");
+            if (issueStatusId != null) {
+                IssueStatus issueStatus = this.issueStatusService.getIssueStatus(issueStatusId);
+                IssueStatusVo issueStatusVo = ConvertUtil.copyProperties(issueStatus, IssueStatusVo.class);
+                result.put("completeIssueStatusVo", issueStatusVo);
+            }
+        }
+
         Long totalCount = this.issueTypeMapper.count(condition);
         int totalPage = (int) Math.ceil((totalCount - 1) / pageable.getPageSize()) + 1;
         List<IssueTypeVo> issueTypeVos = ConvertUtil.convertListToListClass(results, IssueTypeVo.class);
+//        for (IssueTypeVo issueTypeVo : issueTypeVos) {
+//
+//        }
 
         //  �씠�뒋 �쑀�삎�뿉 �뿰寃곕맂 �썙�겕�뵆濡쒖슦 �젙蹂대�� �뀑�똿�븳�떎.
         if (condition.getDeep() != null) {
@@ -185,6 +201,7 @@
         }
 
         this.setUseIssueTypeByProject(issueTypeVos);
+        this.setUseIssueTypeByIssueStatus(issueTypeVos);
         /*this.setUseIssueTypeByCompanyField(issueTypeVos);
         this.setUseIssueTypeByIspField(issueTypeVos);
         this.setUseIssueTypeByHostingField(issueTypeVos);*/
@@ -195,6 +212,15 @@
         resJsonData.put(Constants.RES_KEY_CONTENTS, issueTypeVos);
 
         return issueTypeVos;
+    }
+
+    //  �씠�뒋 �쑀�삎 紐⑸줉�쓣 議고쉶�븳�떎.
+    @Override
+    @Transactional(readOnly = true)
+    public List<IssueTypeVo> findIssueType(IssueTypeCondition condition) {
+        condition.setWorkspaceId(this.userService.getUser(this.webAppUtil.getLoginId()).getLastWorkspaceId());
+        List<Map<String, Object>> results = this.issueTypeMapper.find(condition);
+        return ConvertUtil.convertListToListClass(results, IssueTypeVo.class);
     }
 
     //  �씠�뒋 �쑀�삎�뿉 �뿰寃곕맂 �썙�겕�뵆濡쒖슦 �젙蹂대�� �뀑�똿�븳�떎.
@@ -213,6 +239,17 @@
             Project project = issueType.getProject();
             if (project != null) {
                 issueTypeVo.setProjectVo(ConvertUtil.copyProperties(issueType.getProject(), ProjectVo.class));
+            }
+        }
+    }
+
+    private void setUseIssueTypeByIssueStatus(List<IssueTypeVo> issueTypeVos) {
+        for (IssueTypeVo issueTypeVo : issueTypeVos) {
+            IssueType issueType = this.getIssueType(issueTypeVo.getId());
+
+            IssueStatus issueStatus = issueType.getIssueStatus();
+            if (issueStatus != null) {
+                issueTypeVo.setCompleteIssueStatusVo(ConvertUtil.copyProperties(issueType.getIssueStatus(), IssueStatusVo.class));
             }
         }
     }
@@ -249,20 +286,40 @@
             if (project != null) {
                 issueTypeVo.setProjectVo(ConvertUtil.copyProperties(issueType.getProject(), ProjectVo.class));
             }
-            Integer using = issueType.getUseCompany() != null ? issueType.getUseCompany().intValue() : 0;
+            Integer using = issueType.getUsePartner() != null ? issueType.getUsePartner().intValue() : 0;
 
-            List<UseCompanyVo> useCompanyVos = Lists.newArrayList();
-            for (Integer useAbleCompany : UseCompany.useCompanies) {// 1 // 2 // 4
-                UseCompanyVo useCompanyVo = UseCompany.checkUseCompany(using, useAbleCompany);//3, 1 / 3, 2 / 3, 4
+            List<UsePartnerVo> usePartnerVos = Lists.newArrayList();
+            for (Integer usePartner : UsePartner.partners) {// 1 // 2 // 4
+                UsePartnerVo usePartnerVo = UsePartner.checkUsePartner(using, usePartner);//3, 1 / 3, 2 / 3, 4
 
-                if (useCompanyVo != null) {
-                    useCompanyVos.add(useCompanyVo);
+                if (usePartnerVo != null) {
+                    usePartnerVos.add(usePartnerVo);
                 }
             }
-            issueTypeVo.setUseCompanyVos(useCompanyVos);
+            issueTypeVo.setUsePartnerVos(usePartnerVos);
         }
 
         resJsonData.put(Constants.RES_KEY_CONTENTS, issueTypeVo);
+    }
+
+    // �씠�뒋 �쑀�삎�쓣 �닔�젙�븳�떎. �옄�룞 醫낅즺 �꽕�젙留� �닔�젙
+    @Override
+    @Transactional
+    public IssueType modifyIssueTypeCompleteIssueStatus(IssueTypeForm issueTypeForm) {
+        //  �궗�슜�븯怨� �엳�뒗 �뾽臾� 怨듦컙�씠 �솢�꽦 �긽�깭�씤吏� �솗�씤�븳�떎. �궗�슜 怨듦컙�뿉�꽌 濡쒓렇�씤�븳 �궗�슜�옄媛� 鍮꾪솢�꽦�씤吏� �솗�씤�븳�떎.
+        this.workspaceService.checkUseWorkspace();
+
+        IssueType issueType = this.getIssueType(issueTypeForm.getId());
+        if (issueTypeForm.getCompleteIssueStatusId() != null) {
+            // api�뿉�꽌 �궗�슜�븯�뒗 �옄�룞 醫낅즺 �씠�뒋 �긽�깭
+            IssueStatus issueStatus = this.issueStatusService.getIssueStatus(issueTypeForm.getCompleteIssueStatusId());
+            issueType.setIssueStatus(issueStatus);
+        }else {
+            issueType.setIssueStatus(null);
+        }
+
+        this.issueTypeRepository.saveAndFlush(issueType);
+        return issueType;
     }
 
     //  �씠�뒋 �쑀�삎�쓣 �닔�젙�븳�떎.
@@ -288,7 +345,7 @@
         Project project = this.projectService.getProject(issueTypeForm.getProjectId());
         issueType.setProject(project);
 
-        issueType.setUseCompany(issueTypeForm.getUseCompany());
+        issueType.setUsePartner(issueTypeForm.getUsePartner());
 
         /*if(issueTypeForm.getCompanyId() != null){
             CompanyField companyField = this.companyFieldService.getCompany(issueTypeForm.getCompanyId());

--
Gitblit v1.8.0