Skip to content

Commit

Permalink
feat : 게시물 좋아요 초안 작성
Browse files Browse the repository at this point in the history
  • Loading branch information
donsonioc2010 committed Oct 16, 2023
1 parent 5869220 commit 5b901a5
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package HookKiller.server.board.controller;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/article/like")
@RequiredArgsConstructor
public class ArticleLikeController {

}
7 changes: 4 additions & 3 deletions src/main/java/HookKiller/server/board/entity/Article.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import HookKiller.server.common.AbstractTimeStamp;
import HookKiller.server.common.type.LanguageType;
import HookKiller.server.user.entity.User;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
Expand Down Expand Up @@ -51,13 +52,13 @@ public class Article extends AbstractTimeStamp {
@JoinColumn(name = "board_id")
private Board board;

@OneToMany(mappedBy = "article", fetch = FetchType.LAZY)
@OneToMany(mappedBy = "article", fetch = FetchType.LAZY, orphanRemoval = true, cascade = CascadeType.ALL)
private List<ArticleLike> ArticleLike = new ArrayList<>();

@OneToMany(mappedBy = "article", fetch = FetchType.LAZY)
@OneToMany(mappedBy = "article", fetch = FetchType.LAZY, orphanRemoval = true, cascade = CascadeType.ALL)
private List<ArticleContent> articleContent = new ArrayList<>();

@OneToMany(mappedBy = "article", fetch = FetchType.LAZY)
@OneToMany(mappedBy = "article", fetch = FetchType.LAZY, orphanRemoval = true, cascade = CascadeType.ALL)
private List<Reply> reply = new ArrayList<>();

@NotNull
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/HookKiller/server/board/entity/ArticleLike.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@


import HookKiller.server.common.AbstractTimeStamp;
import HookKiller.server.user.entity.User;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
Expand Down Expand Up @@ -31,9 +33,11 @@ public class ArticleLike extends AbstractTimeStamp {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne(fetch = FetchType.LAZY)
@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL )
@JoinColumn(name="article_id")
private Article article;

private Long userId;
@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinColumn(name="user_id")
private User user;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package HookKiller.server.board.repository;

import HookKiller.server.board.entity.ArticleLike;
import org.springframework.data.jpa.repository.JpaRepository;

public interface ArticleLikeRepository extends JpaRepository<ArticleLike, Long> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package HookKiller.server.board.service;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Slf4j
@Service
@RequiredArgsConstructor
public class ArticleLikeService {
}

0 comments on commit 5b901a5

Please sign in to comment.