Commit 1b3f60c2 authored by shishir suman's avatar shishir suman
Browse files

feedback related fixes

Showing with 39 additions and 2 deletions
+39 -2
......@@ -4,6 +4,9 @@ import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import org.upsmf.grievance.model.Comments;
import java.util.List;
@Repository
public interface CommentRepository extends CrudRepository<Comments, Long> {
List<Comments> findAllByTicketId(Long ticketId);
}
package org.upsmf.grievance.service.impl;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.auth.oauth2.ServiceAccountCredentials;
import com.google.cloud.storage.*;
import lombok.extern.slf4j.Slf4j;
......@@ -79,7 +81,12 @@ public class AttachmentServiceImpl implements AttachmentService {
URL url = blob.signUrl(30, TimeUnit.DAYS);
log.info("URL - {}", url);
String urlString = url.toURI().toString();
return ResponseEntity.ok(urlString);
ObjectMapper mapper = new ObjectMapper();
ObjectNode urlNode = mapper.createObjectNode();
urlNode.put("url", urlString);
ObjectNode node = mapper.createObjectNode();
node.put("result", urlNode);
return ResponseEntity.ok(mapper.writeValueAsString(node));
} catch (IOException e) {
log.error("Error while uploading attachment", e);
return ResponseEntity.internalServerError().body("Error while uploading file.");
......
......@@ -57,6 +57,9 @@ public class TicketServiceImpl implements TicketService {
@Autowired
private OtpService otpService;
@Value("${feedback.base.url}")
private String feedbackBaseUrl;
/**
*
* @param ticket
......@@ -189,10 +192,32 @@ public class TicketServiceImpl implements TicketService {
TicketStatus currentTicketStatus=curentUpdatedTicket.getStatus();
curentUpdatedTicket.getEmail();
curentUpdatedTicket.getTicketId();
otpService.sendGenericEmail(curentUpdatedTicket.getEmail(), "updated Ticket for " +curentUpdatedTicket.getTicketId() ,"ticket as updated to" +curentUpdatedTicket.getStatus().name());
if(curentUpdatedTicket.getStatus().name().equalsIgnoreCase(TicketStatus.CLOSED.name()) && !curentUpdatedTicket.getJunk()) {
String link = generateLinkFeedbackLink(curentUpdatedTicket);
otpService.sendGenericEmail(curentUpdatedTicket.getEmail(), "updated Ticket for " +curentUpdatedTicket.getTicketId() ,"ticket as updated to " +curentUpdatedTicket.getStatus().name()+ " Please provide your feedback by visiting below link."+link);
return ticket;
}
otpService.sendGenericEmail(curentUpdatedTicket.getEmail(), "updated Ticket for " +curentUpdatedTicket.getTicketId() ,"ticket as updated to " +curentUpdatedTicket.getStatus().name());
return ticket;
}
private String generateLinkFeedbackLink(org.upsmf.grievance.model.es.Ticket curentUpdatedTicket) {
List<Comments> comments = commentRepository.findAllByTicketId(curentUpdatedTicket.getTicketId());
Comments latestComment =null;
if(comments!=null && comments.size() > 0) {
latestComment = comments.get(comments.size()-1);
}
return feedbackBaseUrl.concat("?").concat("guestName=")
.concat(curentUpdatedTicket.getFirstName().concat("%20").concat(curentUpdatedTicket.getLastName()))
.concat("&ticketId=").concat(String.valueOf(curentUpdatedTicket.getTicketId()))
.concat("&resolutionComment=").concat(latestComment!=null?latestComment.getComment():"")
.concat("&email=").concat(curentUpdatedTicket.getEmail())
.concat("&phone=").concat(curentUpdatedTicket.getPhone())
.concat("&ticketTitle=").concat(curentUpdatedTicket.getDescription());
//https://grievances.uphrh.in/feedback?guestName=Devendra&ticketId=123&ticketTitle=Registration&resolutionComment=Resolved
}
@Override
public Ticket getTicketById(long id) {
if(id <= 0) {
......
......@@ -89,6 +89,8 @@ exam=4
registration=1
assessment=3
feedback.base.url=https://grievances.uphrh.in/feedback
......
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