-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
bf94604
feat : 레포작업중
lljh1992 705bfce
feat : 게시판 기능 구현
lljh1992 80c7587
Feat : article 전체조회 기능구현
lgsok00 c2b9536
Feat : article 조회 기능 구현
lgsok00 641d9d7
merge dev
lgsok00 e12d183
board entity, repo 작업 완료
lgsok00 3ea011f
Merge branch 'dev' into feat/10-board
lgsok00 a22cf17
build complate
lgsok00 d1ec33d
이슈 수정
lgsok00 7dfd2ce
feat : 게시물 등록 진행중, 임시 커밋
lgsok00 5317d86
Merge branch 'dev' into feat/10-board
lgsok00 de9352f
게시글 등록, 조회, 삭제 구현
lgsok00 56d8b69
papago api
lgsok00 f4f30c3
게시판 CRUD 구현
lgsok00 b87863f
이슈 수정
lgsok00 fbc844a
feat : 게시판 CRUD + papago 기능구현
lljh1992 5df9c1a
fix : 편안
donsonioc2010 c9b4cb5
refactor : Package Import * 제거 및 HealthController의 Papago기능 PapagoSam…
donsonioc2010 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,4 +36,5 @@ out/ | |
### VS Code ### | ||
.vscode/ | ||
|
||
.DS_Store | ||
.DS_Store | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
src/main/java/HookKiller/server/board/controller/ArticleController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package HookKiller.server.board.controller; | ||
|
||
import HookKiller.server.board.dto.ArticleRequestDto; | ||
import HookKiller.server.board.dto.PostArticleRequestDto; | ||
import HookKiller.server.board.service.ArticleContentService; | ||
import HookKiller.server.board.service.ArticleService; | ||
import HookKiller.server.common.type.LanguageType; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
@Slf4j | ||
@RestController | ||
@RequestMapping("/article") | ||
@RequiredArgsConstructor | ||
public class ArticleController { | ||
|
||
private final ArticleService articleService; | ||
private final ArticleContentService articleContentService; | ||
|
||
/** | ||
* 게시글 조회 | ||
*/ | ||
@GetMapping("/{boardId}") | ||
public List<ArticleRequestDto> getArticleList(@PathVariable Long boardId, HttpServletRequest request) { | ||
return articleService.getArticleList(boardId, LanguageType.findTypeByRequest(request)); | ||
} | ||
|
||
/** | ||
* 단건 조회 | ||
*/ | ||
// @GetMapping("/{boardId}/{articleId}") | ||
// public ArticleRequestDto getArticle(@PathVariable Long articleId, HttpServletRequest request) { | ||
// BoardType language = BoardType.valueOf(request.getHeader("language")); | ||
// return articleService.getArticle(boardId, articleId, language); | ||
// } | ||
|
||
/** | ||
* 게시글 등록 | ||
*/ | ||
@PostMapping | ||
public ResponseEntity<String> createArticle(@RequestBody PostArticleRequestDto requestDto) { | ||
articleContentService.createContent( | ||
requestDto, articleService.createArticle(requestDto) | ||
); | ||
Comment on lines
+47
to
+49
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. 여기는 깊게 생각해봤는데 두개를 한개의 메소드에서 작업하고 Transactional 처리를 해야 할 것 같습니다. 번역에 실패하면 롤백해야 하기 떄문입니다. |
||
return ResponseEntity.ok("Article Create Success"); | ||
} | ||
|
||
/** | ||
* 게시물 수정 | ||
*/ | ||
@PutMapping | ||
public ResponseEntity<String> updateArticle(@RequestBody PostArticleRequestDto requestDto) { | ||
articleContentService.updateContent(requestDto, articleService.updateArticle(requestDto)); | ||
return ResponseEntity.ok("Article Create Success"); | ||
} | ||
|
||
|
||
/** | ||
* 게시물 삭제 | ||
*/ | ||
@DeleteMapping("/{articleId}") | ||
public ResponseEntity<String> deleteArticle(@PathVariable Long articleId) { | ||
articleService.deleteArticle(articleId); | ||
return ResponseEntity.ok("삭제처리가 완료되었습니다."); | ||
} | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
src/main/java/HookKiller/server/board/dto/ArticleRequestDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package HookKiller.server.board.dto; | ||
|
||
import HookKiller.server.board.entity.Article; | ||
import HookKiller.server.board.entity.ArticleContent; | ||
import HookKiller.server.board.type.ArticleStatus; | ||
import HookKiller.server.common.AbstractTimeStamp; | ||
import HookKiller.server.common.type.LanguageType; | ||
import jakarta.persistence.EnumType; | ||
import jakarta.persistence.Enumerated; | ||
import jakarta.persistence.Lob; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@Builder | ||
public class ArticleRequestDto extends AbstractTimeStamp { | ||
|
||
private Long boardId; | ||
|
||
private Long articleId; | ||
|
||
@Enumerated(EnumType.STRING) | ||
private LanguageType orgArticleLanguage; | ||
|
||
@Enumerated(EnumType.STRING) | ||
private ArticleStatus status; | ||
|
||
private int likeCount; | ||
|
||
@Enumerated(EnumType.STRING) | ||
private LanguageType contentLanguage; | ||
|
||
private String title; | ||
|
||
@Lob | ||
private String content; | ||
|
||
public static ArticleRequestDto of(Article article, ArticleContent articleContent) { | ||
return ArticleRequestDto.builder() | ||
.articleId(article.getId()) | ||
.title(articleContent.getTitle()) | ||
.content(articleContent.getContent()) | ||
.likeCount(article.getLikeCount()) | ||
.build(); | ||
} | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/HookKiller/server/board/dto/PostArticleRequestDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package HookKiller.server.board.dto; | ||
|
||
import HookKiller.server.common.type.LanguageType; | ||
import jakarta.persistence.EnumType; | ||
import jakarta.persistence.Enumerated; | ||
import jakarta.persistence.Lob; | ||
import jakarta.validation.constraints.NotEmpty; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class PostArticleRequestDto { | ||
@NotNull(message = "게시판 ID는 필수 입니다.") | ||
private Long boardId; | ||
|
||
private Long articleId; | ||
|
||
@NotNull(message = "원본 언어는 필수 선택 하셔야 합니다.") | ||
@Enumerated(EnumType.STRING) | ||
private LanguageType orgArticleLanguage; | ||
|
||
@NotEmpty(message = "제목이 입력되지 않았습니다.") | ||
private String title; | ||
|
||
@NotEmpty(message = "내용이 입력되지 않았습니다.") | ||
private String content; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package HookKiller.server.board.entity; | ||
|
||
import HookKiller.server.board.type.ArticleStatus; | ||
import HookKiller.server.common.AbstractTimeStamp; | ||
import HookKiller.server.common.type.LanguageType; | ||
import HookKiller.server.user.entity.User; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.EnumType; | ||
import jakarta.persistence.Enumerated; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.OneToMany; | ||
import jakarta.persistence.Table; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* id : PK 키 | ||
* orgArticleLanguage : 원본으로 작성된 언어 타입. KOR:한국어, ENG:영어, CHI:중국어, JPN:일본어 | ||
* status: 게시물 상태. PUBLIC:공개, DELETE:삭제처리 | ||
* likeCount : 좋아요 갯수. | ||
* isDeleted : 게시글 삭제 여부 | ||
* createdAt : 게시글 생성일 | ||
* createdUser : 게시글 작성 사용자 ID입력 | ||
* updatedUser : 마지막에 수정한 사용자 ID입력 | ||
*/ | ||
|
||
@Entity | ||
@Getter | ||
@Setter | ||
@Table(name = "tbl_article") | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class Article extends AbstractTimeStamp { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "board_id") | ||
private Board board; | ||
|
||
@OneToMany(mappedBy = "article", fetch = FetchType.LAZY) | ||
private List<ArticleLike> ArticleLike = new ArrayList<>(); | ||
|
||
@OneToMany(mappedBy = "article", fetch = FetchType.LAZY) | ||
private List<ArticleContent> articleContent = new ArrayList<>(); | ||
|
||
@OneToMany(mappedBy = "article", fetch = FetchType.LAZY) | ||
private List<Reply> reply = new ArrayList<>(); | ||
|
||
@NotNull | ||
private LanguageType orgArticleLanguage; | ||
|
||
@NotNull | ||
@Enumerated(EnumType.STRING) | ||
private ArticleStatus articleStatus; | ||
|
||
private int likeCount; | ||
|
||
@NotNull | ||
@ManyToOne(fetch = FetchType.EAGER) | ||
private User createdUser; | ||
|
||
@NotNull | ||
@ManyToOne(fetch = FetchType.EAGER) | ||
private User updatedUser; | ||
|
||
public void updateStatus(ArticleStatus status) { | ||
articleStatus = status; | ||
} | ||
|
||
@Builder | ||
public Article(Board board, Long id, LanguageType orgArticleLanguage, ArticleStatus articleStatus, User createdUser, User updatedUser) { | ||
this.board = board; | ||
this.id = id; | ||
this.articleStatus = articleStatus; | ||
this.orgArticleLanguage = orgArticleLanguage; | ||
this.createdUser = createdUser; | ||
this.updatedUser = updatedUser; | ||
} | ||
|
||
} |
67 changes: 67 additions & 0 deletions
67
src/main/java/HookKiller/server/board/entity/ArticleContent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package HookKiller.server.board.entity; | ||
|
||
|
||
import HookKiller.server.common.type.LanguageType; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.EnumType; | ||
import jakarta.persistence.Enumerated; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.Lob; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.Table; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
/** | ||
* id : PK | ||
* article : 게시글 정보 | ||
* language : 적용된 언어 타입 | ||
* title : 게시글 제목 | ||
* content : 게시글 내용 | ||
*/ | ||
|
||
@Entity | ||
@Getter | ||
@Table(name = "tbl_article_content") | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class ArticleContent { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@NotNull | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name="article_id") | ||
private Article article; | ||
|
||
@Enumerated(EnumType.STRING) | ||
private LanguageType language; | ||
|
||
@NotNull | ||
private String title; | ||
|
||
@NotNull | ||
@Lob | ||
private String content; | ||
|
||
@Builder | ||
public ArticleContent(Article article, LanguageType language, String title, String content) { | ||
this.article = article; | ||
this.language = language; | ||
this.title = title; | ||
this.content = content; | ||
} | ||
|
||
public void articleUpdate(String title, String content) { | ||
this.title = title; | ||
this.content = content; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/HookKiller/server/board/entity/ArticleLike.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package HookKiller.server.board.entity; | ||
|
||
|
||
import HookKiller.server.common.AbstractTimeStamp; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.Table; | ||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
/** | ||
* id : PK | ||
* article : 게시물 정보 | ||
* userId : 좋아요를 누른 사용자의 userId | ||
* createdAt : 게시물 좋아요를 클릭한 일자 | ||
*/ | ||
|
||
@Entity | ||
@Getter | ||
@Table(name = "tbl_article_like") | ||
@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; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.