Skip to content
Snippets Groups Projects
Commit 6e336f12 authored by David Hammond's avatar David Hammond
Browse files

Creating notification code

parent 6b8cca73
Branches
No related tags found
No related merge requests found
......@@ -68,23 +68,19 @@ public class NotificationController {
}
private void notifyCustomerAboutComment(HashMap<String, String> data, Authentication authentication) {
// Extract necessary information from the data map
String username = authentication.getName();
int complaintId = Integer.parseInt(data.get("complaintId"));
String commentTitle = data.get("commentTitle");
String commentContent = data.get("commentContent");
// Use the notification service to notify about the comment
notificationService.notifyComment(username, complaintId, commentTitle, commentContent);
}
private void notifyCustomerAboutComplaintUpdate(HashMap<String, String> data, Authentication authentication) {
// Extract necessary information from the data map
String username = authentication.getName();
int complaintId = Integer.parseInt(data.get("complaintId"));
String newStatus = data.get("status");
// Use the notification service to notify about the complaint status change
notificationService.notifyComplaintStatusChange(username, complaintId, newStatus);
}
}
......@@ -11,19 +11,22 @@ public class NotificationService {
private JdbcTemplate jdbcTemplate;
public void notifyComment(String username, int complaintId, String commentTitle, String commentContent) {
// Save comment notification to the database
String sql = "INSERT INTO notification (customerId, message) VALUES (?, ?)";
jdbcTemplate.update(sql, complaintId, "New Comment: " + commentTitle);
String message = "New Comment: " + commentTitle + "\n" + commentContent;
saveNotification(complaintId, message);
System.out.println("Notification for comment: " + commentTitle);
}
public void notifyComplaintStatusChange(String username, int complaintId, String newStatus) {
// Save status change notification to the database
String sql = "INSERT INTO notification (customerId, message) VALUES (?, ?)";
jdbcTemplate.update(sql, complaintId, "Complaint Status Change: " + newStatus);
String message = "Complaint Status Change: " + newStatus;
saveNotification(complaintId, message);
System.out.println("Notification for complaint status change: " + newStatus);
}
private void saveNotification(int customerId, String message) {
String sql = "INSERT INTO notification (customerId, message) VALUES (?, ?)";
jdbcTemplate.update(sql, customerId, message);
}
public Notification getNotification(int customerId) {
// Retrieve notification for a specific customer from the database
String sql = "SELECT id, customerId, message FROM notification WHERE customerId = ?";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment