From d78323a9138aab73f9f1b25e0a74283780176452 Mon Sep 17 00:00:00 2001
From: 이민희 <mhlee@maprex.co.kr>
Date: 목, 09 12월 2021 20:43:47 +0900
Subject: [PATCH] - 이슈전체보기/이슈프로젝트보기 권한 생성 - 워크스페이스 권한을 가진 사용자 OWL정보 오류 해결

---
 src/main/java/kr/wisestone/owl/util/CommonUtil.java |   71 +++++++++++++++++++++++++++++++++++
 1 files changed, 71 insertions(+), 0 deletions(-)

diff --git a/src/main/java/kr/wisestone/owl/util/CommonUtil.java b/src/main/java/kr/wisestone/owl/util/CommonUtil.java
index 0fac1dd..5659bfd 100644
--- a/src/main/java/kr/wisestone/owl/util/CommonUtil.java
+++ b/src/main/java/kr/wisestone/owl/util/CommonUtil.java
@@ -6,6 +6,7 @@
 import com.google.gson.Gson;
 import kr.wisestone.owl.domain.enumType.FileType;
 import kr.wisestone.owl.type.LikeType;
+import kr.wisestone.owl.vo.DepartmentVo;
 import kr.wisestone.owl.vo.UserVo;
 import org.apache.commons.codec.binary.*;
 import org.apache.commons.codec.binary.Base64;
@@ -343,6 +344,24 @@
         return fileMap;
     }
 
+    //  string file �젙蹂대�� file Map �삎�깭濡� 蹂�寃쏀븳�떎.
+    public static Map<String, Object> makeFileMap(String fileName, String file, String contentType) {
+        Map<String, Object> fileMap = new HashMap<>();
+
+        try {
+            byte[] bytes = Base64.decodeBase64(file);
+
+            fileMap.put("fileName", fileName);
+            fileMap.put("fileSize", bytes.length);
+            fileMap.put("contentType", contentType);
+            fileMap.put("file", CommonUtil.bytesToFile(fileName, bytes));
+        } catch (Exception e) {
+            LOGGER.debug(e.getMessage());
+        }
+
+        return fileMap;
+    }
+
     public static String getPostDataString(Map<String, String> params) throws UnsupportedEncodingException {
         StringBuilder result = new StringBuilder();
         boolean first = true;
@@ -372,6 +391,42 @@
             multipart.transferTo(convertFile);
         } catch (IllegalStateException | IOException e) {
             LOGGER.debug("multipart �뙆�씪 file 蹂��솚 �삤瑜�");
+        }
+
+        return convertFile;
+    }
+
+    // string�쓣 �뙆�씪濡� 蹂��솚
+    public static File stringToFile(String fileName, String file) {
+
+        byte[] bytes = null;
+        try {
+            bytes = Base64.decodeBase64(file);
+
+        } catch (Exception ex) {
+            LOGGER.debug("string to bytes 蹂��솚 �삤瑜�");
+        }
+
+        if (bytes != null) {
+            return bytesToFile(fileName, bytes);
+        }
+        return  null;
+    }
+
+    // bytes瑜� �뙆�씪濡� 蹂��솚
+    public static File bytesToFile(String fileName, byte[] bytes) {
+        File convertFile = new File(WebAppUtil.getContextRealPath() + TMP_UPLOAD_FOLDER + getFileNameByUUID(fileName));
+        if (!convertFile.exists()) {
+            convertFile.mkdirs();
+        }
+
+        try{
+            FileOutputStream lFileOutputStream = new FileOutputStream(convertFile);
+            lFileOutputStream.write(bytes);
+            lFileOutputStream.close();
+
+        }catch (IllegalStateException | IOException e) {
+            LOGGER.debug("bytes �뙆�씪 file 蹂��솚 �삤瑜�");
         }
 
         return convertFile;
@@ -690,6 +745,22 @@
         return stringBuilder.toString();
     }
 
+    //  DepartmentVos �뿉�꽌 遺��꽌 �젙蹂대�� 異붿텧�빐�꽌 臾몄옄�뿴濡� 由ы꽩�빐以��떎. - 二쇰줈 �뿊�� download �뿉�꽌 �궗�슜�맂�떎.
+    public static String convertDepartmentVosToString(List<DepartmentVo> departmentVos) {
+        StringBuilder stringBuilder = new StringBuilder();
+        int count = 0;
+
+        for (DepartmentVo departmentVo : departmentVos) {
+            if (count > 0) {
+                stringBuilder.append("\n");
+            }
+
+            stringBuilder.append(departmentVo.getDepartmentName());
+            count++;
+        }
+        return stringBuilder.toString();
+    }
+
     //  寃��깋 �씪�옄瑜� 援ы븳�떎.
     public static List<Date> findSearchPeriod(String searchPeriod) {
         List<Date> searchDates = Lists.newArrayList();

--
Gitblit v1.8.0