Add coverUpdatedOn to book entity
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
+2
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
@@ -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());
|
||||
}
|
||||
|
||||
+10
-9
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user