mirror of
https://github.com/booklore-app/booklore.git
synced 2026-02-18 00:17:53 +01:00
This commit is contained in:
@@ -6,6 +6,8 @@ import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -58,4 +60,12 @@ public interface UserBookFileProgressRepository extends JpaRepository<UserBookFi
|
||||
@Param("userId") Long userId,
|
||||
@Param("bookIds") Iterable<Long> bookIds
|
||||
);
|
||||
|
||||
@Modifying
|
||||
@Query("""
|
||||
DELETE FROM UserBookFileProgressEntity ubfp
|
||||
WHERE ubfp.user.id = :userId
|
||||
AND ubfp.bookFile.book.id IN :bookIds
|
||||
""")
|
||||
int deleteByUserIdAndBookIds(@Param("userId") Long userId, @Param("bookIds") Iterable<Long> bookIds);
|
||||
}
|
||||
|
||||
@@ -431,7 +431,10 @@ public class ReadingProgressService {
|
||||
List<Long> bookIdList = new ArrayList<>(bookIds);
|
||||
|
||||
switch (type) {
|
||||
case BOOKLORE -> userBookProgressRepository.bulkResetBookloreProgress(userId, bookIdList, now);
|
||||
case BOOKLORE -> {
|
||||
userBookProgressRepository.bulkResetBookloreProgress(userId, bookIdList, now);
|
||||
userBookFileProgressRepository.deleteByUserIdAndBookIds(userId, bookIdList);
|
||||
}
|
||||
case KOREADER -> userBookProgressRepository.bulkResetKoreaderProgress(userId, bookIdList);
|
||||
case KOBO -> {
|
||||
userBookProgressRepository.bulkResetKoboProgress(userId, bookIdList);
|
||||
|
||||
@@ -163,8 +163,13 @@ export class BookPatchService {
|
||||
const updatedBooks = (currentState.books || []).map(book => {
|
||||
const response = responses.find(r => r.bookId === book.id);
|
||||
if (response) {
|
||||
const progressReset: Partial<Book> =
|
||||
type === 'KOREADER' ? {koreaderProgress: undefined} :
|
||||
type === 'KOBO' ? {koboProgress: undefined} :
|
||||
{epubProgress: undefined, pdfProgress: undefined, cbxProgress: undefined, audiobookProgress: undefined};
|
||||
return {
|
||||
...book,
|
||||
...progressReset,
|
||||
readStatus: response.readStatus,
|
||||
readStatusModifiedTime: response.readStatusModifiedTime,
|
||||
dateFinished: response.dateFinished
|
||||
|
||||
Reference in New Issue
Block a user