From 58f7308d634e99bf7cf4a88bef75a97c7325454f Mon Sep 17 00:00:00 2001
From: minhee <alsdldlfrl@gmail.com>
Date: 월, 21 2월 2022 11:10:29 +0900
Subject: [PATCH] - 각종 메일 메일 주소 안썼을 경우 테스트(메일주소 없을 경우 예외처리)

---
 src/main/java/kr/wisestone/owl/service/impl/UserServiceImpl.java |  127 ++++++++++++++++++++++++++++++++++--------
 1 files changed, 103 insertions(+), 24 deletions(-)

diff --git a/src/main/java/kr/wisestone/owl/service/impl/UserServiceImpl.java b/src/main/java/kr/wisestone/owl/service/impl/UserServiceImpl.java
index 6d4c5a1..c0041f5 100644
--- a/src/main/java/kr/wisestone/owl/service/impl/UserServiceImpl.java
+++ b/src/main/java/kr/wisestone/owl/service/impl/UserServiceImpl.java
@@ -12,6 +12,7 @@
 import kr.wisestone.owl.domain.enumType.SocialType;
 import kr.wisestone.owl.exception.OwlRuntimeException;
 import kr.wisestone.owl.mapper.UserMapper;
+import kr.wisestone.owl.repository.DepartmentRepository;
 import kr.wisestone.owl.repository.UserRepository;
 import kr.wisestone.owl.service.*;
 import kr.wisestone.owl.util.*;
@@ -55,6 +56,9 @@
     private UserRepository userRepository;
 
     @Autowired
+    private DepartmentRepository departmentRepository;
+
+    @Autowired
     private UserLevelService userLevelService;
 
     @Autowired
@@ -88,6 +92,9 @@
     private ProjectService projectService;
 
     @Autowired
+    private IssueTypeService issueTypeService;
+
+    @Autowired
     private UserSecurityService userSecurityService;
 
     @Autowired
@@ -98,6 +105,9 @@
 
     @Autowired
     private AttachedFileService attachedFileService;
+
+    @Autowired
+    private UserDepartmentService userDepartmentService;
 
     @Autowired
     private IssueService issueService;
@@ -231,6 +241,13 @@
             /*user.setPermission(MngPermission.USER_PERMISSION_MNG_NONE);*/
 
         } else if(validAdmin == 1) {    // �씪�씠�꽱�뒪 �엯�젰 愿�由ъ옄
+
+            /*DepartmentForm departmentForm = new DepartmentForm();
+
+            departmentForm.setDepartmentName("遺��꽌 �뾾�쓬");
+            Department department = this.departmentService.add(departmentForm);
+            this.departmentRepository.saveAndFlush(department);*/
+
             Workspace primaryWorkspace = this.workspaceService.getPrimaryWorkspace();
 
             UserLevel userLevel = this.userLevelService.addSuperUserLevel();
@@ -246,7 +263,10 @@
                 this.userWorkspaceService.addUserWorkspace(user, workspace, true, true);
 
                 //  湲곕낯�쑝濡� �젣怨듬릺�뒗 �봽濡쒖젥�듃瑜� �깮�꽦�븳�떎.
-//                this.projectService.addDefaultProject(user, workspace);
+                this.projectService.addDefaultProject(user, workspace);
+
+                // 湲곕낯�쑝濡� �젣怨듬릺�뒗 �봽濡쒖젥�듃瑜� �씠�뒋 �쑀�삎�쓽 �궗�슜 �봽濡쒖젥�듃濡� �꽕�젙
+                this.issueTypeService.addDefaultUsedProject(workspace);
 
                 user.setLastWorkspaceId(workspace.getId());
 
@@ -258,13 +278,6 @@
                 /*user.setPermission(MngPermission.makeSubAllPermission());*/
             }
         }
-
-//        DepartmentManageForm departmentManageForm = new DepartmentManageForm();
-//
-//        departmentManageForm.setDepartmentName("遺��꽌 �뾾�쓬");
-//        DepartmentManage departmentManage = this.departmentManageService.addDepartmentManage(departmentManageForm);
-//        user.setDepartmentManage(departmentManage);
-
         this.userRepository.saveAndFlush(user);
 
         //  �씠硫붿씪 �븣由� �삁�젙 �떆媛꾩씠 怨듬갚�씠硫� �뵒�뤃�듃 �씠硫붿씪 �븣由� �삁�젙 �떆媛꾩쑝濡� �꽕�젙�븳�떎.
@@ -536,8 +549,12 @@
             User user = this.getUser(userCondition.getId());
             userVo = ConvertUtil.copyProperties(user, UserVo.class, "password");
             userVo.setAccount(CommonUtil.decryptAES128(userVo.getAccount()));
-        }
 
+            Map<String, Object> projectManagerYN = this.projectRoleUserService.findProjectManager((userCondition.getId()));
+            if(projectManagerYN != null){
+                userVo.setProjectManagerYN(true);
+            }
+        }
         resJsonData.put(Constants.RES_KEY_CONTENTS, userVo);
     }
 
@@ -944,6 +961,15 @@
         return this.convertUserVoToMap(results, totalUsersCount, pageable, resJsonData);
     }
 
+    //  �궗�슜�옄 �젙蹂대�� 媛��졇�삩�떎.
+    @Override
+    @Transactional(readOnly = true)
+    public void findMyLevelAndDepartment(Map<String, Object> resJsonData) {
+        Long loginId = this.webAppUtil.getLoginId();
+        Map<String, Object> result = this.userMapper.findByMyLevelAndDepartment(loginId);
+        resJsonData.put(Constants.RES_KEY_CONTENTS, result);
+    }
+
     //  �궗�슜�옄 �븘�씠�뵒濡� �궗�슜�옄瑜� 議고쉶�븳�떎.
     @Override
     @Transactional(readOnly = true)
@@ -1059,6 +1085,30 @@
         resJsonData.put(Constants.RES_KEY_CONTENTS, userVo);
     }
 
+    //  留덉�留됱쑝濡� �꽑�깮�븳 �씠�뒋 ���엯 �젙蹂대�� ���옣�븳�떎.
+    @Override
+    @Transactional
+    public void updateLastIssueType(Map<String, Object> resJsonData, UserForm userForm) {
+        User user = this.getUser(this.webAppUtil.getLoginId());
+
+        if (userForm.getLastIssueTypeId() != null) {
+            user.setLastIssueTypeId(userForm.getLastIssueTypeId());
+        }
+
+        this.userRepository.saveAndFlush(user);
+        //  �꽭�뀡 �뾽�뜲�씠�듃
+        SecurityUtils.setUserToSession(user);
+        //  �겢�씪�씠�뼵�듃�쓽 �궗�슜�옄 �젙蹂� �뾽�뜲�씠�듃
+        UserVo userVo = ConvertUtil.copyProperties(user, UserVo.class, "password");
+
+        if (user.getSocialType() != null) {
+            userVo.setSocialType(user.getSocialType().toString());
+        }
+
+        userVo.setAccount(CommonUtil.decryptAES128(userVo.getAccount()));
+
+        resJsonData.put(Constants.RES_KEY_CONTENTS, userVo);
+    }
     //  �듅�젙 �븘�씠�뵒�뿉 �빐�떦�븯�뒗 �궗�슜�옄 紐⑸줉�쓣 媛��졇�삩�떎.
     @Override
     @Transactional(readOnly = true)
@@ -1194,10 +1244,19 @@
     @Transactional(readOnly = true)
     public User getUserSession(Map<String, Object> resJsonData, HttpServletRequest httpServletRequest) {
         User user = this.getUser(this.webAppUtil.getLoginId());
-        UserVo userVo = ConvertUtil.copyProperties(user, UserVo.class, "password","permission"); // wyu - ignores permission ??
+        UserVo userVo = ConvertUtil.copyProperties(user, UserVo.class, "password");
         // user�뿉�꽌 Permission 媛믪쓣 媛��졇���꽌 userVo �뿉 setPermission �븿
-        userVo.setPermission(user.getPermission());
         userVo.setAccount(CommonUtil.decryptAES128(userVo.getAccount()));
+
+        UserLevel userLevel = user.getUserLevel();
+        if (userLevel != null) {
+            userVo.setLevelName(userLevel.getLevelName());
+        }
+
+        List<Department> departments = this.userDepartmentService.findDepartment(user.getId());
+        if (departments != null) {
+            userVo.setDepartmentVos(ConvertUtil.convertObjectsToClasses(departments, DepartmentVo.class));
+        }
         resJsonData.put(Constants.RES_KEY_CONTENTS, userVo);
         //  �궗�슜�옄 �꽭�뀡 �젙蹂대�� 遺꾩꽍�빐�꽌 濡쒓렇�뿉 �궓湲대떎.
         log.info(ElasticSearchUtil.makeUserSessionHistoryMessage(httpServletRequest, userVo));
@@ -1223,6 +1282,22 @@
         conditions.put("endTime", DateUtil.convertDateToStr(endCal.getTime(), "HH:mm"));
 
         List<Map<String, Object>> users = this.userMapper.findByReservationNotifyTime(conditions);
+        List<String> results = Lists.newArrayList();
+
+        for (Map<String, Object> user : users) {
+            results.add(MapUtil.getString(user, "account"));
+        }
+
+        return results;
+    }
+
+    //  �씠硫붿씪 �븣由� �삁�젙 �떆媛꾩쓣 �떎�떆媛꾩쑝濡� �꽕�젙�븳 �궗�슜�옄瑜� 議고쉶�븳�떎.
+    @Override
+    @Transactional(readOnly = true)
+    public List<String> findByRealTimeNotifyTime() {
+        Map<String, Object> conditions = new HashMap<>();
+
+        List<Map<String, Object>> users = this.userMapper.findByRealTimeNotifyTime(conditions);
         List<String> results = Lists.newArrayList();
 
         for (Map<String, Object> user : users) {
@@ -1298,15 +1373,17 @@
         userMap.put("newUserCount", joinUsers.size());
         userMap.put("joinUsers", userVos);
 
-        String[] sendEmails = this.userJoinStatisticsEmail.replaceAll("\\p{Z}", "").split(",");
-        List<String> encryptSendEmail = Lists.newArrayList();
+        if (this.userJoinStatisticsEmail != null && !this.userJoinStatisticsEmail.equals("")) {
+            String[] sendEmails = this.userJoinStatisticsEmail.replaceAll("\\p{Z}", "").split(",");
+            List<String> encryptSendEmail = Lists.newArrayList();
 
-        for (String sendEmail : sendEmails) {
-            encryptSendEmail.add(CommonUtil.encryptAES128(sendEmail));
+            for (String sendEmail : sendEmails) {
+                encryptSendEmail.add(CommonUtil.encryptAES128(sendEmail));
+            }
+            //  寃곗젣 �꽦怨� 硫붿씪 諛쒖넚
+            this.systemEmailService.directEmail(encryptSendEmail.toArray(new String[encryptSendEmail.size()]), EmailType.USER_JOIN_STATISTICS, userMap, null);
         }
 
-        //  寃곗젣 �꽦怨� 硫붿씪 諛쒖넚
-        this.systemEmailService.directEmail(encryptSendEmail.toArray(new String[encryptSendEmail.size()]), EmailType.USER_JOIN_STATISTICS, userMap, null);
     }
 
     //  �쟾泥� �궗�슜�옄, �봽濡쒖젥�듃 �닔, �씠�뒋 �닔瑜� �씠硫붿씪濡� 蹂대궦�떎.
@@ -1324,15 +1401,17 @@
         userMap.put("projectCount", CommonUtil.getDecimalFormat(projectCount));
         userMap.put("userCount", CommonUtil.getDecimalFormat(activeUsers.size()));
 
-        String[] sendEmails = this.totalStatisticsEmail.replaceAll("\\p{Z}", "").split(",");
-        List<String> encryptSendEmail = Lists.newArrayList();
+        if (this.totalStatisticsEmail != null && !this.totalStatisticsEmail.equals("")) {
+            String[] sendEmails = this.totalStatisticsEmail.replaceAll("\\p{Z}", "").split(",");
+            List<String> encryptSendEmail = Lists.newArrayList();
 
-        for (String sendEmail : sendEmails) {
-            encryptSendEmail.add(CommonUtil.encryptAES128(sendEmail));
+            for (String sendEmail : sendEmails) {
+                encryptSendEmail.add(CommonUtil.encryptAES128(sendEmail));
+            }
+
+            //  寃곗젣 �꽦怨� 硫붿씪 諛쒖넚
+            this.systemEmailService.directEmail(encryptSendEmail.toArray(new String[encryptSendEmail.size()]), EmailType.TOTAL_STATISTICS, userMap, null);
         }
-
-        //  寃곗젣 �꽦怨� 硫붿씪 諛쒖넚
-        this.systemEmailService.directEmail(encryptSendEmail.toArray(new String[encryptSendEmail.size()]), EmailType.TOTAL_STATISTICS, userMap, null);
     }
 
 

--
Gitblit v1.8.0