licailing 3 lat temu
rodzic
commit
a6dee9f939

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

@@ -24,4 +24,5 @@ public class NewsLike extends BaseEntity {
 
     private Long newsId;
 
+    private Long showroomId;
 }

+ 15 - 0
src/main/java/com/izouma/nineth/domain/ShowCollection.java

@@ -0,0 +1,15 @@
+package com.izouma.nineth.domain;
+
+import lombok.Data;
+
+@Data
+public class ShowCollection extends BaseEntity {
+
+    private Long showroomId;
+
+    private Long collectionId;
+
+    private Long pic;
+
+    private int sort;
+}

+ 27 - 0
src/main/java/com/izouma/nineth/domain/Showroom.java

@@ -0,0 +1,27 @@
+package com.izouma.nineth.domain;
+
+import lombok.Data;
+
+import javax.persistence.Transient;
+import java.util.List;
+
+@Data
+public class Showroom extends BaseEntity {
+    private Long userId;
+
+    private Long assetId;
+
+    private String introduction;
+
+    private int like;
+
+    private int share;
+
+    private String status;
+
+    @Transient
+    private List<ShowCollection> collections;
+//    @Convert(converter = LongArrayConverter.class)
+//    @Column(columnDefinition = "TEXT")
+//    private List<Long> collectionId;
+}

+ 2 - 0
src/main/java/com/izouma/nineth/repo/NewsLikeRepo.java

@@ -16,4 +16,6 @@ public interface NewsLikeRepo extends JpaRepository<NewsLike, Long>, JpaSpecific
     void softDelete(Long id);
 
     List<NewsLike> findByUserIdAndNewsId(Long userId, Long newsId);
+
+    List<NewsLike> findByUserIdAndShowroomId(Long userId, Long showroomId);
 }

+ 18 - 0
src/main/java/com/izouma/nineth/service/NewsLikeService.java

@@ -39,4 +39,22 @@ public class NewsLikeService {
             newsRepo.addLike(newsId, -list.size());
         }
     }
+
+    public void likeRoom(Long userId, Long roomId) {
+        List<NewsLike> list = newsLikeRepo.findByUserIdAndShowroomId(userId, roomId);
+        if (!list.isEmpty()) return;
+        newsLikeRepo.save(NewsLike.builder()
+                .userId(userId)
+                .showroomId(roomId)
+                .build());
+//        newsRepo.addLike(newsId, 1);
+    }
+
+    public void unlikeRoom(Long userId, Long roomId) {
+        List<NewsLike> list = newsLikeRepo.findByUserIdAndShowroomId(userId, roomId);
+        if (!list.isEmpty()) {
+            newsLikeRepo.deleteAll(list);
+//            newsRepo.addLike(newsId, -list.size());
+        }
+    }
 }