From 174dc12380c54730014e86c8897be16389fc804f Mon Sep 17 00:00:00 2001 From: 박지현 <jhpark@maprex.co.kr> Date: 월, 21 2월 2022 11:42:38 +0900 Subject: [PATCH] Merge branch 'master' of http://maprex.iptime.org:9001/r/owl-kisa --- src/main/java/kr/wisestone/owl/service/impl/UserServiceImpl.java | 165 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 140 insertions(+), 25 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 bf2204e..6850762 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,15 @@ private UserRepository userRepository; @Autowired + private DepartmentRepository departmentRepository; + + @Autowired + private UserLevelService userLevelService; + + @Autowired + private DepartmentService departmentService; + + @Autowired private SystemRoleService systemRoleService; @Autowired @@ -82,6 +92,9 @@ private ProjectService projectService; @Autowired + private IssueTypeService issueTypeService; + + @Autowired private UserSecurityService userSecurityService; @Autowired @@ -92,6 +105,9 @@ @Autowired private AttachedFileService attachedFileService; + + @Autowired + private UserDepartmentService userDepartmentService; @Autowired private IssueService issueService; @@ -156,6 +172,9 @@ @Value("${total.statistics.email}") private String totalStatisticsEmail; // �봽濡쒖젥�듃, �씠�뒋, �궗�슜�옄�닔 �븣由� + @Value("${email.joinEmail}") + private boolean bJoinEmail; + @Autowired private ExcelView excelView; @@ -197,7 +216,8 @@ user.setAccount(CommonUtil.encryptAES128(userForm.getAccount())); user.setPassword(this.passwordEncoder.encode(user.getPassword())); - this.userRepository.saveAndFlush(user); + //this.userLevelRepository.saveAndFlush(user); + //userLevelRepository.saveAndFlush(user); // �봽濡쒗븘 �뙆�씪�씠 �쑀�슚�븳吏� 泥댄겕�븳�떎. this.verifyProfile(profile); @@ -217,11 +237,28 @@ this.userInviteService.includePrimaryWorkspace(user, primaryWorkspace); + UserLevel userLevel = this.userLevelService.getBasicUserLevel(); + user.setUserLevel(userLevel); + // edit by zenith for permission at 20200803 - user.setPermission(MngPermission.USER_PERMISSION_MNG_NONE); + /*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(); + user.setUserLevel(userLevel); + + this.userLevelService.addNormalAdminUserLevel(); + + this.userLevelService.addNormalUserLevel(); if(primaryWorkspace == null || primaryWorkspace.getName() != userForm.getWorkspaceName()) { // �뾽臾� 怨듦컙瑜� �깮�꽦�븳�떎. 媛��엯�븳 �궗�슜�옄�뒗 �뾽臾� 怨듦컙�쓽 二쇱씤�씠�떎. @@ -229,23 +266,25 @@ 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()); // edit by zenith for permission at 20200803 - user.setPermission(MngPermission.makeAllPermission()); + //user.setPermission(MngPermission.makeAllPermission()); } else { this.userInviteService.includePrimaryWorkspace(user, primaryWorkspace); user.setLastWorkspaceId(primaryWorkspace.getId()); - - user.setPermission(MngPermission.makeSubAllPermission()); + /*user.setPermission(MngPermission.makeSubAllPermission());*/ } } + this.userRepository.saveAndFlush(user); // �씠硫붿씪 �븣由� �삁�젙 �떆媛꾩씠 怨듬갚�씠硫� �뵒�뤃�듃 �씠硫붿씪 �븣由� �삁�젙 �떆媛꾩쑝濡� �꽕�젙�븳�떎. user.setReservationNotifyTime(User.DEFAULT_RESERVATION_NOTIFY_TIME); - this.userRepository.saveAndFlush(user); // 珥덈�諛쏆� 硫붿씪�씠 �엳�뒗 �궗�슜�옄媛� 媛��엯�뻽�쑝硫� 珥덈��뻽�쓣 �븣 �꽑�깮�븳 �봽濡쒖젥�듃�뿉 李몄뿬 �떆�궓�떎. this.userInviteService.checkInviteUser(user); @@ -256,8 +295,9 @@ userMap.put("registerDate", DateUtil.convertDateToYYYYMMDD(user.getRegisterDate())); // �쉶�썝 媛��엯 �븣由� 硫붿씪 �쟾�넚 - this.systemEmailService.directEmail(new String[]{user.getAccount()}, EmailType.WORKSPACE_JOIN, userMap, null); - + if(bJoinEmail) { + this.systemEmailService.directEmail(new String[]{user.getAccount()}, EmailType.WORKSPACE_JOIN, userMap, null); + } return user; } @@ -513,8 +553,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); } @@ -921,6 +965,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) @@ -1005,7 +1058,13 @@ this.userRepository.saveAndFlush(user); } - // 留덉�留됱쑝濡� �꽑�깮�븳 �봽濡쒖젥�듃 �젙蹂대�� ���옣�븳�떎. + // �궘�젣 �븷 �벑湲됰챸�쓣 �쑀��媛� �궗�슜�븯怨� �엳�뒗吏� �솗�씤 + @Override + public boolean useUserLevel(Long levelId) { + return this.userMapper.findByLevelId(levelId) > 0; + } + + // 留덉�留됱쑝濡� �꽑�깮�븳 �봽濡쒖젥�듃 �젙蹂대�� ���옣�븳�떎. @Override @Transactional public void updateLastProject(Map<String, Object> resJsonData, UserForm userForm) { @@ -1030,6 +1089,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) @@ -1041,7 +1124,7 @@ @Override @Transactional(readOnly = true) public List<User> findAdmin() { - return this.userRepository.findAdmin(); + return this.userRepository.findAdmin(MngPermission.makeAllPermission()); } // �빐�떦 �궗�슜�옄媛� 愿�由ы븯�뒗 �뾽臾� 怨듦컙�쓣 留덉�留됱쑝濡� �젒洹쇳븳 �뾽臾� 怨듦컙 �젙蹂대줈 �뾽�뜲�씠�듃�븳�떎. @@ -1150,6 +1233,7 @@ } } + // �뾽臾� 怨듦컙�뿉�꽌 �젣�쇅�릺嫄곕굹 �뾽臾� 怨듦컙 �궘�젣�떆 李몄뿬 �궗�슜�옄�뱾�쓽 留덉�留� �젒洹� �뾽臾� 怨듦컙 �젙蹂대줈 �꽭�뀡 �뾽�뜲�씠�듃�븯湲� �쐞�빐 �궗�슜 @Override @Transactional(readOnly = true) @@ -1165,7 +1249,18 @@ public User getUserSession(Map<String, Object> resJsonData, HttpServletRequest httpServletRequest) { User user = this.getUser(this.webAppUtil.getLoginId()); UserVo userVo = ConvertUtil.copyProperties(user, UserVo.class, "password"); + // user�뿉�꽌 Permission 媛믪쓣 媛��졇���꽌 userVo �뿉 setPermission �븿 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)); @@ -1191,6 +1286,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) { @@ -1266,15 +1377,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); } // �쟾泥� �궗�슜�옄, �봽濡쒖젥�듃 �닔, �씠�뒋 �닔瑜� �씠硫붿씪濡� 蹂대궦�떎. @@ -1292,15 +1405,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