Browse Source

collection/all 报错

licailing 3 years ago
parent
commit
797c2b7806

+ 1 - 1
src/main/java/com/izouma/nineth/domain/NewsLike.java

@@ -13,7 +13,7 @@ import javax.persistence.Table;
 @Data
 @Entity
 @Table(name = "like_info", indexes =
-        {@Index(columnList = "userId"), @Index(columnList = "newsId")})
+        {@Index(columnList = "userId"), @Index(columnList = "newsId"), @Index(columnList = "showroomId")})
 @AllArgsConstructor
 @NoArgsConstructor
 @Builder

+ 1 - 1
src/main/java/com/izouma/nineth/repo/LikeRepo.java

@@ -17,5 +17,5 @@ public interface LikeRepo extends JpaRepository<Like, Long>, JpaSpecificationExe
 
     List<Like> findByUserIdAndCollectionId(Long userId, Long collectionId);
 
-    List<Like> findByUserId(Long userId);
+    List<Like> findByUserIdAndCollectionIdIsNotNull(Long userId);
 }

+ 1 - 1
src/main/java/com/izouma/nineth/service/CollectionService.java

@@ -214,7 +214,7 @@ public class CollectionService {
         List<Like> likes = new ArrayList<>();
         List<Appointment> appointments = new ArrayList<>();
         if (SecurityUtils.getAuthenticatedUser() != null) {
-            likes.addAll(likeRepo.findByUserId(SecurityUtils.getAuthenticatedUser().getId()));
+            likes.addAll(likeRepo.findByUserIdAndCollectionIdIsNotNull(SecurityUtils.getAuthenticatedUser().getId()));
             appointments.addAll(appointmentRepo.findByUserId(SecurityUtils.getAuthenticatedUser().getId()));
         }
         return collections.stream().parallel().map(collection -> {