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