Commit e7dbe456 authored by shishir suman's avatar shishir suman
Browse files

Merge remote-tracking branch 'origin/main'

Showing with 426 additions and 10 deletions
+426 -10
......@@ -102,6 +102,11 @@
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-velocity</artifactId>
<version>1.4.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
......
package org.upsmf.grievance;
import org.apache.velocity.app.VelocityEngine;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.scheduling.annotation.EnableScheduling;
......@@ -14,4 +16,16 @@ public class GrievanceServiceApplication {
SpringApplication.run(GrievanceServiceApplication.class, args);
}
@Bean
public VelocityEngine velocityEngine() {
VelocityEngine engine = new VelocityEngine();
engine.setProperty("resource.loader", "class");
engine.setProperty("class.resource.loader.class",
"org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
return engine;
}
}
package org.upsmf.grievance.service;
import org.upsmf.grievance.model.EmailDetails;
import org.upsmf.grievance.model.Ticket;
public interface EmailService {
// Method
// To send a simple email
void sendCreateTicketMail(EmailDetails details, Ticket ticket);
void sendSimpleMail(EmailDetails details);
// Method
......
package org.upsmf.grievance.service.impl;
// Importing required classes
import java.io.File;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import lombok.extern.slf4j.Slf4j;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.FileSystemResource;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.mail.javamail.MimeMessagePreparator;
import org.springframework.stereotype.Service;
import org.upsmf.grievance.model.EmailDetails;
import org.upsmf.grievance.model.Ticket;
import org.upsmf.grievance.service.EmailService;
import org.upsmf.grievance.util.DateUtil;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import java.io.File;
import java.io.StringWriter;
// Annotation
@Service
......@@ -24,9 +31,51 @@ public class EmailServiceImpl implements EmailService {
@Autowired
private JavaMailSender javaMailSender;
@Autowired
private VelocityEngine velocityEngine;
@Value("${spring.mail.username}")
private String sender;
@Override
public void sendCreateTicketMail(EmailDetails details, Ticket ticket) {
// Try block to check for exceptions
try {
MimeMessagePreparator preparator = new MimeMessagePreparator() {
public void prepare(MimeMessage mimeMessage) throws Exception {
MimeMessageHelper message = new MimeMessageHelper(mimeMessage);
message.setTo(details.getRecipient());
message.setSubject(details.getSubject());
VelocityContext velocityContext = new VelocityContext();
velocityContext.put("first_name", ticket.getFirstName());
velocityContext.put("id", ticket.getId());
velocityContext.put("created_date", DateUtil.getFormattedDateInString(ticket.getCreatedDate()));
// TODO
velocityContext.put("signature_name", "U.P. State Medical Faculty");
velocityContext.put("phone", "Phone: (0522) 2238846, 2235964, 2235965, 3302100");
velocityContext.put("mobile", "Mobile : +91-8400955546 / +91-9151024463");
velocityContext.put("fax", "Fax : (0522) 2236600");
velocityContext.put("email", "Email: upmedicalfaculty@upsmfac.org");
velocityContext.put("address", "Address: 5, Sarvpalli, Mall Avenue Road, Lucknow - 226001 (U.P.) India");
StringWriter stringWriter = new StringWriter();
velocityEngine.mergeTemplate("templates/raiser-create-ticket.vm", "UTF-8", velocityContext, stringWriter);
message.setText(stringWriter.toString(), true);
}
};
// Sending the mail
javaMailSender.send(preparator);
log.info("create ticket mail Sent Successfully...");
}
// Catch block to handle the exceptions
catch (Exception e) {
log.error("Error while Sending Mail", e);
}
}
// Method 1
// To send a simple email
@Override
......
......@@ -10,14 +10,12 @@ import org.upsmf.grievance.dto.TicketRequest;
import org.upsmf.grievance.dto.UpdateTicketRequest;
import org.upsmf.grievance.enums.TicketPriority;
import org.upsmf.grievance.enums.TicketStatus;
import org.upsmf.grievance.model.AssigneeTicketAttachment;
import org.upsmf.grievance.model.Comments;
import org.upsmf.grievance.model.RaiserTicketAttachment;
import org.upsmf.grievance.model.Ticket;
import org.upsmf.grievance.model.*;
import org.upsmf.grievance.repository.AssigneeTicketAttachmentRepository;
import org.upsmf.grievance.repository.CommentRepository;
import org.upsmf.grievance.repository.RaiserTicketAttachmentRepository;
import org.upsmf.grievance.repository.es.TicketRepository;
import org.upsmf.grievance.service.EmailService;
import org.upsmf.grievance.service.OtpService;
import org.upsmf.grievance.service.TicketService;
import org.upsmf.grievance.util.DateUtil;
......@@ -60,6 +58,9 @@ public class TicketServiceImpl implements TicketService {
@Value("${feedback.base.url}")
private String feedbackBaseUrl;
@Autowired
private EmailService emailService;
/**
*
* @param ticket
......@@ -83,7 +84,6 @@ public class TicketServiceImpl implements TicketService {
org.upsmf.grievance.model.es.Ticket esticket = convertToESTicketObj(ticket);
// save ticket in ES
esTicketRepository.save(esticket);
// TODO send mail
return psqlTicket;
}
......@@ -120,8 +120,9 @@ public class TicketServiceImpl implements TicketService {
Ticket ticket = createTicketWithDefault(ticketRequest);
// create ticket
ticket = saveWithAttachment(ticket, ticketRequest.getAttachmentUrls());
// TODO get email subject and body from db
otpService.sendGenericEmail(ticketRequest.getEmail(), "Ticket Created", "You ticket is created with ID "+ticket.getId()+" at "+ticket.getCreatedDate());
// send mail
EmailDetails emailDetails = EmailDetails.builder().recipient(ticket.getEmail()).subject("New Complaint Registration").build();
emailService.sendCreateTicketMail(emailDetails, ticket);
return ticket;
}
......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1" name="viewport">
<meta name="x-apple-disable-message-reformatting">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="telephone=no" name="format-detection">
<title></title>
</head>
<body style="background: #fdebe8; padding: 50px">
<div class="es-wrapper-color">
<table class="es-wrapper" width="100%" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="esd-email-paddings" valign="top">
<table class="esd-header-popover es-header" cellspacing="0" cellpadding="0" align="center">
<tbody>
<tr>
<td class="esd-stripe" align="center">
<table class="es-header-body" width="600" cellspacing="0" cellpadding="0" bgcolor="#ffffff" align="center">
<tbody>
<tr>
<td class="es-p20t es-p20r es-p20l esd-structure" align="left">
<table class="es-left" cellspacing="0" cellpadding="0" align="left">
<tbody>
<tr>
<td class="es-m-p0r es-m-p20b esd-container-frame" width="180" valign="top" align="center">
<table width="100%" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td align="center" class="esd-block-image" style="font-size: 0px;"><a target="_blank" href="https:// sitename.org"><img class="adapt-img" src="https://uphrh.in/assets/images/sunbird_logo.png" alt="sitename" style="display: block; width: 350px; padding: 50px 25px;" width="180" title="sitename"></a></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<!--[if mso]></td><td width="20"></td><td width="360" valign="top"><![endif]-->
<table class="es-right" cellspacing="0" cellpadding="0" align="right">
<tbody>
<tr>
<td class="esd-container-frame" width="360" align="left">
<table width="100%" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td align="center" class="esd-empty-container" style="display: none;"></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td>
<table class="es-content" cellspacing="0" cellpadding="0" align="center">
<tbody>
<tr>
<td class="esd-stripe" align="center">
<table class="es-content-body" width="600" cellspacing="0" cellpadding="0" bgcolor="#ffffff" align="center">
<tbody>
<tr>
<td class="es-p20t es-p20r es-p20l esd-structure" align="left">
<table width="100%" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="esd-container-frame" width="560" valign="top" align="center" style="padding: 0 50px;">
<table width="100%" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td align="justify" class="esd-block-text es-m-txt-l">
<p></br></p>
<p>Dear ${first_name},</p>
<p>We hope this email finds you well. We sincerely apologize for any inconvenience you may have experienced, and we appreciate your decision to bring this matter to our attention. Your feedback is essential to us, and we are committed to resolving any issues promptly and effectively.</p>
<p>Please be assured that we have registered your grievance (details below), and our team will thoroughly investigate the matter to understand the root cause and identify the best course of action to resolve it. We aim to respond to your complaint within 7 days.</p>
<p>
<div>Grievance ID: <strong>${id}</strong></div>
<div>Registration Date: <strong>${created_date}</strong></div>
</p>
<p>In the meantime, we request your patience and cooperation as we work towards resolving the issue. Your satisfaction is our top priority, and we will do our utmost to rectify the situation to your complete satisfaction.</p>
<p>If you have any supporting documents or relevant information related to your complaint, please feel free to attach them to this email.</p>
<p>We truly appreciate your understanding and cooperation.</p>
</td>
</tr>
<tr></tr>
<tr>
<td align="left" class="esd-block-text">
<p>Sincerely,</p>
<p>
<div>${signature_name}</div>
<div>${phone}</div>
<div>${mobile}</div>
<div>${fax}</div>
<div>${email}</div>
<div>${address}</div>
</p>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<table class="esd-footer-popover es-footer" cellspacing="0" cellpadding="0" align="center" bgcolor="#fdebe8">
<tbody>
<tr>
<td class="esd-stripe" align="center">
<table class="es-footer-body" width="600" cellspacing="0" cellpadding="0" align="center" bgcolor="#ffffff" style="padding: 100px 50px;">
<tbody>
<tr>
<td class="esd-structure es-p20t es-p20b es-p20r es-p20l" align="left">
<table class="es-left" cellspacing="0" cellpadding="0" align="center">
<tbody>
<tr>
<td class="es-m-p20b esd-container-frame" width="400" align="left">
<table width="100%" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td align="center" class="esd-block-text">
<label _ngcontent-wjh-c12="" class="d-flex flex-w-wrap mb-16 flex-jc-center"><a _ngcontent-wjh-c12="" apptelemetryinteract="" href="/term-of-use.html"> Terms and Privacy </a><span _ngcontent-wjh-c12="">| © 2023, NIRAMAYA</span></label>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1" name="viewport">
<meta name="x-apple-disable-message-reformatting">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="telephone=no" name="format-detection">
<title></title>
</head>
<body style="background: #fdebe8; padding: 50px">
<div class="es-wrapper-color">
<table class="es-wrapper" width="100%" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="esd-email-paddings" valign="top">
<table class="esd-header-popover es-header" cellspacing="0" cellpadding="0" align="center">
<tbody>
<tr>
<td class="esd-stripe" align="center">
<table class="es-header-body" width="600" cellspacing="0" cellpadding="0" bgcolor="#ffffff" align="center">
<tbody>
<tr>
<td class="es-p20t es-p20r es-p20l esd-structure" align="left">
<table class="es-left" cellspacing="0" cellpadding="0" align="left">
<tbody>
<tr>
<td class="es-m-p0r es-m-p20b esd-container-frame" width="180" valign="top" align="center">
<table width="100%" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td align="center" class="esd-block-image" style="font-size: 0px;"><a target="_blank" href="https:// sitename.org"><img class="adapt-img" src="https://uphrh.in/assets/images/sunbird_logo.png" alt="sitename" style="display: block; width: 350px; padding: 50px 25px;" width="180" title="sitename"></a></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<!--[if mso]></td><td width="20"></td><td width="360" valign="top"><![endif]-->
<table class="es-right" cellspacing="0" cellpadding="0" align="right">
<tbody>
<tr>
<td class="esd-container-frame" width="360" align="left">
<table width="100%" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td align="center" class="esd-empty-container" style="display: none;"></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td>
<table class="es-content" cellspacing="0" cellpadding="0" align="center">
<tbody>
<tr>
<td class="esd-stripe" align="center">
<table class="es-content-body" width="600" cellspacing="0" cellpadding="0" bgcolor="#ffffff" align="center">
<tbody>
<tr>
<td class="es-p20t es-p20r es-p20l esd-structure" align="left">
<table width="100%" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="esd-container-frame" width="560" valign="top" align="center" style="padding: 0 50px;">
<table width="100%" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td align="justify" class="esd-block-text es-m-txt-l">
<p></br></p>
<p>Dear ${first_name},</p>
<p>We hope this email finds you well. We are writing to provide you with an update regarding your recent ticket with us, ${ticket_number}.</p>
<p>We are pleased to inform you that significant progress has been made in resolving the issue you reported. Our dedicated team has been diligently working on your case, and we are confident that we are moving towards a resolution.</p>
<p>
<div>Here is a brief overview of the status:</div>
<div>Grievance ID: <strong>${id}</strong></div>
<div>Date of Registration: <strong>${created_date}</strong></div>
<div>Current Status: <strong>${status}</strong></div>
<div>Date of Last Update: <strong>${updated_date}</strong></div>
<div>Assigned Support Representative: <strong>${nodal_name}</strong></div>
</p>
<p>Our support team is continuously monitoring the situation to ensure that all necessary steps are taken to address your concerns effectively and efficiently. Rest assured; we are committed to providing you with the best possible resolution.</p>
<p>If you have any additional information or updates that could be helpful for our team to better understand your issue, please feel free to share it with us. Your input is valuable and can contribute to a swifter resolution.</p>
<p>We will keep you updated on any further developments regarding your ticket.</p>
</td>
</tr>
<tr></tr>
<tr>
<td align="left" class="esd-block-text">
<p>Sincerely,</p>
<p>
<div>${signature_name}</div>
<div>${phone}</div>
<div>${mobile}</div>
<div>${fax}</div>
<div>${email}</div>
<div>${address}</div>
</p>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<table class="esd-footer-popover es-footer" cellspacing="0" cellpadding="0" align="center" bgcolor="#fdebe8">
<tbody>
<tr>
<td class="esd-stripe" align="center">
<table class="es-footer-body" width="600" cellspacing="0" cellpadding="0" align="center" bgcolor="#ffffff" style="padding: 100px 50px;">
<tbody>
<tr>
<td class="esd-structure es-p20t es-p20b es-p20r es-p20l" align="left">
<table class="es-left" cellspacing="0" cellpadding="0" align="center">
<tbody>
<tr>
<td class="es-m-p20b esd-container-frame" width="400" align="left">
<table width="100%" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td align="center" class="esd-block-text">
<label _ngcontent-wjh-c12="" class="d-flex flex-w-wrap mb-16 flex-jc-center"><a _ngcontent-wjh-c12="" apptelemetryinteract="" href="/term-of-use.html"> Terms and Privacy </a><span _ngcontent-wjh-c12="">| © 2023, NIRAMAYA</span></label>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment