Przeglądaj źródła

修复文章阅读记录 bug

tianyunperfect 3 lat temu
rodzic
commit
7d2e17cce5

+ 11 - 3
book-server/src/main/java/com/book/server/service/impl/BookServiceImpl.java

@@ -269,7 +269,7 @@ public class BookServiceImpl implements BookService {
         if (freeChapterNum == null) { //查看默认配置
             freeChapterNum = getDefaultFreeChapterNum();
         }
-        if (bookContentVO.getNum()  >= freeChapterNum) {
+        if (bookContentVO.getNum() >= freeChapterNum) {
             //收费
             //是否已购买
             Consume consume = consumeMapper.selectOneByExample(ConsumeExample.newAndCreateCriteria()
@@ -499,8 +499,11 @@ public class BookServiceImpl implements BookService {
         for (UserRecentlyRead userRecentlyRead : userRecentlyReads) {
             UserRecentlyReadRes recentlyReadRes = new UserRecentlyReadRes();
             BeanUtils.copyProperties(userRecentlyRead, recentlyReadRes);
-            recentlyReadRes.setBookName(map.get(userRecentlyRead.getBookId()).getName());
-            recentlyReadRes.setImage(map.get(userRecentlyRead.getBookId()).getImage());
+            Book book = map.get(userRecentlyRead.getBookId());
+            if (book != null) {
+                recentlyReadRes.setBookName(book.getName());
+                recentlyReadRes.setImage(book.getImage());
+            }
             res.add(recentlyReadRes);
         }
 
@@ -825,6 +828,11 @@ public class BookServiceImpl implements BookService {
                             .andBookIdEqualTo(id)
                             .example()
             );
+            userRecentlyReadMapper.deleteByExample(
+                    UserRecentlyReadExample.newAndCreateCriteria()
+                            .andBookIdEqualTo(id)
+                            .example()
+            );
             return 1;
         } else {
             return 0;