| | |
| | | import kr.wisestone.owl.domain.Department; |
| | | import kr.wisestone.owl.domain.SystemEmail; |
| | | import kr.wisestone.owl.domain.User; |
| | | import kr.wisestone.owl.domain.UserDepartment; |
| | | import kr.wisestone.owl.domain.enumType.EmailType; |
| | | import kr.wisestone.owl.exception.OwlRuntimeException; |
| | | import kr.wisestone.owl.repository.SystemEmailRepository; |
| | | import kr.wisestone.owl.service.SystemEmailService; |
| | | import kr.wisestone.owl.service.UserDepartmentService; |
| | | import kr.wisestone.owl.service.UserService; |
| | | import kr.wisestone.owl.util.*; |
| | | import org.apache.commons.io.FilenameUtils; |
| | |
| | | |
| | | @Autowired |
| | | private SpringTemplateEngine springTemplateEngine; |
| | | |
| | | @Autowired |
| | | private UserDepartmentService userDepartmentService; |
| | | |
| | | @Override |
| | | protected JpaRepository<SystemEmail, Long> getRepository() { |
| | |
| | | this.sendEmail(this.messageAccessor.message(mailConstants.getTitle(), locale), content, sendUsers, filePaths); |
| | | } |
| | | |
| | | // 이메일 템플릿 찾기 |
| | | public String makeEmailContent(EmailType emailType, Map<String, Object> params) { |
| | | MailConstants mailConstants = null; |
| | | Context context; |
| | | String content = null; |
| | | //params.put("url", this.commonConfiguration.getEmailSendUrl()); |
| | | |
| | | Locale locale = Locale.getDefault(); |
| | | |
| | | switch (emailType) { |
| | | case ISSUE_SEND_1: // 이슈 이메일 템플릿1로 대상자에게 발송 |
| | | mailConstants = MailConstants.ISSUE_SEND_1; |
| | | context = StringTemplateUtil.makeContext(params, locale); |
| | | content = this.springTemplateEngine.process(mailConstants.getMailTemplate(), context); |
| | | break; |
| | | |
| | | case ISSUE_SEND_2: // 이슈 이메일 템플릿2로 대상자에게 발송 |
| | | mailConstants = MailConstants.ISSUE_SEND_2; |
| | | context = StringTemplateUtil.makeContext(params, locale); |
| | | content = this.springTemplateEngine.process(mailConstants.getMailTemplate(), context); |
| | | break; |
| | | |
| | | case ISSUE_SEND_3: // 이슈 이메일 템플릿3로 대상자에게 발송 |
| | | mailConstants = MailConstants.ISSUE_SEND_3; |
| | | context = StringTemplateUtil.makeContext(params, locale); |
| | | content = this.springTemplateEngine.process(mailConstants.getMailTemplate(), context); |
| | | break; |
| | | } |
| | | return content; |
| | | } |
| | | |
| | | |
| | | // 이메일을 발송한다. |
| | | @Override |
| | | @Transactional(readOnly = true) |
| | |
| | | } |
| | | |
| | | if (excludeCheck) { |
| | | /*List<UserDepartment> userDepartments = this.userDepartmentService.getUserDepartments(department.getId()); |
| | | if(userDepartments != null){ |
| | | for (UserDepartment userDepartment : userDepartments){ |
| | | User user = this.userService.getUser(userDepartment.getUserId()); |
| | | results.add(user.getAccount()); |
| | | } |
| | | }*/ |
| | | results.add(department.getDepartmentName()); |
| | | } |
| | | } |