This commit is contained in:
+10
@@ -6,6 +6,8 @@ import org.springframework.data.jpa.repository.Query;
|
|||||||
import org.springframework.data.repository.query.Param;
|
import org.springframework.data.repository.query.Param;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.Modifying;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@@ -58,4 +60,12 @@ public interface UserBookFileProgressRepository extends JpaRepository<UserBookFi
|
|||||||
@Param("userId") Long userId,
|
@Param("userId") Long userId,
|
||||||
@Param("bookIds") Iterable<Long> bookIds
|
@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);
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-1
@@ -431,7 +431,10 @@ public class ReadingProgressService {
|
|||||||
List<Long> bookIdList = new ArrayList<>(bookIds);
|
List<Long> bookIdList = new ArrayList<>(bookIds);
|
||||||
|
|
||||||
switch (type) {
|
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 KOREADER -> userBookProgressRepository.bulkResetKoreaderProgress(userId, bookIdList);
|
||||||
case KOBO -> {
|
case KOBO -> {
|
||||||
userBookProgressRepository.bulkResetKoboProgress(userId, bookIdList);
|
userBookProgressRepository.bulkResetKoboProgress(userId, bookIdList);
|
||||||
|
|||||||
@@ -163,8 +163,13 @@ export class BookPatchService {
|
|||||||
const updatedBooks = (currentState.books || []).map(book => {
|
const updatedBooks = (currentState.books || []).map(book => {
|
||||||
const response = responses.find(r => r.bookId === book.id);
|
const response = responses.find(r => r.bookId === book.id);
|
||||||
if (response) {
|
if (response) {
|
||||||
|
const progressReset: Partial<Book> =
|
||||||
|
type === 'KOREADER' ? {koreaderProgress: undefined} :
|
||||||
|
type === 'KOBO' ? {koboProgress: undefined} :
|
||||||
|
{epubProgress: undefined, pdfProgress: undefined, cbxProgress: undefined, audiobookProgress: undefined};
|
||||||
return {
|
return {
|
||||||
...book,
|
...book,
|
||||||
|
...progressReset,
|
||||||
readStatus: response.readStatus,
|
readStatus: response.readStatus,
|
||||||
readStatusModifiedTime: response.readStatusModifiedTime,
|
readStatusModifiedTime: response.readStatusModifiedTime,
|
||||||
dateFinished: response.dateFinished
|
dateFinished: response.dateFinished
|
||||||
|
|||||||
Reference in New Issue
Block a user