Feature/update date finished date (#873)

* Fixed issue with not updating the book finished date when updating read status
* Added ability to set a date finished after setting the book status to Read.

---------

Co-authored-by: Aditya Chandel <8075870+adityachandelgit@users.noreply.github.com>
This commit is contained in:
astrodad
2025-08-11 21:33:47 -06:00
committed by GitHub
co-authored by Aditya Chandel
parent 7a859a7536
commit 53aae8bb42
5 changed files with 122 additions and 7 deletions
@@ -6,6 +6,7 @@ import com.adityachandel.booklore.model.dto.progress.PdfProgress;
import jakarta.validation.constraints.AssertTrue;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.time.Instant;
@Data
public class ReadProgressRequest {
@@ -14,9 +15,10 @@ public class ReadProgressRequest {
private EpubProgress epubProgress;
private PdfProgress pdfProgress;
private CbxProgress cbxProgress;
private Instant dateFinished;
@AssertTrue(message = "Either epubProgress or pdfProgress must be provided")
@AssertTrue(message = "At least one progress field must be provided")
public boolean isProgressValid() {
return epubProgress != null || pdfProgress != null || cbxProgress != null;
return epubProgress != null || pdfProgress != null || cbxProgress != null || dateFinished != null;
}
}
@@ -312,6 +312,12 @@ public class BookService {
userBookProgress.setCbxProgress(request.getCbxProgress().getPage());
userBookProgress.setCbxProgressPercent(request.getCbxProgress().getPercentage());
}
// Update dateFinished if provided
if (request.getDateFinished() != null) {
userBookProgress.setDateFinished(request.getDateFinished());
}
userBookProgressRepository.save(userBookProgress);
}