Add coverUpdatedOn to book entity

This commit is contained in:
aditya.chandel
2025-01-18 10:40:26 -07:00
parent ad741440b4
commit 41c3bc99b7
7 changed files with 21 additions and 9 deletions
@@ -17,6 +17,7 @@ public class Book {
private String title;
private Instant lastReadTime;
private Instant addedOn;
private Instant coverUpdatedOn;
private BookMetadata metadata;
private Integer pdfProgress;
private String epubProgress;
@@ -48,6 +48,9 @@ public class BookEntity {
@Column(name = "added_on")
private Instant addedOn;
@Column(name = "cover_updated_on")
private Instant coverUpdatedOn;
@Column(name = "epub_progress")
private String epubProgress;
@@ -24,6 +24,7 @@ import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.time.Instant;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.time.format.DateTimeParseException;
@@ -82,6 +83,7 @@ public class EpubProcessor implements FileProcessor {
boolean success = saveCoverImage(coverImage, bookEntity.getId());
if (success) {
fileProcessingUtils.setBookCoverPath(bookEntity.getId(), bookEntity.getMetadata());
bookEntity.setCoverUpdatedOn(Instant.now());
}
}
}
@@ -20,6 +20,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.time.Instant;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Optional;
@@ -72,6 +73,7 @@ public class PdfProcessor implements FileProcessor {
boolean success = generateCoverImageAndSave(bookEntity.getId(), document);
if (success) {
fileProcessingUtils.setBookCoverPath(bookEntity.getId(), bookEntity.getMetadata());
bookEntity.setCoverUpdatedOn(Instant.now());
}
}
@@ -17,6 +17,7 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.io.IOException;
import java.time.Instant;
import java.util.HashSet;
import java.util.List;
import java.util.stream.Collectors;
@@ -68,6 +69,7 @@ public class BookMetadataUpdater {
String thumbnailPath = null;
try {
thumbnailPath = fileService.createThumbnail(bookId, newMetadata.getThumbnailUrl());
bookEntity.setCoverUpdatedOn(Instant.now());
} catch (IOException e) {
log.error(e.getMessage());
}
@@ -16,15 +16,16 @@ CREATE TABLE IF NOT EXISTS library_path
CREATE TABLE IF NOT EXISTS book
(
id BIGINT AUTO_INCREMENT PRIMARY KEY,
file_name VARCHAR(255) NOT NULL,
book_type VARCHAR(6) NOT NULL,
library_id BIGINT NOT NULL,
path VARCHAR(1000) NOT NULL,
added_on TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
last_read_time TIMESTAMP NULL,
pdf_progress INT NULL,
epub_progress VARCHAR(1000) NULL,
id BIGINT AUTO_INCREMENT PRIMARY KEY,
file_name VARCHAR(255) NOT NULL,
book_type VARCHAR(6) NOT NULL,
library_id BIGINT NOT NULL,
path VARCHAR(1000) NOT NULL,
cover_updated_on TIMESTAMP NULL,
added_on TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
last_read_time TIMESTAMP NULL,
pdf_progress INT NULL,
epub_progress VARCHAR(1000) NULL,
CONSTRAINT fk_library FOREIGN KEY (library_id) REFERENCES library (id) ON DELETE CASCADE,
CONSTRAINT unique_file_library UNIQUE (file_name, library_id)
@@ -9,6 +9,7 @@ export interface Book {
metadata?: BookMetadata;
shelves?: Shelf[];
lastReadTime?: string;
coverUpdatedOn?: string;
addedOn?: string;
epubProgress?: string;
pdfProgress?: number;