-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/10 board - 게시판 entity , repo 작성 #20
Changes from 8 commits
bf94604
705bfce
80c7587
c2b9536
641d9d7
e12d183
3ea011f
a22cf17
d1ec33d
7dfd2ce
5317d86
de9352f
56d8b69
f4f30c3
b87863f
fbc844a
5df9c1a
c9b4cb5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package HookKiller.server.board.controller; | ||
|
||
import HookKiller.server.board.dto.ArticleDto; | ||
import HookKiller.server.board.entity.Article; | ||
import HookKiller.server.board.service.ArticleService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@RequestMapping("/articles") | ||
@RequiredArgsConstructor | ||
public class ArticleController { | ||
|
||
private final ArticleService articleService; | ||
|
||
@GetMapping("{/boardId}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 맞지 |
||
public List<ArticleDto> getArticleList(@PathVariable Long boardId) { | ||
String language = "KOR"; | ||
return articleService.getArticleList(boardId, language); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package HookKiller.server.board.controller; | ||
|
||
import HookKiller.server.board.dto.BoardDto; | ||
import HookKiller.server.board.entity.Board; | ||
import HookKiller.server.board.service.BoardService; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.*; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/board") | ||
public class BoardController { | ||
|
||
private final BoardService boardService; | ||
|
||
@GetMapping | ||
public List<BoardDto> getBoardList() { | ||
List<BoardDto> dto = boardService.getBoardList(); | ||
return dto; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package HookKiller.server.board.dto; | ||
|
||
import HookKiller.server.board.entity.Article; | ||
import HookKiller.server.board.entity.ArticleContent; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import org.joda.time.DateTime; | ||
|
||
import java.sql.Timestamp; | ||
|
||
@Getter | ||
@Builder | ||
public class ArticleDto { | ||
|
||
private Long articleId; | ||
private String title; | ||
private Timestamp createdAt; | ||
private Long createdUser; | ||
private int likeCount; | ||
|
||
public static ArticleDto of(Article article, ArticleContent articleContent) { | ||
return ArticleDto.builder() | ||
.articleId(article.getId()) | ||
.title(articleContent.getTitle()) | ||
.createdAt(article.getCreateAt()) | ||
.createdUser(article.getCreatedUser()) | ||
.likeCount(article.getLikeCount()) | ||
.build(); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package HookKiller.server.board.dto; | ||
|
||
import HookKiller.server.board.entity.Board; | ||
import HookKiller.server.board.repository.BoardRepository; | ||
import jakarta.persistence.Enumerated; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.Setter; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Getter | ||
@Builder | ||
public class BoardDto { | ||
|
||
private Long id; | ||
private String name; | ||
private String boardType; | ||
private String description; | ||
|
||
public static BoardDto from(Board board) { | ||
return BoardDto.builder() | ||
.id(board.getId()) | ||
.name(board.getName()) | ||
.description(board.getDescription()) | ||
.build(); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,51 @@ | ||||||||||||||||||||||||||
package HookKiller.server.board.entity; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
import HookKiller.server.common.AbstractTimeStamp; | ||||||||||||||||||||||||||
import jakarta.persistence.*; | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||
import lombok.*; | ||||||||||||||||||||||||||
import org.joda.time.DateTime; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
import java.util.List; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||
* orgArticleLanguage : 원본으로 작성된 언어 타입. KOR:한국어, ENG:영어, CHI:중국어, JPN:일본어 | ||||||||||||||||||||||||||
* articleType : 게시물 종류. NOTI:공지사항, NORMAL:일반적인 게시물 | ||||||||||||||||||||||||||
* status : 게시물 상태. WRITING:작성중, PUBLIC:공개상태, HIDING:숨김처리, DELETE:삭제처리 | ||||||||||||||||||||||||||
* likeCount : 좋아요 갯수. | ||||||||||||||||||||||||||
* isDeleted : 게시글 삭제 여부 | ||||||||||||||||||||||||||
* createdAt : 게시글 생성일 | ||||||||||||||||||||||||||
* createdUser : 게시글 작성 사용자 ID입력 | ||||||||||||||||||||||||||
* updatedAt : 게시글 정보 업데이트 일자 | ||||||||||||||||||||||||||
* updatedUser : 마지막에 수정한 사용자 ID입력 | ||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아래의 컬럼과 동일한 정보인가요? |
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
@Entity | ||||||||||||||||||||||||||
@Getter | ||||||||||||||||||||||||||
@RequiredArgsConstructor | ||||||||||||||||||||||||||
public class Article extends AbstractTimeStamp { | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) | ||||||||||||||||||||||||||
private Long id; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
@ManyToOne(fetch = FetchType.LAZY) | ||||||||||||||||||||||||||
@JoinColumn(name="board_id") | ||||||||||||||||||||||||||
private Board board; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
@OneToMany | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||||||||||||||||||
private List<ArticleLike> ArticleLike; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
@OneToMany | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||||||||||||||||||
private List<ArticleContent> articleContent; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
@OneToMany | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||||||||||||||||||
private List<Reply> reply; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
private String orgArticleLanguage; | ||||||||||||||||||||||||||
private String articleType; | ||||||||||||||||||||||||||
private String status; | ||||||||||||||||||||||||||
private int likeCount; | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 혹시 likeCount 업데이트는 어떻게 진행되나요? |
||||||||||||||||||||||||||
private boolean isDeleted; | ||||||||||||||||||||||||||
private Long createdUser; | ||||||||||||||||||||||||||
private Long updatedUser; | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. create 혹은 update한 User의 Id를 쓰는거면 |
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,37 @@ | ||||||||||||||||
package HookKiller.server.board.entity; | ||||||||||||||||
|
||||||||||||||||
|
||||||||||||||||
import jakarta.persistence.*; | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||||||||
import lombok.AccessLevel; | ||||||||||||||||
import lombok.Getter; | ||||||||||||||||
import lombok.NoArgsConstructor; | ||||||||||||||||
|
||||||||||||||||
/** | ||||||||||||||||
* id : PK | ||||||||||||||||
* article : 게시글 정보 | ||||||||||||||||
* language : 적용된 언어 타입 | ||||||||||||||||
* title : 게시글 제목 | ||||||||||||||||
* content : 게시글 내용 | ||||||||||||||||
*/ | ||||||||||||||||
|
||||||||||||||||
@Entity | ||||||||||||||||
@Getter | ||||||||||||||||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
public class ArticleContent { | ||||||||||||||||
|
||||||||||||||||
@Id | ||||||||||||||||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||||||||||||||||
private Long id; | ||||||||||||||||
|
||||||||||||||||
@ManyToOne(fetch = FetchType.LAZY) | ||||||||||||||||
@JoinColumn(name="article_id") | ||||||||||||||||
private Article article; | ||||||||||||||||
|
||||||||||||||||
private String language; | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||||||||
private String title; | ||||||||||||||||
|
||||||||||||||||
@Column | ||||||||||||||||
@Lob | ||||||||||||||||
private String content; | ||||||||||||||||
|
||||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package HookKiller.server.board.entity; | ||
|
||
|
||
import HookKiller.server.common.AbstractTimeStamp; | ||
import jakarta.persistence.*; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import org.joda.time.DateTime; | ||
|
||
/** | ||
* id : PK | ||
* article : 게시물 정보 | ||
* userId : 좋아요를 누른 사용자의 userId | ||
* createdAt : 게시물 좋아요를 클릭한 일자 | ||
*/ | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class ArticleLike extends AbstractTimeStamp { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name="article_id") | ||
private Article article; | ||
|
||
private Long userId; | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,41 @@ | ||||||||||||||||||||||
package HookKiller.server.board.entity; | ||||||||||||||||||||||
|
||||||||||||||||||||||
import HookKiller.server.board.type.BoardType; | ||||||||||||||||||||||
import jakarta.persistence.*; | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||
import jakarta.validation.constraints.NotNull; | ||||||||||||||||||||||
import lombok.AccessLevel; | ||||||||||||||||||||||
import lombok.Getter; | ||||||||||||||||||||||
import lombok.NoArgsConstructor; | ||||||||||||||||||||||
import lombok.RequiredArgsConstructor; | ||||||||||||||||||||||
|
||||||||||||||||||||||
import java.util.List; | ||||||||||||||||||||||
|
||||||||||||||||||||||
/** | ||||||||||||||||||||||
* id : PK | ||||||||||||||||||||||
* name :게시판 명 | ||||||||||||||||||||||
* boardType : 게시판 종류 | ||||||||||||||||||||||
* description : 게시판 사용 용도 | ||||||||||||||||||||||
*/ | ||||||||||||||||||||||
|
||||||||||||||||||||||
@Entity | ||||||||||||||||||||||
@Getter | ||||||||||||||||||||||
@Table(name = "Board") | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 테이블명칭만 아래와 같이 설정 바람.
Suggested change
|
||||||||||||||||||||||
@RequiredArgsConstructor | ||||||||||||||||||||||
public class Board { | ||||||||||||||||||||||
|
||||||||||||||||||||||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) | ||||||||||||||||||||||
private Long id; | ||||||||||||||||||||||
|
||||||||||||||||||||||
@OneToMany | ||||||||||||||||||||||
private List<Article> article; | ||||||||||||||||||||||
|
||||||||||||||||||||||
@NotNull | ||||||||||||||||||||||
private String name; | ||||||||||||||||||||||
|
||||||||||||||||||||||
@Enumerated(EnumType.STRING) | ||||||||||||||||||||||
private BoardType boardType; | ||||||||||||||||||||||
|
||||||||||||||||||||||
@NotNull | ||||||||||||||||||||||
private String description; | ||||||||||||||||||||||
|
||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,43 @@ | ||||||||||||||||||||
package HookKiller.server.board.entity; | ||||||||||||||||||||
|
||||||||||||||||||||
import HookKiller.server.common.AbstractTimeStamp; | ||||||||||||||||||||
import jakarta.persistence.*; | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||||||||||||
import lombok.AccessLevel; | ||||||||||||||||||||
import lombok.Getter; | ||||||||||||||||||||
import lombok.NoArgsConstructor; | ||||||||||||||||||||
import org.joda.time.DateTime; | ||||||||||||||||||||
|
||||||||||||||||||||
import java.util.List; | ||||||||||||||||||||
|
||||||||||||||||||||
/** | ||||||||||||||||||||
* id : PK | ||||||||||||||||||||
* article : 게시글 정보 | ||||||||||||||||||||
* replyContent : 댓글 내용 | ||||||||||||||||||||
* orgReplyLanguage : 원본으로 작성된 언어 타입 | ||||||||||||||||||||
* isDeleted : 댓글 삭제 여부 | ||||||||||||||||||||
* createdAt : 댓글 생성일 | ||||||||||||||||||||
* createdUser : 댓글 작성 사용자 ID | ||||||||||||||||||||
* updatedAt : 댓글 정보 업데이트 | ||||||||||||||||||||
* updatedUser : 마지막에 수정한 사용자 ID | ||||||||||||||||||||
*/ | ||||||||||||||||||||
|
||||||||||||||||||||
@Entity | ||||||||||||||||||||
@Getter | ||||||||||||||||||||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||||||||||||||||||||
public class Reply extends AbstractTimeStamp { | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||
|
||||||||||||||||||||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) | ||||||||||||||||||||
private long id; | ||||||||||||||||||||
|
||||||||||||||||||||
@ManyToOne(fetch = FetchType.LAZY) | ||||||||||||||||||||
@JoinColumn(name="article_id") | ||||||||||||||||||||
private Article article; | ||||||||||||||||||||
Comment on lines
+40
to
+42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||||||||||||
|
||||||||||||||||||||
@OneToMany | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 마찬가지로 |
||||||||||||||||||||
private List<ReplyContent> replyContent; | ||||||||||||||||||||
|
||||||||||||||||||||
private String orgReplyLanguage; | ||||||||||||||||||||
private boolean isDeleted; | ||||||||||||||||||||
private Long createdUser; | ||||||||||||||||||||
private Long updatedUser; | ||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,33 @@ | ||||||||||||||||||||
package HookKiller.server.board.entity; | ||||||||||||||||||||
|
||||||||||||||||||||
import HookKiller.server.common.AbstractTimeStamp; | ||||||||||||||||||||
import jakarta.persistence.*; | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||||||||||||
import lombok.AccessLevel; | ||||||||||||||||||||
import lombok.Getter; | ||||||||||||||||||||
import lombok.NoArgsConstructor; | ||||||||||||||||||||
|
||||||||||||||||||||
/** | ||||||||||||||||||||
* language : content가 적용된 언어 타입. | ||||||||||||||||||||
* content : 댓글 내용. | ||||||||||||||||||||
*/ | ||||||||||||||||||||
|
||||||||||||||||||||
@Entity | ||||||||||||||||||||
@Getter | ||||||||||||||||||||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||||||||||||||||||||
public class ReplyContent { | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||
|
||||||||||||||||||||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) | ||||||||||||||||||||
private long id; | ||||||||||||||||||||
|
||||||||||||||||||||
@ManyToOne(fetch = FetchType.LAZY) | ||||||||||||||||||||
@JoinColumn(name="reply_id") | ||||||||||||||||||||
private Reply reply; | ||||||||||||||||||||
Comment on lines
+33
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||||||||||||
|
||||||||||||||||||||
private String language; | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LanguageType Enum으로 해야하지 않을까? |
||||||||||||||||||||
|
||||||||||||||||||||
@Column | ||||||||||||||||||||
@Lob | ||||||||||||||||||||
private String content; | ||||||||||||||||||||
|
||||||||||||||||||||
|
||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package HookKiller.server.board.exception; | ||
|
||
import HookKiller.server.common.dto.ErrorDetail; | ||
|
||
public interface BaseErrorCode { | ||
|
||
ErrorDetail getErrorDetail(); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 해당 클래스는 Common에 구현된 클래스 같이 쓰기바람. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package HookKiller.server.board.exception; | ||
|
||
|
||
import HookKiller.server.common.dto.ErrorDetail; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public class BaseException extends RuntimeException { | ||
|
||
private BaseErrorCode errorCode; | ||
|
||
public ErrorDetail getErrorDetail() { | ||
return this.errorCode.getErrorDetail(); | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 해당 클래스는 Common에 구현된 클래스 같이 쓰기바람. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package HookKiller.server.board.exception; | ||
|
||
public class ExampleException extends BaseException { | ||
|
||
public static final BaseException EXCEPTION = new ExampleException(); | ||
|
||
private ExampleException() { | ||
super(GlobalException.EXAMPLE_ERROR); | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이친구는 왜만든거야? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이게 좀 더 어울리지 않을까요?