diff --git a/ClassDiagram.uml b/ClassDiagram.uml
new file mode 100644
index 0000000..4232a49
--- /dev/null
+++ b/ClassDiagram.uml
@@ -0,0 +1,541 @@
+
+
+ JAVA
+ /Users/ajaynegi/Downloads/libraryman-api/src/main/java/com/libraryman_api
+
+ com.libraryman_api.member.MemberService
+ com.libraryman_api.notification.NotificationType
+ com.libraryman_api.fine.FineRepository
+ com.libraryman_api.book.Book
+ com.libraryman_api.exception.ResourceNotFoundException
+ com.libraryman_api.book.BookController
+ com.libraryman_api.borrowing.BorrowingController
+ com.libraryman_api.notification.NotificationRepository
+ com.libraryman_api.exception.ErrorDetails
+ com.libraryman_api.borrowing.BorrowingService
+ com.libraryman_api.member.Members
+ com.libraryman_api.member.MemberRepository
+ com.libraryman_api.book.BookService
+ com.libraryman_api.email.EmailSender
+ com.libraryman_api.exception.GlobalExceptionHandler
+ com.libraryman_api.borrowing.Borrowings
+ com.libraryman_api.member.Role
+ com.libraryman_api.notification.NotificationService
+ com.libraryman_api.email.EmailService
+ com.libraryman_api.notification.Notifications
+ com.libraryman_api.LibrarymanApiApplication
+ com.libraryman_api.member.MemberController
+ com.libraryman_api.notification.NotificationStatus
+ com.libraryman_api.fine.Fines
+ com.libraryman_api.book.BookRepository
+ com.libraryman_api.borrowing.BorrowingRepository
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ com.libraryman_api.member.MemberService
+ com.libraryman_api.fine.FineRepository
+ com.libraryman_api.borrowing.BorrowingRepository
+ com.libraryman_api.LibrarymanApiApplication
+ com.libraryman_api.book.BookController
+ com.libraryman_api.notification.Notifications
+ com.libraryman_api.member.Role
+ com.libraryman_api.member.MemberRepository
+ com.libraryman_api.exception.GlobalExceptionHandler
+ com.libraryman_api.notification.NotificationRepository
+ com.libraryman_api.member.MemberController
+ com.libraryman_api.notification.NotificationStatus
+ com.libraryman_api.fine.Fines
+ com.libraryman_api.borrowing.BorrowingController
+ com.libraryman_api.exception.ResourceNotFoundException
+ com.libraryman_api.book.BookRepository
+ com.libraryman_api.email.EmailSender
+ com.libraryman_api.notification.NotificationService
+ com.libraryman_api.borrowing.BorrowingService
+ com.libraryman_api.borrowing.Borrowings
+ com.libraryman_api.notification.NotificationType
+ com.libraryman_api.exception.ErrorDetails
+ com.libraryman_api.email.EmailService
+ com.libraryman_api.book.BookService
+ com.libraryman_api.member.Members
+ com.libraryman_api.book.Book
+
+
+ Constructors
+ Fields
+ Inner Classes
+ Methods
+ Properties
+
+ All
+ private
+
+
diff --git a/src/main/java/com/libraryman_api/notification/NotificationService.java b/src/main/java/com/libraryman_api/notification/NotificationService.java
index 2a146bd..1d37dde 100644
--- a/src/main/java/com/libraryman_api/notification/NotificationService.java
+++ b/src/main/java/com/libraryman_api/notification/NotificationService.java
@@ -6,7 +6,12 @@
import com.libraryman_api.member.MemberRepository;
import com.libraryman_api.member.Members;
import org.springframework.stereotype.Service;
+
import java.sql.Timestamp;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+
/**
* Service class responsible for managing notifications within the LibraryMan application.
@@ -75,9 +80,12 @@ public void borrowBookNotification(Borrowings borrowing) {
notification.setMember(borrowing.getMember());
notification.setMessage("Congratulations! π You have successfully borrowed '" +
borrowing.getBook().getTitle() + "' on " +
- borrowing.getBorrowDate() +
+ LocalDateTime.ofInstant(borrowing.getBorrowDate().toInstant(), ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("dd MMMM yyyy"))
+
+ +
".
You now have 15 days to enjoy reading it. We kindly request that you return it to us on or before " +
- borrowing.getDueDate() +
+ LocalDateTime.ofInstant(borrowing.getDueDate().toInstant(), ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("dd MMMM yyyy"))
+ +
" to avoid any late fees π, which are βΉ10 per day for late returns.
If you need to renew the book or have any questions, please don't hesitate to reach out to us.
Thank you for choosing our library!");
notification.setNotificationType(NotificationType.BORROW);
notification.setSentDate(new Timestamp(System.currentTimeMillis()));
@@ -96,7 +104,8 @@ public void reminderNotification(Borrowings borrowing) {
notification.setMember(borrowing.getMember());
notification.setMessage("This is a friendly reminder that the due date to return '" +
borrowing.getBook().getTitle() + "' is approaching. Please ensure that you return the book by " +
- borrowing.getBorrowDate() +
+
+ LocalDateTime.ofInstant(borrowing.getDueDate().toInstant(), ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("dd MMMM yyyy HH:mm")) +
" to avoid any late fees. π
" +
"
If you need more time, consider renewing your book through our online portal or by contacting us." +
"
Thank you, and happy reading! π");
@@ -136,7 +145,7 @@ public void fineImposedNotification(Borrowings borrowing) {
notification.setMessage("We hope you enjoyed reading '" +
borrowing.getBook().getTitle() +
"'. Unfortunately, our records show that the book was returned after the due date of " +
- borrowing.getDueDate() +
+ LocalDateTime.ofInstant(borrowing.getDueDate().toInstant(), ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("dd MMMM yyyy HH:mm")) +
". As a result, a fine of βΉ10 per day has been imposed for the late return.
The total fine amount for this overdue return is βΉ" +
borrowing.getFine().getAmount() +
".
If you have any questions or would like to discuss this matter further, please don't hesitate to contact us.
Thank you for your understanding and for being a valued member of our library.");
@@ -172,7 +181,7 @@ public void accountDetailsUpdateNotification(Members members) {
public void bookReturnedNotification(Borrowings borrowing) {
Notifications notification = new Notifications();
notification.setMember(borrowing.getMember());
- notification.setMessage("Thank you for returning '" + borrowing.getBook().getTitle() + "' on " + borrowing.getReturnDate() + ". We hope you enjoyed the book!" +
+ notification.setMessage("Thank you for returning '" + borrowing.getBook().getTitle() + "' book on " + LocalDateTime.ofInstant(borrowing.getReturnDate().toInstant(), ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("dd MMMM yyyy HH:mm")) + ". We hope you enjoyed the book!" +
"
Feel free to explore our collection for your next read. If you have any questions or need assistance, weβre here to help." +
"
Thank you for choosing LibraryMan!");
notification.setNotificationType(NotificationType.RETURNED);
@@ -206,8 +215,8 @@ private void sendNotification(Notifications notification) {
/**
* Builds the email content based on the notification type, member name, and notification message.
*
- * @param notificationType the type of notification.
- * @param memberName the name of the member.
+ * @param notificationType the type of notification.
+ * @param memberName the name of the member.
* @param notificationMessage the notification message to include in the email.
* @return the built email content.
*/
@@ -245,80 +254,77 @@ private String subject(NotificationType notificationType) {
}
- private String buildEmail(String notificationType,String memberName, String notificationMessage) {
-
- return """
-
\n" +
-
-
\n" +
-
-
\n" +
- \n" +
- \n" +
- \n" +
- \n" +
- \n" +
- \n" +
- \n" +
- \n" +
- \n" +
- \n" +
- | \n" +
- \n" +
- " +notificationType+
- \n" +
- | \n" +
- \n" +
- \n" +
- \n" +
- | \n" +
- \n" +
- \n" +
- \n" +
- | \n" +
-
\n" +
-
\n" +
-
\n" +
- \n" +
- | \n" +
- \n" +
- \n" +
- \n" +
- \n" +
- | \n" +
- \n" +
- \n" +
- \n" +
- | \n" +
- | \n" +
-
\n" +
-
\n" +
- \n" +
- \n" +
- \n" +
-
\n" +
- \n" +
-
| \n" +
-
\n" +
- \n" +
-
| \n" +
- \n" +
- \n" +
- Hi " + memberName + ", " + notificationMessage + " " +
- Best regards, " +
- LibraryMan " +
- \n" +
- | \n" +
-
| \n" +
-
\n" +
- \n" +
-
| \n" +
-
\n" +
-
\n" +
-
-
- """;
+ private String buildEmail(String notificationType, String memberName, String notificationMessage) {
+ return "\n" +
+ "\n" +
+ "
\n" +
+ "\n" +
+ "
\n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " | \n" +
+ " \n" +
+ " " + notificationType +
+ "\n" +
+ " | \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " | \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " | \n" +
+ "
\n" +
+ "
\n" +
+ "
\n" +
+ " \n" +
+ " | \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " | \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " | \n" +
+ " | \n" +
+ "
\n" +
+ "
\n" +
+ "\n" +
+ "\n" +
+ "\n" +
+ "
\n" +
+ " \n" +
+ "
| \n" +
+ "
\n" +
+ " \n" +
+ "
| \n" +
+ " \n" +
+ " \n" +
+ " Hi " + memberName + ", " + notificationMessage + " " +
+ "Best regards, " +
+ "LibraryMan " +
+ " \n" +
+ " | \n" +
+ "
| \n" +
+ "
\n" +
+ " \n" +
+ "
| \n" +
+ "
\n" +
+ "
\n" +
+ "\n" +
+ "
";
}
}
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 53718a7..eeefb5c 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -1,2 +1,2 @@
spring.application.name=libraryman-api
-spring.profiles.active=${ENV:development}
\ No newline at end of file
+spring.profiles.active=${ENV:dev}
\ No newline at end of file