| | |
| | | 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.*; |
| | | import kr.wisestone.owl.vo.*; |
| | | import kr.wisestone.owl.web.condition.UserCondition; |
| | | import kr.wisestone.owl.web.form.DepartmentManagementForm; |
| | | import kr.wisestone.owl.web.form.UserForm; |
| | | import kr.wisestone.owl.web.form.UserLevelForm; |
| | | import kr.wisestone.owl.web.view.ExcelView; |
| | | import org.apache.commons.validator.routines.EmailValidator; |
| | | import org.slf4j.Logger; |
| | |
| | | import org.springframework.security.core.session.SessionRegistry; |
| | | import org.springframework.security.core.userdetails.UserDetails; |
| | | import org.springframework.security.crypto.password.PasswordEncoder; |
| | | import org.springframework.stereotype.Repository; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.ui.Model; |
| | |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | |
| | | import javax.rmi.CORBA.Util; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.*; |
| | | import java.net.HttpURLConnection; |
| | |
| | | private UserRepository userRepository; |
| | | |
| | | @Autowired |
| | | private DepartmentRepository departmentRepository; |
| | | |
| | | @Autowired |
| | | private UserLevelService userLevelService; |
| | | |
| | | @Autowired |
| | | private DepartmentManagementService departmentManagementService; |
| | | private DepartmentService departmentService; |
| | | |
| | | @Autowired |
| | | private SystemRoleService systemRoleService; |
| | |
| | | private ProjectService projectService; |
| | | |
| | | @Autowired |
| | | private IssueTypeService issueTypeService; |
| | | |
| | | @Autowired |
| | | private UserSecurityService userSecurityService; |
| | | |
| | | @Autowired |
| | |
| | | |
| | | @Autowired |
| | | private AttachedFileService attachedFileService; |
| | | |
| | | @Autowired |
| | | private UserDepartmentService userDepartmentService; |
| | | |
| | | @Autowired |
| | | private IssueService issueService; |
| | |
| | | @Value("${total.statistics.email}") |
| | | private String totalStatisticsEmail; // 프로젝트, 이슈, 사용자수 알림 |
| | | |
| | | @Value("${email.joinEmail}") |
| | | private boolean bJoinEmail; |
| | | |
| | | @Autowired |
| | | private ExcelView excelView; |
| | | |
| | |
| | | |
| | | 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);*/ |
| | | |
| | | } 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); |
| | | |
| | | // DepartmentManagement에 임시로 Name, Description 값 추가 |
| | | DepartmentManagementForm departmentManagementForm = new DepartmentManagementForm(); |
| | | this.userLevelService.addNormalAdminUserLevel(); |
| | | |
| | | departmentManagementForm.setDepartmentName("개발팀"); |
| | | departmentManagementForm.setDepartmentDescription("웹사이트 및 앱 서비스 개발"); |
| | | DepartmentManagement departmentManagement = this.departmentManagementService.addDepartment(departmentManagementForm); |
| | | user.setDepartmentId(departmentManagement); |
| | | this.userLevelService.addNormalUserLevel(); |
| | | |
| | | if(primaryWorkspace == null || primaryWorkspace.getName() != userForm.getWorkspaceName()) { |
| | | // 업무 공간를 생성한다. 가입한 사용자는 업무 공간의 주인이다. |
| | |
| | | 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()); |
| | | |
| | |
| | | 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; |
| | | } |
| | | |
| | |
| | | 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); |
| | | } |
| | | |
| | |
| | | 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) |
| | |
| | | this.userRepository.saveAndFlush(user); |
| | | } |
| | | |
| | | // 삭제 할 등급명을 유저가 사용하고 있는지 확인 |
| | | @Override |
| | | public boolean useUserLevel(Long levelId) { |
| | | return this.userMapper.findByLevelId(levelId) > 0; |
| | |
| | | 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) |
| | |
| | | @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"); |
| | | 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)); |
| | |
| | | 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) { |
| | |
| | | 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); |
| | | } |
| | | |
| | | // 전체 사용자, 프로젝트 수, 이슈 수를 이메일로 보낸다. |
| | |
| | | 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); |
| | | } |
| | | |
| | | |